public class RowValue
extends java.lang.Object
implements java.io.Serializable
This corresponds to the value of a MemoryStore Row object, i.e. the MemoryStore row without the key.
Note that to maximize efficiency this class uses a fairly low-level interface for getting and setting values, which require specifying fields using a type-specific index value (typedIndex) rather than simply specifying the field number. e.g. if the schema types were [integer, boolean, string] then you'd set the first string value by calling setString(0) not setString(2).
When the schema types for the table
are known, it's simplest to use the RowValueHelper
class to find the
type-specific index from the field number before calling
the get/set methods. For example:
RowValueHelper helper = new RowValueHelper("string", "integer", "boolean", "float", "string");
int i = 0;
RowValue rowValue = helper.createRowValue()
.setString (helper.getTypedIndex(i++), "s1")
.setInteger (helper.getTypedIndex(i++), 200)
.setBoolean (helper.getTypedIndex(i++), true)
.setFloat (helper.getTypedIndex(i++), 300.2)
.setString (helper.getTypedIndex(i++), "s2")
;
System.out.println("The values of the 4th and 5th fields are: "+
rowValue.getFloat(helper.getTypedIndex(3))+" and "+
rowValue.getString(helper.getTypedIndex(4))
);
i = 0;
for (Object v: helper.fieldValues(rowValue))
System.out.println("Got value: "+(i++)+"='"+v+"' ("+v.getClass().getSimpleName()+")");
Constructor and Description |
---|
RowValue()
Default constructor for creating a new RowValue where the schema is not known.
|
Modifier and Type | Method and Description |
---|---|
RowValue |
clone()
Clone the values that represent this RowValue into a new RowValue
|
boolean |
equals(java.lang.Object obj) |
boolean |
getBoolean(int typedIndex)
Get the n'th field of this type.
|
double |
getFloat(int typedIndex)
Get the n'th field of this type.
|
long |
getInteger(int typedIndex)
Get the n'th field of this type.
|
java.lang.String |
getString(int typedIndex)
Get the n'th string field.
|
byte[] |
getStringBytes(int typedIndex)
Get the n'th string field of this type as a null-terminated array of UTF-8 bytes
(which is currently the in-memory storage format for strings).
|
int |
hashCode() |
RowValue |
setBoolean(int typedIndex,
boolean value)
Set the n'th field of this type.
|
void |
setBoolean(int typedIndex,
int maxSizeHint,
boolean v)
Deprecated.
|
RowValue |
setFloat(int typedIndex,
double value)
Set the n'th field of this type.
|
void |
setFloat(int typedIndex,
int maxSizeHint,
double v)
Deprecated.
|
void |
setInteger(int typedIndex,
int maxSizeHint,
long v)
Deprecated.
|
RowValue |
setInteger(int typedIndex,
long value)
Set the n'th field of this type.
|
void |
setString(int typedIndex,
int maxSizeHint,
byte[] utf8ByteString)
Deprecated.
|
void |
setString(int typedIndex,
int maxSizeHint,
java.lang.String v)
Deprecated.
|
RowValue |
setString(int typedIndex,
java.lang.String value)
Set the n'th string field.
|
RowValue |
setStringBytes(int typedIndex,
byte[] value)
Set the n'th string field from a UTF-8 null-terminated byte array
(which is currently the in-memory storage format for strings).
|
java.lang.String |
toString() |
public RowValue()
If the schema is known, then use the more efficient
RowValueHelper.createRowValue()
instead.
RowValueHelper.createRowValue()
public java.lang.String toString()
toString
in class java.lang.Object
public RowValue clone()
clone
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String getString(int typedIndex)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.public final byte[] getStringBytes(int typedIndex)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.public final RowValue setString(int typedIndex, java.lang.String value)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.value
- public final RowValue setStringBytes(int typedIndex, byte[] value)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.value
- The string as a null-terminated UTF-8 string. Ownership passes to the
RowValue when this method is called; it is NOT permitted to mutate the array after this point.@Deprecated public final void setString(int typedIndex, int maxSizeHint, java.lang.String v)
@Deprecated public final void setString(int typedIndex, int maxSizeHint, byte[] utf8ByteString)
public final long getInteger(int typedIndex)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.public final RowValue setInteger(int typedIndex, long value)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.value
- @Deprecated public final void setInteger(int typedIndex, int maxSizeHint, long v)
public final double getFloat(int typedIndex)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.public final RowValue setFloat(int typedIndex, double value)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.value
- @Deprecated public final void setFloat(int typedIndex, int maxSizeHint, double v)
public final boolean getBoolean(int typedIndex)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.public final RowValue setBoolean(int typedIndex, boolean value)
typedIndex
- The type-specific index n, where n is the n'th field of this particular type.value
- @Deprecated public final void setBoolean(int typedIndex, int maxSizeHint, boolean v)
Submit a bug or feature
Copyright (c) 2013-2015 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors. Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.