com.apama.correlator.memstore
Class RowValueHelper

java.lang.Object
  extended by com.apama.correlator.memstore.RowValueHelper

public class RowValueHelper
extends java.lang.Object

Helper class for more conveniently and efficiently dealing with RowValue objects for a given table schema.

RowValueHelper is an immutable (and therefore thread-safe) object, which caches computed information about the schema during construction, so typical usage is to re-use a single instance of the helper as needed for all RowValue instances that have the same schema.

See RowValue Javadoc for example usage.


Constructor Summary
RowValueHelper(java.lang.String... schemaTypes)
          Create a new RowValueHelper based on the specified schema type information.
 
Method Summary
 RowValue createRowValue()
          Create a new RowValue instance, with its data structured pre-allocated for the field types of this schema.
 java.lang.Iterable<java.lang.Object> fieldValues(RowValue rv)
          Use the schema to iterate over each field in the specified row value, returning a Java Object of the correct type for each field value.
 int getTypedIndex(int fieldIndex)
          Use the schema types to get the typedIndex (suitable for a RowValue.set/get call) from a fieldIndex.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RowValueHelper

public RowValueHelper(java.lang.String... schemaTypes)
Create a new RowValueHelper based on the specified schema type information.

Do not create a new RowValueHelper for every RowValue, instead it is more efficient to reuse a single helper for many RowValue objects.

Parameters:
schemaTypes - A params array indicating the type and order of fields in this table's schema.
Method Detail

createRowValue

public RowValue createRowValue()
Create a new RowValue instance, with its data structured pre-allocated for the field types of this schema.

Returns:
A new RowValue instance.

getTypedIndex

public int getTypedIndex(int fieldIndex)
Use the schema types to get the typedIndex (suitable for a RowValue.set/get call) from a fieldIndex.

The correctness of this method is dependent on valid schema information being supplied - this method will return an out of range index if the schema and RowValue do not match, or if an invalid fieldIndex is specified (but it will not throw an exception).

Parameters:
fieldIndex - The field index, i.e. n where n is the nth field in the row.
Returns:
The typed index for the type of this field, i.e. n where n is the nth field of the type (in the row).

fieldValues

public java.lang.Iterable<java.lang.Object> fieldValues(RowValue rv)
Use the schema to iterate over each field in the specified row value, returning a Java Object of the correct type for each field value.

Parameters:
rv - The RowValue
Returns:
An iterable that can be used as the target of a for-each loop.


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.