Package uk.co.real_logic.sbe
Class PrimitiveValue
java.lang.Object
uk.co.real_logic.sbe.PrimitiveValue
Class used to encapsulate values for primitives. Used for nullValue, minValue, maxValue, and constants.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresentation type used for the stored value. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BigIntegerMaximum value representation for an unsigned 64-bit type.static final BigIntegerNull value representation for an unsigned 64-bit type.static final longMaximum value representation for a char type.static final doubleMaximum value representation for a double precision 64-bit floating point type.static final floatMaximum value representation for a single precision 32-bit floating point type.static final longMaximum value representation for a signed 16-bit type.static final longMaximum value representation for a signed 32-bit type.static final longMaximum value representation for a signed 64-bit type.static final longMaximum value representation for a signed 8-bit type.static final longMaximum value representation for an unsigned 16-bit type.static final longMaximum value representation for an unsigned 32-bit type.static final longMaximum value representation for an unsigned 64-bit type.static final longMaximum value representation for an unsigned 8-bit type.static final longMinimum value representation for a char type.static final doubleMinimum value representation for a double precision 64-bit floating point type.static final floatMaximum value representation for a single precision 32-bit floating point type.static final longMinimum value representation for a signed 16-bit type.static final longMinimum value representation for a signed 32-bit type.static final longMinimum value representation for a signed 64-bit type.static final longMinimum value representation for a signed 8-bit type.static final longMinimum value representation for an unsigned 16-bit type.static final longMinimum value representation for an unsigned 32-bit type.static final longMinimum value representation for an unsigned 64-bit type.static final longMinimum value representation for an unsigned 8-bit type.static final longNull value representation for a char type.static final doubleNull value representation for a double precision 64-bit floating point type.static final floatNull value representation for a single precision 32-bit floating point type.static final longNull value representation for a signed 16-bit type.static final longNull value representation for a signed 32-bit type.static final longNull value representation for a signed 64-bit type.static final longNull value representation for a signed 8-bit type.static final longNull value representation for an unsigned 16-bit type.static final longNull value representation for an unsigned 32-bit type.static final longNull value representation for an unsigned 64-bit type.static final longNull value representation for an unsigned 8-bit type. -
Constructor Summary
ConstructorsConstructorDescriptionPrimitiveValue(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 TypeMethodDescriptionbyte[]Return byte array value for this PrimitiveValue.byte[]byteArrayValue(PrimitiveType type) Return byte array value for this PrimitiveValue given a particular typeThe character encoding of the byte array representation.doubleReturn double value for this PrimitiveValue.booleanDetermine if two values are equivalent.inthashCode()Return hashCode for value.longReturn long value for this PrimitiveValue.static PrimitiveValueParse constant value string and set representation based on type, length, and characterEncodingstatic PrimitiveValueparse(String value, PrimitiveType primitiveType) Parse constant value string and set representation based on typestatic PrimitiveValueparse(String value, PrimitiveType primitiveType, String characterEncoding) Parse constant value string and set representation based on typeGet thePrimitiveValue.Representationof the value.intsize()Return encodedLength for this PrimitiveValue for serialization purposes.toString()Return String value representation of this object.
-
Field Details
-
MIN_VALUE_CHAR
public static final long MIN_VALUE_CHARMinimum value representation for a char type.- See Also:
-
MAX_VALUE_CHAR
public static final long MAX_VALUE_CHARMaximum value representation for a char type.- See Also:
-
NULL_VALUE_CHAR
public static final long NULL_VALUE_CHARNull value representation for a char type.- See Also:
-
MIN_VALUE_INT8
public static final long MIN_VALUE_INT8Minimum value representation for a signed 8-bit type.- See Also:
-
MAX_VALUE_INT8
public static final long MAX_VALUE_INT8Maximum value representation for a signed 8-bit type.- See Also:
-
NULL_VALUE_INT8
public static final long NULL_VALUE_INT8Null value representation for a signed 8-bit type.- See Also:
-
MIN_VALUE_UINT8
public static final long MIN_VALUE_UINT8Minimum value representation for an unsigned 8-bit type.- See Also:
-
MAX_VALUE_UINT8
public static final long MAX_VALUE_UINT8Maximum value representation for an unsigned 8-bit type.- See Also:
-
NULL_VALUE_UINT8
public static final long NULL_VALUE_UINT8Null value representation for an unsigned 8-bit type.- See Also:
-
MIN_VALUE_INT16
public static final long MIN_VALUE_INT16Minimum value representation for a signed 16-bit type.- See Also:
-
MAX_VALUE_INT16
public static final long MAX_VALUE_INT16Maximum value representation for a signed 16-bit type.- See Also:
-
NULL_VALUE_INT16
public static final long NULL_VALUE_INT16Null value representation for a signed 16-bit type.- See Also:
-
MIN_VALUE_UINT16
public static final long MIN_VALUE_UINT16Minimum value representation for an unsigned 16-bit type.- See Also:
-
MAX_VALUE_UINT16
public static final long MAX_VALUE_UINT16Maximum value representation for an unsigned 16-bit type.- See Also:
-
NULL_VALUE_UINT16
public static final long NULL_VALUE_UINT16Null value representation for an unsigned 16-bit type.- See Also:
-
MIN_VALUE_INT32
public static final long MIN_VALUE_INT32Minimum value representation for a signed 32-bit type.- See Also:
-
MAX_VALUE_INT32
public static final long MAX_VALUE_INT32Maximum value representation for a signed 32-bit type.- See Also:
-
NULL_VALUE_INT32
public static final long NULL_VALUE_INT32Null value representation for a signed 32-bit type.- See Also:
-
MIN_VALUE_UINT32
public static final long MIN_VALUE_UINT32Minimum value representation for an unsigned 32-bit type.- See Also:
-
MAX_VALUE_UINT32
public static final long MAX_VALUE_UINT32Maximum value representation for an unsigned 32-bit type.- See Also:
-
NULL_VALUE_UINT32
public static final long NULL_VALUE_UINT32Null value representation for an unsigned 32-bit type.- See Also:
-
MIN_VALUE_INT64
public static final long MIN_VALUE_INT64Minimum value representation for a signed 64-bit type.- See Also:
-
MAX_VALUE_INT64
public static final long MAX_VALUE_INT64Maximum value representation for a signed 64-bit type.- See Also:
-
NULL_VALUE_INT64
public static final long NULL_VALUE_INT64Null value representation for a signed 64-bit type.- See Also:
-
MIN_VALUE_UINT64
public static final long MIN_VALUE_UINT64Minimum value representation for an unsigned 64-bit type.- See Also:
-
BI_MAX_VALUE_UINT64
Maximum value representation for an unsigned 64-bit type. -
MAX_VALUE_UINT64
public static final long MAX_VALUE_UINT64Maximum value representation for an unsigned 64-bit type. -
BI_NULL_VALUE_UINT64
Null value representation for an unsigned 64-bit type. -
NULL_VALUE_UINT64
public static final long NULL_VALUE_UINT64Null value representation for an unsigned 64-bit type. -
MIN_VALUE_FLOAT
public static final float MIN_VALUE_FLOATMaximum value representation for a single precision 32-bit floating point type.- See Also:
-
MAX_VALUE_FLOAT
public static final float MAX_VALUE_FLOATMaximum value representation for a single precision 32-bit floating point type.- See Also:
-
NULL_VALUE_FLOAT
public static final float NULL_VALUE_FLOATNull value representation for a single precision 32-bit floating point type.- See Also:
-
MIN_VALUE_DOUBLE
public static final double MIN_VALUE_DOUBLEMinimum value representation for a double precision 64-bit floating point type.- See Also:
-
MAX_VALUE_DOUBLE
public static final double MAX_VALUE_DOUBLEMaximum value representation for a double precision 64-bit floating point type.- See Also:
-
NULL_VALUE_DOUBLE
public static final double NULL_VALUE_DOUBLENull 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
Construct and fill in value as a long.- Parameters:
value- in long formatcharacterEncoding- 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
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
Get thePrimitiveValue.Representationof the value.- Returns:
- the
PrimitiveValue.Representationof the value.
-
parse
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
PrimitiveValuefor 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
PrimitiveValuefor the value. - Throws:
IllegalArgumentException- if parsing malformed type
-
parse
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
PrimitiveValuefor 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
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
The character encoding of the byte array representation.- Returns:
- the character encoding of te byte array representation.
-
toString
Return String value representation of this object. -
equals
Determine if two values are equivalent. -
hashCode
public int hashCode()Return hashCode for value. This is the underlying representations hashCode for the value.
-