TupleBinding (Oracle - Berkeley DB Java API)
Date: 2020-06-01

Package com.sleepycat.bind.tuple

## Class TupleBinding<E>

- java.lang.Object
- - com.sleepycat.bind.tuple.TupleBase<E>
  - - com.sleepycat.bind.tuple.TupleBinding<E>

- Type Parameters:
    `E` - is the class representing the key or data.
  All Implemented Interfaces:
    `EntryBinding<E>`
  Direct Known Subclasses:
    `BigDecimalBinding`, `BigIntegerBinding`, `BooleanBinding`, `ByteBinding`, `CharacterBinding`, `DoubleBinding`, `FloatBinding`, `IntegerBinding`, `LongBinding`, `PackedIntegerBinding`, `PackedLongBinding`, `ShortBinding`, `SortedBigDecimalBinding`, `SortedDoubleBinding`, `SortedFloatBinding`, `SortedPackedIntegerBinding`, `SortedPackedLongBinding`, `StringBinding`, `TupleMarshalledBinding`

      public abstract class TupleBinding<E>
      extends TupleBase<E>
      implements EntryBinding<E>

  An abstract `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.

  - `entryToObject(TupleInput)`
  - `objectToEntry(Object,TupleOutput)`
  See Also:
    Tuple Formats

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `TupleBinding()` | Creates a tuple binding.

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `abstract E` | `entryToObject​(TupleInput input)` | Constructs a key or data object from a `TupleInput` entry.
    `E` | `entryToObject​(DatabaseEntry entry)` | Converts a entry buffer into an Object.
    `static <T> TupleBinding<T>` | `getPrimitiveBinding​(java.lang.Class<T> cls)` | Creates a tuple binding for a primitive Java class.
    `abstract void` | `objectToEntry​(E object, TupleOutput output)` | Converts a key or data object to a tuple entry.
    `void` | `objectToEntry​(E object, DatabaseEntry entry)` | Converts an Object into a entry buffer.

    - ### Methods inherited from class com.sleepycat.bind.tuple.TupleBase

      `entryToInput, getTupleBufferSize, getTupleOutput, inputToEntry, newOutput, newOutput, outputToEntry, setTupleBufferSize`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TupleBinding

          public TupleBinding()

      Creates a tuple binding.

  - ### Method Detail

    - #### entryToObject

          public E entryToObject​(DatabaseEntry entry)

      Description copied from interface: `EntryBinding`
      Converts a entry buffer into an Object.
      Specified by:
        `entryToObject` in interface `EntryBinding<E>`
      Parameters:
        `entry` - is the source entry buffer.
      Returns:
        the resulting Object.

    - #### objectToEntry

          public void objectToEntry​(E object,
                                    DatabaseEntry entry)

      Description copied from interface: `EntryBinding`
      Converts an Object into a entry buffer.
      Specified by:
        `objectToEntry` in interface `EntryBinding<E>`
      Parameters:
        `object` - is the source Object.
        `entry` - is the destination entry buffer.

    - #### entryToObject

          public abstract E entryToObject​(TupleInput input)

      Constructs a key or data object from a `TupleInput` entry.
      Parameters:
        `input` - is the tuple key or data entry.
      Returns:
        the key or data object constructed from the entry.

    - #### objectToEntry

          public abstract void objectToEntry​(E object,
                                             TupleOutput output)

      Converts a key or data object to a tuple entry.
      Parameters:
        `object` - is the key or data object.
        `output` - is the tuple entry to which the key or data should be written.

    - #### getPrimitiveBinding

          public static <T> TupleBinding<T> getPrimitiveBinding​(java.lang.Class<T> cls)

      Creates a tuple binding for a primitive Java class. The following Java classes are supported.
      - `String`
      - `Character`
      - `Boolean`
      - `Byte`
      - `Short`
      - `Integer`
      - `Long`
      - `Float`
      - `Double`

      Note: `getPrimitiveBinding(java.lang.Class<T>)` returns bindings that do not sort negative floating point numbers correctly by default. See `SortedFloatBinding` and `SortedDoubleBinding` for details.

      Type Parameters:
        `T` - the primitive Java class.
      Parameters:
        `cls` - 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.

Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved.