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 java.lang.Object
A single value that may be either a parameter or a return value associated with a
Request
. Multiple values are bundled together with theValues
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 Summary
Fields Modifier and Type Field Description static byte
DATA
type identifier forDataValue
(x)static byte
DATA_ARRAY
type identifier forDataArray
(X)static byte
DOUBLE
type identifier forDoubleValue
(d)static byte
DOUBLE_ARRAY
type identifier forDoubleArray
(D)static byte
FLOAT
type identifier forFloatValue
(f)static byte
FLOAT_ARRAY
type identifier forFloatArray
(F)static byte
INT16
type identifier forInt16Value
(h)static byte
INT16_ARRAY
type identifier forInt16Array
(H)static byte
INT32
type identifier forInt32Value
(i)static byte
INT32_ARRAY
type identifier forInt32Array
(I)static byte
INT64
type identifier forInt64Value
(l)static byte
INT64_ARRAY
type identifier forInt64Array
(L)static byte
INT8
type identifier forInt8Value
(b)static byte
INT8_ARRAY
type identifier forInt8Array
(B)static byte
STRING
type identifier forStringValue
(s)static byte
STRING_ARRAY
type identifier forStringArray
(S)
-
Constructor Summary
Constructors Constructor Description Value()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description byte[]
asData()
Interpret this value as aDataValue
and return the contents as an appropriate Java typebyte[][]
asDataArray()
Interpret this value as aDataArray
and return the contents as an appropriate Java typedouble
asDouble()
Interpret this value as aDoubleValue
and return the contents as an appropriate Java typedouble[]
asDoubleArray()
Interpret this value as aDoubleArray
and return the contents as an appropriate Java typefloat
asFloat()
Interpret this value as aFloatValue
and return the contents as an appropriate Java typefloat[]
asFloatArray()
Interpret this value as aFloatArray
and return the contents as an appropriate Java typeshort
asInt16()
Interpret this value as aInt16Value
and return the contents as an appropriate Java typeshort[]
asInt16Array()
Interpret this value as aInt16Array
and return the contents as an appropriate Java typeint
asInt32()
Interpret this value as aInt32Value
and return the contents as an appropriate Java typeint[]
asInt32Array()
Interpret this value as aInt32Array
and return the contents as an appropriate Java typelong
asInt64()
Interpret this value as aInt64Value
and return the contents as an appropriate Java typelong[]
asInt64Array()
Interpret this value as aInt64Array
and return the contents as an appropriate Java typebyte
asInt8()
Interpret this value as aInt8Value
and return the contents as an appropriate Java typebyte[]
asInt8Array()
Interpret this value as aInt8Array
and return the contents as an appropriate Java typejava.lang.String
asString()
Interpret this value as aStringValue
and return the contents as an appropriate Java typejava.lang.String[]
asStringArray()
Interpret this value as aStringArray
and return the contents as an appropriate Java typecom.yahoo.text.Utf8Array
asUtf8Array()
Interpret this value as aStringValue
and return the contents as an appropriate Java typeabstract int
count()
Obtain the number of entries stored in this value.abstract java.lang.String
toString()
Force a proper toStringabstract byte
type()
Obtain the type identifier for this value
-
-
-
Field Detail
-
INT8
public static final byte INT8
type identifier forInt8Value
(b)- See Also:
- Constant Field Values
-
INT8_ARRAY
public static final byte INT8_ARRAY
type identifier forInt8Array
(B)- See Also:
- Constant Field Values
-
INT16
public static final byte INT16
type identifier forInt16Value
(h)- See Also:
- Constant Field Values
-
INT16_ARRAY
public static final byte INT16_ARRAY
type identifier forInt16Array
(H)- See Also:
- Constant Field Values
-
INT32
public static final byte INT32
type identifier forInt32Value
(i)- See Also:
- Constant Field Values
-
INT32_ARRAY
public static final byte INT32_ARRAY
type identifier forInt32Array
(I)- See Also:
- Constant Field Values
-
INT64
public static final byte INT64
type identifier forInt64Value
(l)- See Also:
- Constant Field Values
-
INT64_ARRAY
public static final byte INT64_ARRAY
type identifier forInt64Array
(L)- See Also:
- Constant Field Values
-
FLOAT
public static final byte FLOAT
type identifier forFloatValue
(f)- See Also:
- Constant Field Values
-
FLOAT_ARRAY
public static final byte FLOAT_ARRAY
type identifier forFloatArray
(F)- See Also:
- Constant Field Values
-
DOUBLE
public static final byte DOUBLE
type identifier forDoubleValue
(d)- See Also:
- Constant Field Values
-
DOUBLE_ARRAY
public static final byte DOUBLE_ARRAY
type identifier forDoubleArray
(D)- See Also:
- Constant Field Values
-
STRING
public static final byte STRING
type identifier forStringValue
(s)- See Also:
- Constant Field Values
-
STRING_ARRAY
public static final byte STRING_ARRAY
type identifier forStringArray
(S)- See Also:
- Constant Field Values
-
DATA
public static final byte DATA
type identifier forDataValue
(x)- See Also:
- Constant Field Values
-
DATA_ARRAY
public static final byte DATA_ARRAY
type identifier forDataArray
(X)- See Also:
- Constant Field Values
-
-
Method Detail
-
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 aInt8Value
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt8Value
-
asInt8Array
public byte[] asInt8Array()
Interpret this value as aInt8Array
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt8Array
-
asInt16
public short asInt16()
Interpret this value as aInt16Value
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt16Value
-
asInt16Array
public short[] asInt16Array()
Interpret this value as aInt16Array
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt16Array
-
asInt32
public int asInt32()
Interpret this value as aInt32Value
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt32Value
-
asInt32Array
public int[] asInt32Array()
Interpret this value as aInt32Array
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt32Array
-
asInt64
public long asInt64()
Interpret this value as aInt64Value
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt64Value
-
asInt64Array
public long[] asInt64Array()
Interpret this value as aInt64Array
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aInt64Array
-
asFloat
public float asFloat()
Interpret this value as aFloatValue
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aFloatValue
-
asFloatArray
public float[] asFloatArray()
Interpret this value as aFloatArray
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aFloatArray
-
asDouble
public double asDouble()
Interpret this value as aDoubleValue
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aDoubleValue
-
asDoubleArray
public double[] asDoubleArray()
Interpret this value as aDoubleArray
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aDoubleArray
-
asString
public java.lang.String asString()
Interpret this value as aStringValue
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aStringValue
-
asUtf8Array
public com.yahoo.text.Utf8Array asUtf8Array()
Interpret this value as aStringValue
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aUtf8Array
-
asStringArray
public java.lang.String[] asStringArray()
Interpret this value as aStringArray
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aStringArray
-
asData
public byte[] asData()
Interpret this value as aDataValue
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aDataValue
-
asDataArray
public byte[][] asDataArray()
Interpret this value as aDataArray
and return the contents as an appropriate Java type- Returns:
- the value contained in this object as a Java type
- Throws:
java.lang.ClassCastException
- if this is not aDataArray
-
toString
public abstract java.lang.String toString()
Force a proper toString- Overrides:
toString
in classjava.lang.Object
-
-