com.apama.correlator.memstore
Class RowValue

java.lang.Object
  extended by com.apama.correlator.memstore.RowValue
All Implemented Interfaces:
java.io.Serializable

public class RowValue
extends java.lang.Object
implements java.io.Serializable

The value of an entry/row in a distributed store's table.

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()+")");

See Also:
Serialized Form

Constructor Summary
RowValue()
          Default constructor for creating a new RowValue where the schema is not known.
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RowValue

public RowValue()
Default constructor for creating a new RowValue where the schema is not known.

If the schema is known, then use the more efficient RowValueHelper.createRowValue() instead.

See Also:
RowValueHelper.createRowValue()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public RowValue clone()
Clone the values that represent this RowValue into a new RowValue

Overrides:
clone in class java.lang.Object
Returns:
the cloned RowValue

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getString

public final java.lang.String getString(int typedIndex)
Get the n'th string field.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
Returns:
The field value, or the default value "" if the specified index is out of range or there is no value set for it.

getStringBytes

public final 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).

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
Returns:
The field value as null-terminated array of UTF-8 bytes, or a byte array containing a single null byte if the specified index is out of range or there is no value set for it. It is NOT permitted to mutate the returned array.

setString

public final RowValue setString(int typedIndex,
                                java.lang.String value)
Set the n'th string field.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
value -
Returns:
This RowValue instance, to facilitate method chaining.

setStringBytes

public final 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).

Parameters:
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.
Returns:
This RowValue instance, to facilitate method chaining.

setString

@Deprecated
public final void setString(int typedIndex,
                                       int maxSizeHint,
                                       java.lang.String v)
Deprecated. 

This deprecated method overload will be removed in a future release, please use the alternative overload instead.


setString

@Deprecated
public final void setString(int typedIndex,
                                       int maxSizeHint,
                                       byte[] utf8ByteString)
Deprecated. 

This deprecated method overload will be removed in a future release, please use the alternative overload instead.


getInteger

public final long getInteger(int typedIndex)
Get the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
Returns:
The field value, or the default value 0 if the specified index is out of range or there is no value set for it.

setInteger

public final RowValue setInteger(int typedIndex,
                                 long value)
Set the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
value -
Returns:
This RowValue instance, to facilitate method chaining.

setInteger

@Deprecated
public final void setInteger(int typedIndex,
                                        int maxSizeHint,
                                        long v)
Deprecated. 

This deprecated method overload will be removed in a future release, please use the alternative overload instead.


getFloat

public final double getFloat(int typedIndex)
Get the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
Returns:
The field value, or the default value 0.0 if the specified index is out of range or there is no value set for it.

setFloat

public final RowValue setFloat(int typedIndex,
                               double value)
Set the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
value -
Returns:
This RowValue instance, to facilitate method chaining.

setFloat

@Deprecated
public final void setFloat(int typedIndex,
                                      int maxSizeHint,
                                      double v)
Deprecated. 

This deprecated method overload will be removed in a future release, please use the alternative overload instead.


getBoolean

public final boolean getBoolean(int typedIndex)
Get the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
Returns:
The field value, or the default value false if the specified index is out of range or there is no value set for it.

setBoolean

public final RowValue setBoolean(int typedIndex,
                                 boolean value)
Set the n'th field of this type.

Parameters:
typedIndex - The type-specific index n, where n is the n'th field of this particular type.
value -
Returns:
This RowValue instance, to facilitate method chaining.

setBoolean

@Deprecated
public final void setBoolean(int typedIndex,
                                        int maxSizeHint,
                                        boolean v)
Deprecated. 

This deprecated method overload will be removed in a future release, please use the alternative overload instead.



Submit a bug or feature
Copyright (c) 2013-2014 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.