|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.cMsg.cMsgPayloadItem
public final class cMsgPayloadItem
This class represents an item in a cMsg message's payload. The value of each item is stored in this class along with a text representation of that item. Following is the text format of various types of payload items where [nl] means newline.
Note that there is only 1 space or newline between all entries. The only exception to the 1 space spacing is between the last two entries on each "header" line (the line that contains the item_name). There may be several spaces between the last 2 entries on these lines.
for string items:
item_name item_type item_count isSystemItem? item_length[nl] string_length_1[nl] string_characters_1[nl] . . . string_length_N[nl] string_characters_N
for binary (converted into text) items:
item_name item_type original_binary_byte_length isSystemItem? item_length[nl] string_length endian[nl] string_characters[nl]
for primitive type items:
item_name item_type item_count isSystemItem? item_length[nl] value_1 value_2 ... value_N[nl]
A cMsg message is formatted as a compound payload. Each message has a number of fields (payload items).
for message items:
_ item_name item_type item_count isSystemItem? item_length[nl] / message_1_in_compound_payload_text_format[nl] < field_count[nl] . \ list_of_payload_format_items . - . message_N_in_compound_payload_text_format[nl]
Constructor Summary | |
---|---|
cMsgPayloadItem(java.lang.String name,
java.math.BigInteger big)
Construct a payload item from an unsigned 64-bit integer. |
|
cMsgPayloadItem(java.lang.String name,
java.math.BigInteger[] bigs)
Construct a payload item from an array of unsigned 64-bit integers. |
|
cMsgPayloadItem(java.lang.String name,
byte b)
Construct a payload item from an 8-bit integer. |
|
cMsgPayloadItem(java.lang.String name,
byte[] b)
Construct a payload item from an array of 8-bit integers. |
|
cMsgPayloadItem(java.lang.String name,
byte[] b,
int end)
Construct a payload item from a byte array containing binary data. |
|
cMsgPayloadItem(java.lang.String name,
cMsgMessage msg)
Construct a payload item from a cMsgMessage object. |
|
cMsgPayloadItem(java.lang.String name,
cMsgMessage[] msgs)
Construct a payload item from an array of cMsgMessage objects. |
|
cMsgPayloadItem(java.lang.String name,
double d)
Construct a payload item from a double. |
|
cMsgPayloadItem(java.lang.String name,
double[] d)
Construct a payload item from an array of doubles. |
|
cMsgPayloadItem(java.lang.String name,
float f)
Construct a payload item from a float. |
|
cMsgPayloadItem(java.lang.String name,
float[] f)
Construct a payload item from an array of floats. |
|
cMsgPayloadItem(java.lang.String name,
int i)
Construct a payload item from a 32-bit integer. |
|
cMsgPayloadItem(java.lang.String name,
int[] i)
Construct a payload item from an array of 32-bit integers. |
|
cMsgPayloadItem(java.lang.String name,
long l)
Construct a payload item from a 64-bit integer. |
|
cMsgPayloadItem(java.lang.String name,
long[] l)
Construct a payload item from an array of 64-bit integers. |
|
cMsgPayloadItem(java.lang.String name,
short s)
Construct a payload item from a 16-bit integer. |
|
cMsgPayloadItem(java.lang.String name,
short[] s)
Construct a payload item from an array of 16-bit integers. |
|
cMsgPayloadItem(java.lang.String name,
java.lang.String s)
Construct a payload item from a String object. |
|
cMsgPayloadItem(java.lang.String name,
java.lang.String[] s)
Construct a payload item from a String array. |
|
cMsgPayloadItem(java.lang.String name,
T t)
Construct a payload item from an object implementing the Number interface. |
|
cMsgPayloadItem(java.lang.String name,
T[] t)
Construct a payload item from an array of objects implementing the Number interface. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clone this object. |
cMsgPayloadItem |
copy()
Creates a complete copy of this object. |
java.math.BigInteger |
getBigInt()
Gets the payload item as a BigInteger object. |
java.math.BigInteger[] |
getBigIntArray()
Gets the payload item as an array of BigInteger objects. |
byte[] |
getBinary()
Gets the payload item as a byte array object holding binary data. |
byte |
getByte()
Gets the payload item as a byte (8-bit integer). |
byte[] |
getByteArray()
Gets the payload item as an array of bytes (8-bit integers). |
int |
getCount()
Get the number of elements if this payload item is an array, else return one. |
double |
getDouble()
Gets the payload item as a double. |
double[] |
getDoubleArray()
Gets the payload item as an array of doubles. |
int |
getEndian()
Get the endian value if this payload item is a byte array containing binary data. |
float |
getFloat()
Gets the payload item as a float. |
float[] |
getFloatArray()
Gets the payload item as an array of floats. |
int |
getInt()
Gets the payload item as a int (32-bit integer). |
int[] |
getIntArray()
Gets the payload item as an array of ints (32-bit integers). |
java.lang.Object |
getItem()
Get the payload item itself as an object of class Object. |
long |
getLong()
Gets the payload item as a long (64-bit integer). |
long[] |
getLongArray()
Gets the payload item as an array of longs (64-bit integers). |
cMsgMessage |
getMessage()
Gets the payload item as a cMsgMessage object. |
cMsgMessage[] |
getMessageArray()
Gets the payload item as an array of cMsgMessage objects. |
java.lang.String |
getName()
Get the name of this payload item. |
short |
getShort()
Gets the payload item as a short (16-bit integer). |
short[] |
getShortArray()
Gets the payload item as an array of shorts (16-bit integers). |
java.lang.String |
getString()
Gets the payload item as a String object. |
java.lang.String[] |
getStringArray()
Gets the payload item as an array of String objects. |
java.lang.String |
getText()
Get the text representation of this payload item. |
int |
getType()
Get the type of this payload item. |
static void |
intToStr(java.lang.StringBuilder sb,
int i)
This method changes an int value into a string of 8 hex characters in order to represent its bit pattern. |
static void |
longToStr(java.lang.StringBuilder sb,
long l)
This method changes a long value into a string of 16 hex characters in order to represent its bit pattern. |
void |
validName(java.lang.String name,
boolean isSystem)
This method checks a string to see if it is a valid payload item name. |
static void |
zerosToIntStr(java.lang.StringBuilder sb,
int zeros)
This method changes an integer value into a string of 8 hex characters starting with "Z" in order to represent a number of zeros in our simple zero-compression scheme. |
static void |
zerosToLongStr(java.lang.StringBuilder sb,
int zeros)
This method changes an integer value into a string of 16 hex characters starting with "Z" in order to represent a number of zeros in our simple zero-compression scheme. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public cMsgPayloadItem(java.lang.String name, java.lang.String s) throws cMsgException
name
- name of items
- string to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, java.lang.String[] s) throws cMsgException
name
- name of items
- string to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, byte[] b, int end) throws cMsgException
name
- name of itemb
- byte array containing binary data to be part of the payloadend
- endian value of the binary data (cMsgConstants.endianBig
,
cMsgConstants.endianLittle
, cMsgConstants.endianLocal
, or
cMsgConstants.endianNotLocal
)
cMsgException
- if invalid name or endian valuepublic cMsgPayloadItem(java.lang.String name, cMsgMessage msg) throws cMsgException
name
- name of itemmsg
- cMsgMessage object to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, cMsgMessage[] msgs) throws cMsgException
name
- name of itemmsgs
- array of cMsgMessage objects to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, byte b) throws cMsgException
name
- name of itemb
- byte (8-bit integer) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, short s) throws cMsgException
name
- name of items
- short (16-bit integer) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, int i) throws cMsgException
name
- name of itemi
- int (32-bit integer) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, long l) throws cMsgException
name
- name of iteml
- long (64-bit integer) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, java.math.BigInteger big) throws cMsgException
name
- name of itembig
- BigInteger object (containing an unsigned 64-bit integer) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, T t) throws cMsgException
Byte
, Short
, Integer
,
Long
, Float
, or Double
.
name
- name of itemt
- Number object to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, byte[] b) throws cMsgException
name
- name of itemb
- byte array (array of 8-bit integers) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, short[] s) throws cMsgException
name
- name of items
- short array (array of 16-bit integers) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, int[] i) throws cMsgException
name
- name of itemi
- int array (array of 32-bit integers) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, long[] l) throws cMsgException
name
- name of iteml
- long array (array of 64-bit integers) to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, java.math.BigInteger[] bigs) throws cMsgException
name
- name of itembigs
- array of BigInteger objects (each containing an unsigned 64-bit integer)
to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, T[] t) throws cMsgException
Byte
, Short
, Integer
,
Long
, Float
, or Double
.
name
- name of itemt
- array of Number objects to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, float f) throws cMsgException
name
- name of itemf
- float to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, double d) throws cMsgException
name
- name of itemd
- double to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, float[] f) throws cMsgException
name
- name of itemf
- float array to be part of the payload
cMsgException
- if invalid namepublic cMsgPayloadItem(java.lang.String name, double[] d) throws cMsgException
name
- name of itemd
- double array to be part of the payload
cMsgException
- if invalid nameMethod Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public cMsgPayloadItem copy()
public void validName(java.lang.String name, boolean isSystem) throws cMsgException
name
- string to checkisSystem
- if true, allows names starting with "cmsg", else not
cMsgException
- if string is null, contains illegal characters, starts with
"cmsg" if not isSystem, or is too longpublic static final void zerosToIntStr(java.lang.StringBuilder sb, int zeros)
sb
- StringBuilder object into which the characters are writtenzeros
- the number of zeros to be encoded/compressedpublic static final void zerosToLongStr(java.lang.StringBuilder sb, int zeros)
sb
- StringBuilder object into which the characters are writtenzeros
- the number of zeros to be encoded/compressedpublic static final void longToStr(java.lang.StringBuilder sb, long l)
sb
- StringBuilder object into which the characters are writtenl
- the number to transformpublic static final void intToStr(java.lang.StringBuilder sb, int i)
sb
- StringBuilder object into which the characters are writteni
- the number to transformpublic java.lang.String getName()
public java.lang.Object getItem()
public int getType()
cMsgConstants.payloadStr
for a String
cMsgConstants.payloadFlt
for a 4 byte float
cMsgConstants.payloadDbl
for an 8 byte float
cMsgConstants.payloadInt8
for an 8 bit int
cMsgConstants.payloadInt16
for a 16 bit int
cMsgConstants.payloadInt32
for a 32 bit int
cMsgConstants.payloadInt64
for a 64 bit int
cMsgConstants.payloadUint8
for an unsigned 8 bit int
cMsgConstants.payloadUint16
for an unsigned 16 bit int
cMsgConstants.payloadUint32
for an unsigned 32 bit int
cMsgConstants.payloadUint64
for an unsigned 64 bit int
cMsgConstants.payloadMsg
for a cMsg message
cMsgConstants.payloadBin
for binary
cMsgConstants.payloadStrA
for a String array
cMsgConstants.payloadFltA
for a 4 byte float array
cMsgConstants.payloadDblA
for an 8 byte float array
cMsgConstants.payloadInt8A
for an 8 bit int array
cMsgConstants.payloadInt16A
for a 16 bit int array
cMsgConstants.payloadInt32A
for a 32 bit int array
cMsgConstants.payloadInt64A
for a 64 bit int array
cMsgConstants.payloadUint8A
for an unsigned 8 bit int array
cMsgConstants.payloadUint16A
for an unsigned 16 bit int array
cMsgConstants.payloadUint32A
for an unsigned 32 bit int array
cMsgConstants.payloadUint64A
for an unsigned 64 bit int array
cMsgConstants.payloadMsgA
for a cMsg message array
public java.lang.String getText()
public int getCount()
public int getEndian()
public java.lang.String getString() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadStr
public java.lang.String[] getStringArray() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadStrA
public byte[] getBinary() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadBin
public cMsgMessage getMessage() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadMsg
public cMsgMessage[] getMessageArray() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadMsgA
public byte getByte() throws cMsgException
cMsgException
- if payload item is not of an integer type,
or if its value is out-of-range for a bytepublic short getShort() throws cMsgException
cMsgException
- if payload item is not of an integer type,
or if its value is out-of-range for a shortpublic int getInt() throws cMsgException
cMsgException
- if payload item is not of an integer type,
or if its value is out-of-range for a intpublic long getLong() throws cMsgException
cMsgException
- if payload item is not of an integer type,
or if its value is out-of-range for a longpublic java.math.BigInteger getBigInt() throws cMsgException
cMsgException
- if payload item is not of an integer typepublic byte[] getByteArray() throws cMsgException
cMsgException
- if payload item is not of an integer array type,
or if its array values are out-of-range for a bytepublic short[] getShortArray() throws cMsgException
cMsgException
- if payload item is not of an integer array type,
or if its array values are out-of-range for a shortpublic int[] getIntArray() throws cMsgException
cMsgException
- if payload item is not of an integer array type,
or if its array values are out-of-range for a intpublic long[] getLongArray() throws cMsgException
cMsgException
- if payload item is not of an integer array type,
or if its array values are out-of-range for a longpublic java.math.BigInteger[] getBigIntArray() throws cMsgException
cMsgException
- if payload item is not of an integer array typepublic float getFloat() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadFlt
,
or it's not of type cMsgConstants.payloadDbl
and
its value is out-of-range for a floatpublic double getDouble() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadFlt
or cMsgConstants.payloadDbl
public float[] getFloatArray() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadFltA
,
or it's not of type cMsgConstants.payloadDblA
and
its values are out-of-range for a floatpublic double[] getDoubleArray() throws cMsgException
cMsgException
- if payload item is not of type cMsgConstants.payloadFltA
or cMsgConstants.payloadDblA
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |