Package org.apache.vinci.transport
Class FrameLeaf
java.lang.Object
org.apache.vinci.transport.FrameComponent
org.apache.vinci.transport.FrameLeaf
- Direct Known Subclasses:
AFrameLeaf
Class encapsulating leaf data from a Frame. Internally, leaf data is always represented as UTF-8.
Most people will never have to use this class directly unless implementing specialized Frame
document types.
While FrameLeaf is effectively an immutable class, any descendents that implement setAttributes
of the base class FrameComponent are not likely to be immutable.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
If you call toString() on a FrameLeaf which contains binary data, you get this string as the result. -
Constructor Summary
ConstructorDescriptionFrameLeaf
(boolean bool) FrameLeaf
(byte[] mydata, boolean encode) Create a frameleaf from existing UTF-8 (or true binary) data.FrameLeaf
(double myfloat) FrameLeaf
(double[] mydouble) FrameLeaf
(float myfloat_) FrameLeaf
(float[] myfloat) FrameLeaf
(int myint_) FrameLeaf
(int[] myint) FrameLeaf
(long myint) FrameLeaf
(long[] mylong) This method does NOT support null values in the array. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getData()
Get the raw (usually UTF-8) frame data.boolean
Converts the UTF-8 data to a Java boolean.byte[]
toBytes()
Converts the B64 encoded data to binary and returns it.double
toDouble()
Converts the UTF-8 data to a Java double type.double[]
Converts the UTF-8 data to a Java array of double.float
toFloat()
Converts the UTF-8 data to a Java float type.float[]
Converts the UTF-8 data to a Java array of float.int
toInt()
Converts the UTF-8 data to a Java int type.int[]
Converts the UTF-8 data to a Java array of ints.long
toLong()
Converts the UTF-8 data to a Java long type.long[]
Converts the UTF-8 data to a Java array of longs.toString()
String[]
Methods inherited from class org.apache.vinci.transport.FrameComponent
getAttributes, setAttributes
-
Field Details
-
NOT_UTF8_ERROR
If you call toString() on a FrameLeaf which contains binary data, you get this string as the result.- See Also:
-
-
Constructor Details
-
FrameLeaf
public FrameLeaf(byte[] mydata, boolean encode) Create a frameleaf from existing UTF-8 (or true binary) data. WARNING: Does not copy the array. Caller is responsible for ensuring the provided byte array cannot be modified by external code.- Parameters:
mydata
- -encode
- -
-
FrameLeaf
- Parameters:
mydata
- -
-
FrameLeaf
This method does NOT support null values in the array.- Parameters:
mystring
- -
-
FrameLeaf
public FrameLeaf(float myfloat_) -
FrameLeaf
public FrameLeaf(float[] myfloat) - Parameters:
myfloat
- -
-
FrameLeaf
public FrameLeaf(double myfloat) -
FrameLeaf
public FrameLeaf(double[] mydouble) - Parameters:
mydouble
- -
-
FrameLeaf
public FrameLeaf(int myint_) -
FrameLeaf
public FrameLeaf(int[] myint) - Parameters:
myint
- -
-
FrameLeaf
public FrameLeaf(long myint) -
FrameLeaf
public FrameLeaf(long[] mylong) - Parameters:
mylong
- -
-
FrameLeaf
public FrameLeaf(boolean bool)
-
-
Method Details
-
toString
-
toStringArray
-
getData
public byte[] getData()Get the raw (usually UTF-8) frame data.- Returns:
- -
-
toBytes
public byte[] toBytes()Converts the B64 encoded data to binary and returns it.- Returns:
- -
- Throws:
LeafCastException
- if the data was not base64 encoded.
-
toLong
public long toLong()Converts the UTF-8 data to a Java long type.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be converted to long.
-
toLongArray
public long[] toLongArray()Converts the UTF-8 data to a Java array of longs.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be convered to a long array.
-
toInt
public int toInt()Converts the UTF-8 data to a Java int type.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be converted to int.
-
toIntArray
public int[] toIntArray()Converts the UTF-8 data to a Java array of ints.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be convered to an int array.
-
toFloat
public float toFloat()Converts the UTF-8 data to a Java float type.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be converted to float.
-
toFloatArray
public float[] toFloatArray()Converts the UTF-8 data to a Java array of float.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be convered to a float array.
-
toDouble
public double toDouble()Converts the UTF-8 data to a Java double type.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be converted to double.
-
toDoubleArray
public double[] toDoubleArray()Converts the UTF-8 data to a Java array of double.- Returns:
- -
- Throws:
LeafCastException
- if the data could not be convered to a double array.
-
toBoolean
public boolean toBoolean()Converts the UTF-8 data to a Java boolean.- Returns:
- -
- Throws:
LeafCastException
- if the underlying data was not utf-8 (which in general should not happen).
-