ErlangValueFastString
Date: 2016-02-29

de.zib.scalaris.examples

## Class ErlangValueFastString

- java.lang.Object
- - de.zib.scalaris.ErlangValue
  - - de.zib.scalaris.examples.ErlangValueFastString

- All Implemented Interfaces:
    Comparable<ErlangValue>

      public class ErlangValueFastString
      extends ErlangValue

  Implements a faster `String` storage mechanism if only Java access to scalaris is used.

  Uses `OtpErlangBinary` objects that store the array of bytes a `String` consists of and writes this binary to scalaris wrapped into a `OtpErlangTuple`. Trying to read strings will convert a returned `OtpErlangBinary` to a `String` or return the value of a `OtpErlangString` result.

  Run a benchmark of the different String implementations with `java -cp scalaris-examples.jar de.zib.scalaris.examples.FastStringBenchmark`

  Since:
    2.9
  Version:
    2.9
  Author:
    Nico Kruber, kruber@zib.de

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class de.zib.scalaris.ErlangValue

      `ErlangValue.ListElementConverter<T>, ErlangValue.StringListElementConverter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ErlangValueFastString(ErlangValue value)` Creates an object with the given (erlang) value.
    `ErlangValueFastString(OtpErlangObject otpValue)` Creates an object with the given (erlang) value.
    `ErlangValueFastString(String value)` Creates an object with the given (Java) value.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `stringValue()` Converts the stored erlang value created by this object to a Java `String`.

    - ### Methods inherited from class de.zib.scalaris.ErlangValue

      `bigIntValue, binaryListValue, binaryValue, boolValue, compareTo, convertToErlang, doubleListValue, doubleValue, equals, hashCode, intValue, jsonListValue, jsonValue, jsonValue, listCollectionValue, listCollectionValue, listValue, listValue, longListValue, longValue, otpObjectToOtpList, stringListValue, toString, value`

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

      `getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ErlangValueFastString

          public ErlangValueFastString(String value)

      Creates an object with the given (Java) value.
      Parameters:
        `value` - the value to use

    - #### ErlangValueFastString

          public ErlangValueFastString(OtpErlangObject otpValue)

      Creates an object with the given (erlang) value.
      Parameters:
        `otpValue` - the value to use

    - #### ErlangValueFastString

          public ErlangValueFastString(ErlangValue value)

      Creates an object with the given (erlang) value. Provided for convenience.
      Parameters:
        `value` - the value to use
      See Also:
        `ErlangValue`

  - ### Method Detail

    - #### stringValue

          public String stringValue()

      Converts the stored erlang value created by this object to a Java `String`.
      Overrides:
        `stringValue` in class `ErlangValue`
      Returns:
        the converted value
      Throws:
        `ClassCastException` - if the conversion fails