Package com.yahoo.jrt

Class Value

java.lang.Object
com.yahoo.jrt.Value
Direct Known Subclasses:
DataArray, DataValue, DoubleArray, DoubleValue, FloatArray, FloatValue, Int16Array, Int16Value, Int32Array, Int32Value, Int64Array, Int64Value, Int8Array, Int8Value, StringArray, StringValue

public abstract class Value extends Object

A single value that may be either a parameter or a return value associated with a Request. Multiple values are bundled together with the Values class. The value type identifiers are defined by the RPC protocol. Each identifier matches the value of an ASCII character (listed after the Java class for the type).

Most Value subclasses that are constructed from a Java array will not copy the array. This enables the same data to back multiple Value objects, but it also means that the application should be careful not to change the backing data under the feet of a Value object.

  • Field Details

  • Constructor Details

    • Value

      public Value()
  • Method Details

    • type

      public abstract byte type()
      Obtain the type identifier for this value
      Returns:
      type identifier
    • count

      public abstract int count()
      Obtain the number of entries stored in this value. This is 1 for basic data types and the size of the array for array types.
      Returns:
      the number of entries stored in this value
    • asInt8

      public byte asInt8()
      Interpret this value as a Int8Value and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int8Value
    • asInt8Array

      public byte[] asInt8Array()
      Interpret this value as a Int8Array and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int8Array
    • asInt16

      public short asInt16()
      Interpret this value as a Int16Value and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int16Value
    • asInt16Array

      public short[] asInt16Array()
      Interpret this value as a Int16Array and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int16Array
    • asInt32

      public int asInt32()
      Interpret this value as a Int32Value and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int32Value
    • asInt32Array

      public int[] asInt32Array()
      Interpret this value as a Int32Array and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int32Array
    • asInt64

      public long asInt64()
      Interpret this value as a Int64Value and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int64Value
    • asInt64Array

      public long[] asInt64Array()
      Interpret this value as a Int64Array and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Int64Array
    • asFloat

      public float asFloat()
      Interpret this value as a FloatValue and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a FloatValue
    • asFloatArray

      public float[] asFloatArray()
      Interpret this value as a FloatArray and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a FloatArray
    • asDouble

      public double asDouble()
      Interpret this value as a DoubleValue and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a DoubleValue
    • asDoubleArray

      public double[] asDoubleArray()
      Interpret this value as a DoubleArray and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a DoubleArray
    • asString

      public String asString()
      Interpret this value as a StringValue and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a StringValue
    • asUtf8Array

      public com.yahoo.text.Utf8Array asUtf8Array()
      Interpret this value as a StringValue and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a Utf8Array
    • asStringArray

      public String[] asStringArray()
      Interpret this value as a StringArray and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a StringArray
    • asData

      public byte[] asData()
      Interpret this value as a DataValue and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a DataValue
    • asDataArray

      public byte[][] asDataArray()
      Interpret this value as a DataArray and return the contents as an appropriate Java type
      Returns:
      the value contained in this object as a Java type
      Throws:
      ClassCastException - if this is not a DataArray
    • toString

      public abstract String toString()
      Force a proper toString
      Overrides:
      toString in class Object