NebulaGraph Java Client  release-3.8
BaseTableRow.java
1 /* Copyright (c) 2020 vesoft inc. All rights reserved.
2  *
3  * This source code is licensed under Apache 2.0 License.
4  */
5 
6 package com.vesoft.nebula.client.storage.data;
7 
8 import com.vesoft.nebula.client.graph.data.DateTimeWrapper;
9 import com.vesoft.nebula.client.graph.data.DateWrapper;
10 import com.vesoft.nebula.client.graph.data.DurationWrapper;
11 import com.vesoft.nebula.client.graph.data.GeographyWrapper;
12 import com.vesoft.nebula.client.graph.data.TimeWrapper;
13 import com.vesoft.nebula.client.graph.data.ValueWrapper;
14 import java.io.Serializable;
15 import java.io.UnsupportedEncodingException;
16 import java.util.List;
17 
18 public class BaseTableRow implements Serializable {
19  protected final List<ValueWrapper> values;
20  protected String decodeType = "utf-8";
21 
22  public BaseTableRow(List<ValueWrapper> values) {
23  this.values = values;
24  }
25 
26  public BaseTableRow(List<ValueWrapper> values, String decodeType) {
27  this.values = values;
28  this.decodeType = decodeType;
29  }
30 
34  public int size() {
35  return values.size();
36  }
37 
41  public boolean isNullAt(int i) {
42  return values.get(i) == null;
43  }
44 
45  public String getString(int i) throws UnsupportedEncodingException {
46  return values.get(i).asString();
47  }
48 
49  public long getLong(int i) {
50  return values.get(i).asLong();
51  }
52 
53  public boolean getBoolean(int i) {
54  return values.get(i).asBoolean();
55  }
56 
57  public double getDouble(int i) {
58  return values.get(i).asDouble();
59  }
60 
61  public DateWrapper getDate(int i) {
62  return values.get(i).asDate();
63  }
64 
65  public TimeWrapper getTime(int i) {
66  return values.get(i).asTime();
67  }
68 
69  public DateTimeWrapper getDateTime(int i) {
70  return values.get(i).asDateTime();
71  }
72 
73  public GeographyWrapper getGeography(int i) {
74  return values.get(i).asGeography();
75  }
76 
77  public DurationWrapper getDuration(int i) {
78  return values.get(i).asDuration();
79  }
80 
81  public List<ValueWrapper> getValues() {
82  return values;
83  }
84 
85 
89  public String mkString(String sep) {
90  return mkString("", sep, "");
91  }
92 
97  public String mkString(String start, String sep, String end) {
98  int n = size();
99  StringBuilder builder = new StringBuilder();
100  builder.append(start);
101  if (n > 0) {
102  builder.append(values.get(0));
103  int i = 1;
104  while (i < n) {
105  builder.append(sep);
106  builder.append(values.get(i));
107  i++;
108  }
109  }
110  builder.append(end);
111  return builder.toString();
112  }
113 
114 }
boolean isNullAt(int i)
check whether the value at position i is null
String mkString(String sep)
Displays all elements of this vertexTableRow in a string using a separator string.
String mkString(String start, String sep, String end)
Displays all elements of this vertexTableRow in a string using start, end, and separator strings.
int size()
number of elements in vertexTableRow