Class AbstractImmutableRawValue

    • Field Detail

      • data

        protected final byte[] data
    • Constructor Detail

      • AbstractImmutableRawValue

        public AbstractImmutableRawValue​(byte[] data)
      • AbstractImmutableRawValue

        public AbstractImmutableRawValue​(java.lang.String string)
    • Method Detail

      • asRawValue

        public ImmutableRawValue asRawValue()
        Description copied from interface: Value
        Returns the value as RawValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((RawValue) thisValue) to check type of a value because type of a mutable value is variable.
        Specified by:
        asRawValue in interface ImmutableValue
        Specified by:
        asRawValue in interface Value
      • asByteArray

        public byte[] asByteArray()
        Description copied from interface: RawValue
        Returns the value as byte[]. This method copies the byte array.
        Specified by:
        asByteArray in interface RawValue
      • asByteBuffer

        public java.nio.ByteBuffer asByteBuffer()
        Description copied from interface: RawValue
        Returns the value as ByteBuffer. Returned ByteBuffer is read-only. See also ByteBuffer.asReadOnlyBuffer(). This method doesn't copy the byte array as much as possible.
        Specified by:
        asByteBuffer in interface RawValue
      • asString

        public java.lang.String asString()
        Description copied from interface: RawValue
        Returns the value as String. This method throws an exception if the value includes invalid UTF-8 byte sequence.
        Specified by:
        asString in interface RawValue
      • toJson

        public java.lang.String toJson()
        Description copied from interface: Value
        Returns json representation of this Value.

        Following behavior is not configurable at this release and they might be changed at future releases:

        • if a key of MapValue is not string, the key is converted to a string using toString method.
        • NaN and Infinity of DoubleValue are converted to null.
        • ExtensionValue is converted to a 2-element array where first element is a number and second element is the data encoded in hex.
        • BinaryValue is converted to a string using UTF-8 encoding. Invalid byte sequence is replaced with U+FFFD replacement character.
        • Invalid UTF-8 byte sequences in StringValue is replaced with U+FFFD replacement character
          Specified by:
          toJson in interface Value
        • toString

          public java.lang.String toString()
          Description copied from interface: RawValue
          Returns the value as String. This method replaces an invalid UTF-8 byte sequence with U+FFFD replacement character.
          Specified by:
          toString in interface RawValue
          Overrides:
          toString in class java.lang.Object
        • isNilValue

          public boolean isNilValue()
          Description copied from interface: Value
          Returns true if type of this value is Nil. If this method returns true, asNilValue never throws exceptions. Note that you can't use instanceof or cast ((NilValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isNilValue in interface Value
        • isBooleanValue

          public boolean isBooleanValue()
          Description copied from interface: Value
          Returns true if type of this value is Boolean. If this method returns true, asBooleanValue never throws exceptions. Note that you can't use instanceof or cast ((BooleanValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isBooleanValue in interface Value
        • isNumberValue

          public boolean isNumberValue()
          Description copied from interface: Value
          Returns true if type of this value is Integer or Float. If this method returns true, asNumberValue never throws exceptions. Note that you can't use instanceof or cast ((NumberValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isNumberValue in interface Value
        • isIntegerValue

          public boolean isIntegerValue()
          Description copied from interface: Value
          Returns true if type of this value is Integer. If this method returns true, asIntegerValue never throws exceptions. Note that you can't use instanceof or cast ((IntegerValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isIntegerValue in interface Value
        • isFloatValue

          public boolean isFloatValue()
          Description copied from interface: Value
          Returns true if type of this value is Float. If this method returns true, asFloatValue never throws exceptions. Note that you can't use instanceof or cast ((FloatValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isFloatValue in interface Value
        • isRawValue

          public boolean isRawValue()
          Description copied from interface: Value
          Returns true if type of this value is String or Binary. If this method returns true, asRawValue never throws exceptions. Note that you can't use instanceof or cast ((RawValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isRawValue in interface Value
        • isBinaryValue

          public boolean isBinaryValue()
          Description copied from interface: Value
          Returns true if type of this value is Binary. If this method returns true, asBinaryValue never throws exceptions. Note that you can't use instanceof or cast ((BinaryValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isBinaryValue in interface Value
        • isStringValue

          public boolean isStringValue()
          Description copied from interface: Value
          Returns true if type of this value is String. If this method returns true, asStringValue never throws exceptions. Note that you can't use instanceof or cast ((StringValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isStringValue in interface Value
        • isArrayValue

          public boolean isArrayValue()
          Description copied from interface: Value
          Returns true if type of this value is Array. If this method returns true, asArrayValue never throws exceptions. Note that you can't use instanceof or cast ((ArrayValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isArrayValue in interface Value
        • isMapValue

          public boolean isMapValue()
          Description copied from interface: Value
          Returns true if type of this value is Map. If this method returns true, asMapValue never throws exceptions. Note that you can't use instanceof or cast ((MapValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isMapValue in interface Value
        • isExtensionValue

          public boolean isExtensionValue()
          Description copied from interface: Value
          Returns true if type of this an Extension. If this method returns true, asExtensionValue never throws exceptions. Note that you can't use instanceof or cast ((ExtensionValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          isExtensionValue in interface Value
        • asNilValue

          public ImmutableNilValue asNilValue()
          Description copied from interface: Value
          Returns the value as NilValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((NilValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asNilValue in interface ImmutableValue
          Specified by:
          asNilValue in interface Value
        • asBooleanValue

          public ImmutableBooleanValue asBooleanValue()
          Description copied from interface: Value
          Returns the value as BooleanValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((BooleanValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asBooleanValue in interface ImmutableValue
          Specified by:
          asBooleanValue in interface Value
        • asNumberValue

          public ImmutableNumberValue asNumberValue()
          Description copied from interface: Value
          Returns the value as NumberValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((NumberValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asNumberValue in interface Value
        • asIntegerValue

          public ImmutableIntegerValue asIntegerValue()
          Description copied from interface: Value
          Returns the value as IntegerValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((IntegerValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asIntegerValue in interface ImmutableValue
          Specified by:
          asIntegerValue in interface Value
        • asFloatValue

          public ImmutableFloatValue asFloatValue()
          Description copied from interface: Value
          Returns the value as FloatValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((FloatValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asFloatValue in interface ImmutableValue
          Specified by:
          asFloatValue in interface Value
        • asBinaryValue

          public ImmutableBinaryValue asBinaryValue()
          Description copied from interface: Value
          Returns the value as BinaryValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((BinaryValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asBinaryValue in interface ImmutableValue
          Specified by:
          asBinaryValue in interface Value
        • asStringValue

          public ImmutableStringValue asStringValue()
          Description copied from interface: Value
          Returns the value as StringValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((StringValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asStringValue in interface ImmutableValue
          Specified by:
          asStringValue in interface Value
        • asArrayValue

          public ImmutableArrayValue asArrayValue()
          Description copied from interface: Value
          Returns the value as ArrayValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((ArrayValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asArrayValue in interface ImmutableValue
          Specified by:
          asArrayValue in interface Value
        • asMapValue

          public ImmutableMapValue asMapValue()
          Description copied from interface: Value
          Returns the value as MapValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((MapValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asMapValue in interface ImmutableValue
          Specified by:
          asMapValue in interface Value
        • asExtensionValue

          public ImmutableExtensionValue asExtensionValue()
          Description copied from interface: Value
          Returns the value as ExtensionValue. Otherwise throws MessageTypeCastException. Note that you can't use instanceof or cast ((ExtensionValue) thisValue) to check type of a value because type of a mutable value is variable.
          Specified by:
          asExtensionValue in interface Value