TupleBinding (Sleepycat Software, Inc. - Berkeley DB Java API)
Keywords: com.sleepycat.bind.tuple.TupleBinding class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.3.27
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sleepycat.bind.tuple
Class TupleBinding

    java.lang.Object
      com.sleepycat.bind.tuple.TupleBinding

All Implemented Interfaces:
  EntryBinding

Direct Known Subclasses:
  BooleanBinding, ByteBinding, CharacterBinding, DoubleBinding, FloatBinding, IntegerBinding, LongBinding, ShortBinding, StringBinding, TupleMarshalledBinding

public abstract class TupleBinding
extends Object
implements EntryBinding

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)`

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.

Constructor Summary
`TupleBinding()` Creates a tuple binding.

Method Summary
`static TupleInput` | `entryToInput(DatabaseEntry entry)` Utility method to create a new tuple input object for reading the data from a given buffer.
`Object` | `entryToObject(DatabaseEntry entry)` Converts a entry buffer into an Object.
`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.
`static void` | `inputToEntry(TupleInput input, DatabaseEntry entry)` Utility method to set the data in a entry buffer to the data in a tuple input object.
`static TupleOutput` | `newOutput()` Utility method for use by bindings to create a tuple output object.
`static TupleOutput` | `newOutput(byte[] buffer)` Utility method for use by bindings to create a tuple output object with a specific starting size.
`void` | `objectToEntry(Object object, DatabaseEntry entry)` Converts an Object into a entry buffer.
`abstract void` | `objectToEntry(Object object, TupleOutput output)` Converts a key or data object to a tuple entry.
`static void` | `outputToEntry(TupleOutput output, DatabaseEntry entry)` Utility method to set the data in a entry buffer to the data in a tuple output object.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TupleBinding

    public TupleBinding()

  Creates a tuple binding.

Method Detail

### entryToObject

    public Object entryToObject(DatabaseEntry entry)

  Description copied from interface: `EntryBinding`
  Converts a entry buffer into an Object.

  Specified by:
    `entryToObject` in interface `EntryBinding`
  Parameters:
    `entry` - is the source entry buffer.
  Returns:
    the resulting Object.

### objectToEntry

    public void objectToEntry(Object object,
                              DatabaseEntry entry)

  Description copied from interface: `EntryBinding`
  Converts an Object into a entry buffer.

  Specified by:
    `objectToEntry` in interface `EntryBinding`
  Parameters:
    `object` - is the source Object.
    `entry` - is the destination entry buffer.

### newOutput

    public static TupleOutput newOutput()

  Utility method for use by bindings to create a tuple output object.

  Returns:
    a new tuple output object.

### newOutput

    public static TupleOutput newOutput(byte[] buffer)

  Utility method for use by bindings to create a tuple output object with a specific starting size.

  Returns:
    a new tuple output object.

### outputToEntry

    public static void outputToEntry(TupleOutput output,
                                     DatabaseEntry entry)

  Utility method to set the data in a entry buffer to the data in a tuple output object.

  Parameters:
    `output` - is the source tuple output object.
    `entry` - is the destination entry buffer.

### inputToEntry

    public static void inputToEntry(TupleInput input,
                                    DatabaseEntry entry)

  Utility method to set the data in a entry buffer to the data in a tuple input object.

  Parameters:
    `input` - is the source tuple input object.
    `entry` - is the destination entry buffer.

### entryToInput

    public static TupleInput entryToInput(DatabaseEntry entry)

  Utility method to create a new tuple input object for reading the data from a given buffer. If an existing input is reused, it is reset before returning it.

  Parameters:
    `entry` - is the source entry buffer.
  Returns:
    the new tuple input object.

### entryToObject

    public abstract Object 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(Object 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 TupleBinding getPrimitiveBinding(Class 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`

  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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.3.27
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved.