org.apache.directory.mavibot.btree.serializer

## Interface ElementSerializer<T>

- Type Parameters:
    `T` - The type for the element to serialize and compare
  All Known Implementing Classes:
    AbstractElementSerializer, BooleanSerializer, ByteArraySerializer, ByteSerializer, CharArraySerializer, CharSerializer, IntSerializer, LongArraySerializer, LongSerializer, ShortSerializer, StringSerializer

      public interface ElementSerializer<T>

  This interface is used by implementations of serializer, deserializer and comparator.
  Author:
    Apache Directory Project

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(T type1, T type2)` Returns the comparison of two types.
    `T` | `deserialize(BufferHandler bufferHandler)` Deserialize an element from a BufferHandler
    `T` | `deserialize(ByteBuffer buffer)` Deserialize an element from a ByteBuffer
    `T` | `fromBytes(byte[] buffer)` Deserialize an element from a byte[]
    `T` | `fromBytes(byte[] buffer, int pos)` Deserialize an element from a byte[]
    `Comparator<T>` | `getComparator()`
    `Class<?>` | `getType()`
    `byte[]` | `serialize(T key)` Produce the byte[] representation of the element

- - ### Method Detail

    - #### serialize

          byte[] serialize(T key)

      Produce the byte[] representation of the element
      Parameters:
        `key` - The element to serialize
      Returns:
        The byte[] containing the serialized element

    - #### deserialize

          T deserialize(BufferHandler bufferHandler)
                        throws IOException

      Deserialize an element from a BufferHandler
      Parameters:
        `bufferHandler` - The incoming bufferHandler
      Returns:
        The deserialized element
      Throws:
        `IOException` - If the deserialization failed

    - #### deserialize

          T deserialize(ByteBuffer buffer)
                        throws IOException

      Deserialize an element from a ByteBuffer
      Parameters:
        `buffer` - The incoming ByteBuffer
      Returns:
        The deserialized element
      Throws:
        `IOException` - If the deserialization failed

    - #### fromBytes

          T fromBytes(byte[] buffer)
                      throws IOException

      Deserialize an element from a byte[]
      Parameters:
        `buffer` - The incoming byte[]
      Returns:
        The deserialized element
      Throws:
        `IOException` - If the deserialization failed

    - #### fromBytes

          T fromBytes(byte[] buffer,
                    int pos)
                      throws IOException

      Deserialize an element from a byte[]
      Parameters:
        `buffer` - The incoming byte[]
      Returns:
        The deserialized element
      Throws:
        `IOException` - If the deserialization failed

    - #### compare

          int compare(T type1,
                    T type2)

      Returns the comparison of two types.
      - If type1 < type2, return -1
      - If type1 > type2, return 1
      - If type1 == type2, return 0
      Parameters:
        `type1` - The first type to compare
        `type2` - The second type to compare
      Returns:
        The comparison result

    - #### getComparator

          Comparator<T> getComparator()

      Returns:
        the comparator for the used type

    - #### getType

          Class<?> getType()

      Returns:
        the type being serialized

Copyright © 2012–2015 Apache Mavibot Project Parent. All rights reserved.