com.sleepycat.bind.tuple
public abstract class TupleBinding extends TupleBase implements EntryBinding
EntryBinding
that treats a key or data entry as a
tuple; it includes predefined bindings for Java primitive types.
This class takes care of converting the entries to/from TupleInput and TupleOutput objects. Its two abstract methods must be implemented by a concrete subclass to convert between tuples and key or data objects.
For key or data entries which are Java primitive classes (String, Integer, etc) TupleBinding may be used to return a builtin tuple binding. A custom tuple binding for these types is not needed. Note: TupleBinding returns bindings that do not sort negative floating point numbers correctly by default. See SortedFloatBinding and SortedDoubleBinding for details.
When a tuple binding is used as a key binding, it produces key values with a reasonable default sort order. For more information on the default sort order, see TupleOutput.
Constructor Summary | |
---|---|
TupleBinding()
Creates a tuple binding. |
Method Summary | |
---|---|
Object | entryToObject(DatabaseEntry entry) |
abstract Object | entryToObject(TupleInput input)
Constructs a key or data object from a TupleInput entry.
|
static TupleBinding | getPrimitiveBinding(Class cls)
Creates a tuple binding for a primitive Java class. |
void | objectToEntry(Object object, DatabaseEntry entry) |
abstract void | objectToEntry(Object object, TupleOutput output)
Converts a key or data object to a tuple entry.
|
Parameters: input is the tuple key or data entry.
Returns: the key or data object constructed from the entry.
String
Character
Boolean
Byte
Short
Integer
Long
Float
Double
Note: TupleBinding returns bindings that do not sort negative floating point numbers correctly by default. See SortedFloatBinding and SortedDoubleBinding for details.
Parameters: cls is the primitive Java class.
Returns: a new binding for the primitive class or null if the cls parameter is not one of the supported classes.
Parameters: object is the key or data object. output is the tuple entry to which the key or data should be written.