|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jlab.coda.jevio.CompositeData
public final class CompositeData
This is the class defining the composite data type. It is a mixture of header and raw data.
Nested Class Summary | |
---|---|
static class |
CompositeData.Data
This class is used to provide all data when constructing a CompositeData object. |
Constructor Summary | |
---|---|
CompositeData(byte[] rawBytes,
java.nio.ByteOrder byteOrder)
Constructor used when reading existing data. |
|
CompositeData(java.lang.String format,
int formatTag,
CompositeData.Data data,
int dataTag,
int dataNum)
Constructor used for creating this object from scratch. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Method to clone a CompositeData object. |
static java.util.List<java.lang.Integer> |
compositeFormatToInt(java.lang.String fmt)
This method transforms a composite, format-containing ASCII string to an int array. |
static void |
dataToRawBytes(java.nio.ByteBuffer rawBuf,
CompositeData.Data data,
java.util.List<java.lang.Integer> ifmt)
This method takes a list of data objects and a transformed format string and uses that to write data into a buffer/array in raw form. |
static byte[] |
generateRawBytes(CompositeData[] data)
This method generates raw bytes of evio format from an array of CompositeData objects. |
java.lang.Byte |
getByte()
This method gets the next data item as a Byte object. |
java.nio.ByteOrder |
getByteOrder()
This method gets the raw data byte order. |
java.lang.Double |
getDouble()
This method gets the next data item as a Double object. |
java.lang.Float |
getFloat()
This method gets the next data item as a Float object. |
java.lang.Integer |
getHollerit()
This method gets the next data item (which is of Hollerit type) as an Integer object. |
java.lang.Integer |
getInt()
This method gets the next data item as an Integer object. |
java.util.List<java.lang.Object> |
getItems()
This method gets a list of all the data items inside the composite. |
java.lang.Long |
getLong()
This method gets the next data item as a Long object. |
java.lang.Integer |
getNValue()
This method gets the next N value item as an Integer object. |
java.util.List<java.lang.Integer> |
getNValues()
This method gets a list of all the n values of the data items inside the composite. |
byte[] |
getRawBytes()
This method gets the raw byte representation of this object's data. |
java.lang.Short |
getShort()
This method gets the next data item as a Short object. |
java.lang.String[] |
getStrings()
This method gets the next data item as a String array. |
java.util.List<DataType> |
getTypes()
This method gets a list of all the types of the data items inside the composite. |
int |
index()
This methods returns the index of the data item to be returned on the next call to one of the get<Type>() methods (e.g. |
void |
index(int index)
This methods sets the index of the data item to be returned on the next call to one of the get<Type>() methods (e.g. |
static CompositeData[] |
parse(byte[] rawBytes,
java.nio.ByteOrder byteOrder)
This method parses an array of raw bytes into an array of CompositeData objects. |
void |
process()
This method swaps EVIO composite type data, in place, to big endian (IEEE) if currently little endian (DECS). |
static java.lang.String |
stringsToFormat(java.lang.String[] strings)
This method helps the CompositeData object creator by finding the proper format string parameter for putting this array of Strings into its data. |
static void |
swapAll(byte[] src,
int srcOff,
byte[] dest,
int destOff,
int length,
java.nio.ByteOrder srcOrder)
This method converts (swaps) a buffer of EVIO composite type between big & little endian. |
static void |
swapData(byte[] src,
int srcOff,
byte[] dest,
int destOff,
int nBytes,
java.util.List<java.lang.Integer> ifmt,
java.nio.ByteOrder srcOrder)
This method converts (swaps) an array of EVIO composite type data between IEEE (big endian) and DECS (little endian). |
static void |
swapData(java.nio.ByteBuffer srcBuf,
java.nio.ByteBuffer destBuf,
int nBytes,
java.util.List<java.lang.Integer> ifmt)
This method converts (swaps) EVIO composite type data between IEEE (big endian) and DECS (little endian). |
java.lang.String |
toString()
Obtain a string representation of the composite data. |
java.lang.String |
toString(boolean hex)
This method returns a string representation of this CompositeData object suitable for displaying in EventTreeFrame gui. |
java.lang.String |
toString(java.lang.String indent)
Obtain a string representation of the composite data. |
void |
toXML(javax.xml.stream.XMLStreamWriter xmlWriter,
BaseStructure bs,
boolean hex)
This method writes an xml string representation of this CompositeData object into the xmlWriter given. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CompositeData(java.lang.String format, int formatTag, CompositeData.Data data, int dataTag, int dataNum) throws EvioException
format
- format String defining dataformatTag
- tag used in tagsegment containing formatdata
- data in given formatdataTag
- tag used in bank containing datadataNum
- num used in bank containing data
EvioException
- data or format arg = null;
if improper format stringpublic CompositeData(byte[] rawBytes, java.nio.ByteOrder byteOrder) throws EvioException
rawBytes
- raw data defining this composite type itembyteOrder
- byte order of rawBytes
EvioException
Method Detail |
---|
public static CompositeData[] parse(byte[] rawBytes, java.nio.ByteOrder byteOrder) throws EvioException
rawBytes
- array of raw bytes to parsebyteOrder
- byte order of raw bytes
EvioException
- if null args or bad format of raw datapublic static byte[] generateRawBytes(CompositeData[] data)
data
- array of CompositeData object to turn into bytes
public java.lang.Object clone()
clone
in class java.lang.Object
public static java.lang.String stringsToFormat(java.lang.String[] strings)
strings
- array of strings to eventually put into a
CompositeData object.
public java.nio.ByteOrder getByteOrder()
public byte[] getRawBytes()
public java.util.List<java.lang.Object> getItems()
public java.util.List<DataType> getTypes()
public java.util.List<java.lang.Integer> getNValues()
public int index()
getInt()
.
public void index(int index)
getInt()
.
index
- the index of the next data item to be returnedpublic java.lang.Integer getInt()
public java.lang.Integer getNValue()
public java.lang.Integer getHollerit()
public java.lang.Byte getByte()
public java.lang.Short getShort()
public java.lang.Long getLong()
public java.lang.Float getFloat()
public java.lang.Double getDouble()
public java.lang.String[] getStrings()
public static java.util.List<java.lang.Integer> compositeFormatToInt(java.lang.String fmt) throws EvioException
swapData(ByteBuffer, ByteBuffer, int, List)
to swap the endianness of composite data.
It's translated from the eviofmt C function.
format code bits <- format in ascii form
[7:4] [3:0]
# 0 #'('
0 15 #'(' same as above, but have to take # from the data (32-bit)
0 0 ')'
# 1 #'i' unsigned int
# 2 #'F' floating point
# 3 #'a' 8-bit ASCII char (C++)
# 4 #'S' short
# 5 #'s' unsigned short
# 6 #'C' char
# 7 #'c' unsigned char
# 8 #'D' double (64-bit float)
# 9 #'L' long long (64-bit int)
# 10 #'l' unsigned long long (64-bit int)
# 11 #'I' int
# 12 #'A' hollerit (4-byte char with int ending)
NOTES:
1. If format ends but end of data did not reach, format in last parenthesis
will be repeated until all data processed; if there are no parenthesis
in format, data processing will be started from the beginnig of the format
(FORTRAN agreement)
2. The number of repeats '#' must be a number between 2 and 15; if the number
of repeats is symbol 'N' instead of the number, it will be taken from data
assuming 'int' format
fmt
- composite data format string
EvioException
- if improper format stringpublic static void swapAll(byte[] src, int srcOff, byte[] dest, int destOff, int length, java.nio.ByteOrder srcOrder) throws EvioException
src
- source data array (of 32 bit words)srcOff
- # of bytes offset into source data arraydest
- destination data array (of 32 bit words)destOff
- # of bytes offset into destination data arraylength
- length of data array in 32 bit wordssrcOrder
- the byte order of data in src
EvioException
- if offsets or length < 0; if src = null;
if src = dest and offsets are not the same;
if src or dest is too smallpublic static void swapData(byte[] src, int srcOff, byte[] dest, int destOff, int nBytes, java.util.List<java.lang.Integer> ifmt, java.nio.ByteOrder srcOrder) throws EvioException
src
- source data array (of 32 bit words)srcOff
- offset into source data arraydest
- destination data array (of 32 bit words)destOff
- offset into destination data arraynBytes
- length of data array in bytesifmt
- format list as produced by compositeFormatToInt(String)
srcOrder
- byte order of the src data array
EvioException
- if src == null or ifmt == null;
if nBytes or ifmt size <= 0;
if src = dest and offsets are not the same;
if src or dest is too smallpublic static void swapData(java.nio.ByteBuffer srcBuf, java.nio.ByteBuffer destBuf, int nBytes, java.util.List<java.lang.Integer> ifmt) throws EvioException
MAKE SURE destBuf IS SET TO THE OPPOSITE ENDIANNESS AS srcBuf OR
NO SWAPPING WILL TAKE PLACE! This can be done by calling
ByteBuffer.order(java.nio.ByteOrder)
.
srcBuf
- source data bufferdestBuf
- destination data buffer; if null, use srcBuf as destinationnBytes
- length of data array in bytesifmt
- format list as produced by compositeFormatToInt(String)
EvioException
- if ifmt null; ifmt size or nBytes <= 0;
srcBuf or destBuf is too smallpublic static void dataToRawBytes(java.nio.ByteBuffer rawBuf, CompositeData.Data data, java.util.List<java.lang.Integer> ifmt) throws EvioException
rawBuf
- data buffer in which to put the raw bytesdata
- data to convert to raw bytesifmt
- format list as produced by compositeFormatToInt(String)
EvioException
- if ifmt size <= 0; if srcBuf or destBuf is too
small; not enough dataItems for the given formatpublic void process()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String indent)
indent
- a string to insert in front of each group of 5 items
public void toXML(javax.xml.stream.XMLStreamWriter xmlWriter, BaseStructure bs, boolean hex) throws javax.xml.stream.XMLStreamException
xmlWriter
- the writer used to write the events to XML. It is tied to an open file.bs
- evio container object that called this method. Allows us to use
some convenient methods.hex
- if true
then print integers in hexadecimal
javax.xml.stream.XMLStreamException
public java.lang.String toString(boolean hex)
hex
- if true
then print integers in hexadecimal
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |