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) getPrimitiveBinding(java.lang.Class) may be used to return a builtin
tuple binding. A custom tuple binding for these types is not needed.
Note: getPrimitiveBinding(java.lang.Class) 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 and Description |
|---|
TupleBinding()
Creates a tuple binding.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
entryToObject(DatabaseEntry entry)
Converts a entry buffer into an Object.
|
abstract java.lang.Object |
entryToObject(TupleInput input)
Constructs a key or data object from a
TupleInput entry. |
static TupleBinding |
getPrimitiveBinding(java.lang.Class cls)
Creates a tuple binding for a primitive Java class.
|
void |
objectToEntry(java.lang.Object object,
DatabaseEntry entry)
Converts an Object into a entry buffer.
|
abstract void |
objectToEntry(java.lang.Object object,
TupleOutput output)
Converts a key or data object to a tuple entry.
|
entryToInput, getTupleBufferSize, getTupleOutput, inputToEntry, newOutput, newOutput, outputToEntry, setTupleBufferSizepublic java.lang.Object entryToObject(DatabaseEntry entry)
EntryBindingentryToObject in interface EntryBindingentry - is the source entry buffer.public void objectToEntry(java.lang.Object object,
DatabaseEntry entry)
EntryBindingobjectToEntry in interface EntryBindingobject - is the source Object.entry - is the destination entry buffer.public abstract java.lang.Object entryToObject(TupleInput input)
TupleInput entry.input - is the tuple key or data entry.public abstract void objectToEntry(java.lang.Object object,
TupleOutput output)
object - is the key or data object.output - is the tuple entry to which the key or data should be
written.public static TupleBinding getPrimitiveBinding(java.lang.Class cls)
StringCharacterBooleanByteShortIntegerLongFloatDoubleNote: getPrimitiveBinding(java.lang.Class) returns bindings that do
not sort negative floating point numbers correctly by default. See
SortedFloatBinding and SortedDoubleBinding for
details.
cls - is the primitive Java class.