com.thinkaurelius.titan.graphdb.database.serialize.attribute

## Class StringSerializer

- java.lang.Object
- - com.thinkaurelius.titan.graphdb.database.serialize.attribute.StringSerializer

- All Implemented Interfaces:
    AttributeHandler<String>, AttributeSerializer<String>, OrderPreservingSerializer<String>, SupportsNullSerializer

      public class StringSerializer
      extends Object
      implements OrderPreservingSerializer<String>, SupportsNullSerializer

  Serializes Strings by trying to find the most efficient serialization format: 1) ASCII encoding (one byte per char) 2) Full UTF encoding (for non-ASCII strings) 3) Using compression algorithms for long strings
  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `LONG_COMPRESSION_THRESHOLD`
    `static int` | `MAX_LENGTH`
    `static int` | `TEXT_COMRPESSION_THRESHOLD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StringSerializer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `convert(Object value)` Converts the given (not-null) value to the expected datatype V.
    `String` | `read(ScanBuffer buffer)` Reads an attribute from the given ReadBuffer.
    `String` | `readByteOrder(ScanBuffer buffer)` Reads an attribute from the given ReadBuffer assuming it was written in byte order.
    `void` | `verifyAttribute(String value)` Verifies the given (not-null) attribute value is valid.
    `void` | `write(WriteBuffer buffer, String attribute)` Writes the attribute value to the given WriteBuffer.
    `void` | `writeByteOrder(WriteBuffer buffer, String attribute)` Writes the attribute value to the given WriteBuffer such that the byte order of the result is equal to the natural order of the attribute.

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

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

- - ### Field Detail

    - #### MAX_LENGTH

          public static final int MAX_LENGTH

      See Also:
        Constant Field Values

    - #### LONG_COMPRESSION_THRESHOLD

          public static final int LONG_COMPRESSION_THRESHOLD

      See Also:
        Constant Field Values

    - #### TEXT_COMRPESSION_THRESHOLD

          public static final int TEXT_COMRPESSION_THRESHOLD

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### StringSerializer

          public StringSerializer()

  - ### Method Detail

    - #### readByteOrder

          public String readByteOrder(ScanBuffer buffer)

      Description copied from interface: `OrderPreservingSerializer`
      Reads an attribute from the given ReadBuffer assuming it was written in byte order.

      It is expected that this read operation adjusts the position in the ReadBuffer to after the attribute value.
      Specified by:
        `readByteOrder` in interface `OrderPreservingSerializer<String>`
      Parameters:
        `buffer` - ReadBuffer to read attribute from
      Returns:
        Read attribute

    - #### writeByteOrder

          public void writeByteOrder(WriteBuffer buffer,
                            String attribute)

      Description copied from interface: `OrderPreservingSerializer`
      Writes the attribute value to the given WriteBuffer such that the byte order of the result is equal to the natural order of the attribute.

      It is expected that this write operation adjusts the position in the WriteBuffer to after the attribute value.
      Specified by:
        `writeByteOrder` in interface `OrderPreservingSerializer<String>`
      Parameters:
        `buffer` - WriteBuffer to write attribute to
        `attribute` - Attribute to write to WriteBuffer

    - #### verifyAttribute

          public void verifyAttribute(String value)

      Description copied from interface: `AttributeHandler`
      Verifies the given (not-null) attribute value is valid. Throws an `IllegalArgumentException` if the value is invalid, otherwise simply returns.
      Specified by:
        `verifyAttribute` in interface `AttributeHandler<String>`
      Parameters:
        `value` - to verify

    - #### convert

          public String convert(Object value)

      Description copied from interface: `AttributeHandler`
      Converts the given (not-null) value to the expected datatype V. The given object will NOT be of type V. Throws an `IllegalArgumentException` if it cannot be converted.
      Specified by:
        `convert` in interface `AttributeHandler<String>`
      Parameters:
        `value` - to convert
      Returns:
        converted to expected datatype

    - #### read

          public String read(ScanBuffer buffer)

      Description copied from interface: `AttributeSerializer`
      Reads an attribute from the given ReadBuffer.

      It is expected that this read operation adjusts the position in the ReadBuffer to after the attribute value.
      Specified by:
        `read` in interface `AttributeSerializer<String>`
      Parameters:
        `buffer` - ReadBuffer to read attribute from
      Returns:
        Read attribute

    - #### write

          public void write(WriteBuffer buffer,
                   String attribute)

      Description copied from interface: `AttributeSerializer`
      Writes the attribute value to the given WriteBuffer.

      It is expected that this write operation adjusts the position in the WriteBuffer to after the attribute value.
      Specified by:
        `write` in interface `AttributeSerializer<String>`
      Parameters:
        `buffer` - WriteBuffer to write attribute to
        `attribute` - Attribute to write to WriteBuffer

Copyright © 2012–2014. All rights reserved.