Class PrimitiveValue

java.lang.Object
uk.co.real_logic.sbe.PrimitiveValue

public class PrimitiveValue extends Object
Class used to encapsulate values for primitives. Used for nullValue, minValue, maxValue, and constants.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Representation type used for the stored value.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BigInteger
    Maximum value representation for an unsigned 64-bit type.
    static final BigInteger
    Null value representation for an unsigned 64-bit type.
    static final long
    Maximum value representation for a char type.
    static final double
    Maximum value representation for a double precision 64-bit floating point type.
    static final float
    Maximum value representation for a single precision 32-bit floating point type.
    static final long
    Maximum value representation for a signed 16-bit type.
    static final long
    Maximum value representation for a signed 32-bit type.
    static final long
    Maximum value representation for a signed 64-bit type.
    static final long
    Maximum value representation for a signed 8-bit type.
    static final long
    Maximum value representation for an unsigned 16-bit type.
    static final long
    Maximum value representation for an unsigned 32-bit type.
    static final long
    Maximum value representation for an unsigned 64-bit type.
    static final long
    Maximum value representation for an unsigned 8-bit type.
    static final long
    Minimum value representation for a char type.
    static final double
    Minimum value representation for a double precision 64-bit floating point type.
    static final float
    Maximum value representation for a single precision 32-bit floating point type.
    static final long
    Minimum value representation for a signed 16-bit type.
    static final long
    Minimum value representation for a signed 32-bit type.
    static final long
    Minimum value representation for a signed 64-bit type.
    static final long
    Minimum value representation for a signed 8-bit type.
    static final long
    Minimum value representation for an unsigned 16-bit type.
    static final long
    Minimum value representation for an unsigned 32-bit type.
    static final long
    Minimum value representation for an unsigned 64-bit type.
    static final long
    Minimum value representation for an unsigned 8-bit type.
    static final long
    Null value representation for a char type.
    static final double
    Null value representation for a double precision 64-bit floating point type.
    static final float
    Null value representation for a single precision 32-bit floating point type.
    static final long
    Null value representation for a signed 16-bit type.
    static final long
    Null value representation for a signed 32-bit type.
    static final long
    Null value representation for a signed 64-bit type.
    static final long
    Null value representation for a signed 8-bit type.
    static final long
    Null value representation for an unsigned 16-bit type.
    static final long
    Null value representation for an unsigned 32-bit type.
    static final long
    Null value representation for an unsigned 64-bit type.
    static final long
    Null value representation for an unsigned 8-bit type.
  • Constructor Summary

    Constructors
    Constructor
    Description
    PrimitiveValue(byte[] value, String characterEncoding, int size)
    Construct and fill in value as a byte array.
    PrimitiveValue(byte value, String characterEncoding)
    Construct and fill in value as a long.
    PrimitiveValue(double value, int size)
    Construct and fill in value as a double.
    PrimitiveValue(long value, int size)
    Construct and fill in value as a long.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Return byte array value for this PrimitiveValue.
    byte[]
    Return byte array value for this PrimitiveValue given a particular type
    The character encoding of the byte array representation.
    double
    Return double value for this PrimitiveValue.
    boolean
    equals(Object value)
    Determine if two values are equivalent.
    int
    Return hashCode for value.
    long
    Return long value for this PrimitiveValue.
    parse(String value, int length, String characterEncoding)
    Parse constant value string and set representation based on type, length, and characterEncoding
    parse(String value, PrimitiveType primitiveType)
    Parse constant value string and set representation based on type
    parse(String value, PrimitiveType primitiveType, String characterEncoding)
    Parse constant value string and set representation based on type
    Get the PrimitiveValue.Representation of the value.
    int
    Return encodedLength for this PrimitiveValue for serialization purposes.
    Return String value representation of this object.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • MIN_VALUE_CHAR

      public static final long MIN_VALUE_CHAR
      Minimum value representation for a char type.
      See Also:
    • MAX_VALUE_CHAR

      public static final long MAX_VALUE_CHAR
      Maximum value representation for a char type.
      See Also:
    • NULL_VALUE_CHAR

      public static final long NULL_VALUE_CHAR
      Null value representation for a char type.
      See Also:
    • MIN_VALUE_INT8

      public static final long MIN_VALUE_INT8
      Minimum value representation for a signed 8-bit type.
      See Also:
    • MAX_VALUE_INT8

      public static final long MAX_VALUE_INT8
      Maximum value representation for a signed 8-bit type.
      See Also:
    • NULL_VALUE_INT8

      public static final long NULL_VALUE_INT8
      Null value representation for a signed 8-bit type.
      See Also:
    • MIN_VALUE_UINT8

      public static final long MIN_VALUE_UINT8
      Minimum value representation for an unsigned 8-bit type.
      See Also:
    • MAX_VALUE_UINT8

      public static final long MAX_VALUE_UINT8
      Maximum value representation for an unsigned 8-bit type.
      See Also:
    • NULL_VALUE_UINT8

      public static final long NULL_VALUE_UINT8
      Null value representation for an unsigned 8-bit type.
      See Also:
    • MIN_VALUE_INT16

      public static final long MIN_VALUE_INT16
      Minimum value representation for a signed 16-bit type.
      See Also:
    • MAX_VALUE_INT16

      public static final long MAX_VALUE_INT16
      Maximum value representation for a signed 16-bit type.
      See Also:
    • NULL_VALUE_INT16

      public static final long NULL_VALUE_INT16
      Null value representation for a signed 16-bit type.
      See Also:
    • MIN_VALUE_UINT16

      public static final long MIN_VALUE_UINT16
      Minimum value representation for an unsigned 16-bit type.
      See Also:
    • MAX_VALUE_UINT16

      public static final long MAX_VALUE_UINT16
      Maximum value representation for an unsigned 16-bit type.
      See Also:
    • NULL_VALUE_UINT16

      public static final long NULL_VALUE_UINT16
      Null value representation for an unsigned 16-bit type.
      See Also:
    • MIN_VALUE_INT32

      public static final long MIN_VALUE_INT32
      Minimum value representation for a signed 32-bit type.
      See Also:
    • MAX_VALUE_INT32

      public static final long MAX_VALUE_INT32
      Maximum value representation for a signed 32-bit type.
      See Also:
    • NULL_VALUE_INT32

      public static final long NULL_VALUE_INT32
      Null value representation for a signed 32-bit type.
      See Also:
    • MIN_VALUE_UINT32

      public static final long MIN_VALUE_UINT32
      Minimum value representation for an unsigned 32-bit type.
      See Also:
    • MAX_VALUE_UINT32

      public static final long MAX_VALUE_UINT32
      Maximum value representation for an unsigned 32-bit type.
      See Also:
    • NULL_VALUE_UINT32

      public static final long NULL_VALUE_UINT32
      Null value representation for an unsigned 32-bit type.
      See Also:
    • MIN_VALUE_INT64

      public static final long MIN_VALUE_INT64
      Minimum value representation for a signed 64-bit type.
      See Also:
    • MAX_VALUE_INT64

      public static final long MAX_VALUE_INT64
      Maximum value representation for a signed 64-bit type.
      See Also:
    • NULL_VALUE_INT64

      public static final long NULL_VALUE_INT64
      Null value representation for a signed 64-bit type.
      See Also:
    • MIN_VALUE_UINT64

      public static final long MIN_VALUE_UINT64
      Minimum value representation for an unsigned 64-bit type.
      See Also:
    • BI_MAX_VALUE_UINT64

      public static final BigInteger BI_MAX_VALUE_UINT64
      Maximum value representation for an unsigned 64-bit type.
    • MAX_VALUE_UINT64

      public static final long MAX_VALUE_UINT64
      Maximum value representation for an unsigned 64-bit type.
    • BI_NULL_VALUE_UINT64

      public static final BigInteger BI_NULL_VALUE_UINT64
      Null value representation for an unsigned 64-bit type.
    • NULL_VALUE_UINT64

      public static final long NULL_VALUE_UINT64
      Null value representation for an unsigned 64-bit type.
    • MIN_VALUE_FLOAT

      public static final float MIN_VALUE_FLOAT
      Maximum value representation for a single precision 32-bit floating point type.
      See Also:
    • MAX_VALUE_FLOAT

      public static final float MAX_VALUE_FLOAT
      Maximum value representation for a single precision 32-bit floating point type.
      See Also:
    • NULL_VALUE_FLOAT

      public static final float NULL_VALUE_FLOAT
      Null value representation for a single precision 32-bit floating point type.
      See Also:
    • MIN_VALUE_DOUBLE

      public static final double MIN_VALUE_DOUBLE
      Minimum value representation for a double precision 64-bit floating point type.
      See Also:
    • MAX_VALUE_DOUBLE

      public static final double MAX_VALUE_DOUBLE
      Maximum value representation for a double precision 64-bit floating point type.
      See Also:
    • NULL_VALUE_DOUBLE

      public static final double NULL_VALUE_DOUBLE
      Null value representation for a double precision 64-bit floating point type.
      See Also:
  • Constructor Details

    • PrimitiveValue

      public PrimitiveValue(long value, int size)
      Construct and fill in value as a long.
      Parameters:
      value - in long format.
      size - of the type in bytes.
    • PrimitiveValue

      public PrimitiveValue(byte value, String characterEncoding)
      Construct and fill in value as a long.
      Parameters:
      value - in long format
      characterEncoding - of the char type.
    • PrimitiveValue

      public PrimitiveValue(double value, int size)
      Construct and fill in value as a double.
      Parameters:
      value - in double format.
      size - of the type in bytes.
    • PrimitiveValue

      public PrimitiveValue(byte[] value, String characterEncoding, int size)
      Construct and fill in value as a byte array.
      Parameters:
      value - as a byte array.
      characterEncoding - of the characters.
      size - of string in characters.
  • Method Details

    • representation

      public PrimitiveValue.Representation representation()
      Get the PrimitiveValue.Representation of the value.
      Returns:
      the PrimitiveValue.Representation of the value.
    • parse

      public static PrimitiveValue parse(String value, PrimitiveType primitiveType)
      Parse constant value string and set representation based on type
      Parameters:
      value - expressed as a String.
      primitiveType - that this is supposed to be.
      Returns:
      a new PrimitiveValue for the value.
      Throws:
      IllegalArgumentException - if parsing malformed type
    • parse

      public static PrimitiveValue parse(String value, PrimitiveType primitiveType, String characterEncoding)
      Parse constant value string and set representation based on type
      Parameters:
      value - expressed as a String.
      primitiveType - that this is supposed to be.
      characterEncoding - of the constant value.
      Returns:
      a new PrimitiveValue for the value.
      Throws:
      IllegalArgumentException - if parsing malformed type
    • parse

      public static PrimitiveValue parse(String value, int length, String characterEncoding)
      Parse constant value string and set representation based on type, length, and characterEncoding
      Parameters:
      value - expressed as a String.
      length - of the type.
      characterEncoding - of the String.
      Returns:
      a new PrimitiveValue for the value.
      Throws:
      IllegalArgumentException - if parsing malformed type.
    • longValue

      public long longValue()
      Return long value for this PrimitiveValue.
      Returns:
      value expressed as a long.
      Throws:
      IllegalStateException - if not a long value representation.
    • doubleValue

      public double doubleValue()
      Return double value for this PrimitiveValue.
      Returns:
      value expressed as a double.
      Throws:
      IllegalStateException - if not a double value representation.
    • byteArrayValue

      public byte[] byteArrayValue()
      Return byte array value for this PrimitiveValue.
      Returns:
      value expressed as a byte array.
      Throws:
      IllegalStateException - if not a byte array value representation.
    • byteArrayValue

      public byte[] byteArrayValue(PrimitiveType type)
      Return byte array value for this PrimitiveValue given a particular type
      Parameters:
      type - of this value.
      Returns:
      value expressed as a byte array.
      Throws:
      IllegalStateException - if not a byte array value representation.
    • size

      public int size()
      Return encodedLength for this PrimitiveValue for serialization purposes.
      Returns:
      encodedLength for serialization.
    • characterEncoding

      public String characterEncoding()
      The character encoding of the byte array representation.
      Returns:
      the character encoding of te byte array representation.
    • toString

      public String toString()
      Return String value representation of this object.
      Overrides:
      toString in class Object
      Returns:
      String representing object value.
    • equals

      public boolean equals(Object value)
      Determine if two values are equivalent.
      Overrides:
      equals in class Object
      Parameters:
      value - to compare this value with.
      Returns:
      equivalence of values.
    • hashCode

      public int hashCode()
      Return hashCode for value. This is the underlying representations hashCode for the value.
      Overrides:
      hashCode in class Object
      Returns:
      int value of the hashCode.