Class Variable

  • All Implemented Interfaces:
    Value

    public class Variable
    extends java.lang.Object
    implements Value
    • Constructor Detail

      • Variable

        public Variable()
    • Method Detail

      • setNilValue

        public Variable setNilValue()
      • setBooleanValue

        public Variable setBooleanValue​(boolean v)
      • setIntegerValue

        public Variable setIntegerValue​(long v)
      • setIntegerValue

        public Variable setIntegerValue​(java.math.BigInteger v)
      • setFloatValue

        public Variable setFloatValue​(double v)
      • setFloatValue

        public Variable setFloatValue​(float v)
      • setBinaryValue

        public Variable setBinaryValue​(byte[] v)
      • setStringValue

        public Variable setStringValue​(java.lang.String v)
      • setStringValue

        public Variable setStringValue​(byte[] v)
      • setArrayValue

        public Variable setArrayValue​(java.util.List<Value> v)
      • setExtensionValue

        public Variable setExtensionValue​(byte type,
                                          byte[] data)
      • immutableValue

        public ImmutableValue immutableValue()
        Description copied from interface: Value
        Returns immutable copy of this value. This method simply returns this without copying the value if this value is already immutable.
        Specified by:
        immutableValue in interface Value
      • writeTo

        public void writeTo​(MessagePacker pk)
                     throws java.io.IOException
        Description copied from interface: Value
        Serializes the value using the specified MessagePacker
        Specified by:
        writeTo in interface Value
        Throws:
        java.io.IOException
        See Also:
        MessagePacker
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Description copied from interface: Value
        Compares this value to the specified object. This method returns true if type and value are equivalent. If this value is MapValue or ArrayValue, this method check equivalence of elements recursively.
        Specified by:
        equals in interface Value
        Overrides:
        equals in class java.lang.Object
      • 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()
          Overrides:
          toString in class java.lang.Object
        • getValueType

          public ValueType getValueType()
          Description copied from interface: Value
          Returns type of this value. Note that you can't use instanceof to check type of a value because type of a mutable value is variable.
          Specified by:
          getValueType in interface Value
        • 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 NilValue 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 Value
        • asBooleanValue

          public BooleanValue 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 Value
        • asNumberValue

          public NumberValue 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 IntegerValue 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 Value
        • asFloatValue

          public FloatValue 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 Value
        • asRawValue

          public RawValue 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 Value
        • asBinaryValue

          public BinaryValue 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 Value
        • asStringValue

          public StringValue 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 Value
        • asArrayValue

          public ArrayValue 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 Value
        • asMapValue

          public MapValue 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 Value
        • asExtensionValue

          public ExtensionValue 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