public final class CompactEventBuilder
extends java.lang.Object
The methods of this class are not synchronized so it is NOT
threadsafe. This is done for speed. The buffer retrieved by
getBuffer()
is ready to read.
Constructor and Description |
---|
CompactEventBuilder(java.nio.ByteBuffer buffer)
This is the constructor to use for building a new event
(just the event in a buffer, not the full evio file format)
with a user-given buffer.
|
CompactEventBuilder(java.nio.ByteBuffer buffer,
boolean generateNodes)
This is the constructor to use for building a new event
(just the event in a buffer, not the full evio file format)
with a user-given buffer.
|
CompactEventBuilder(int bufferSize,
java.nio.ByteOrder order)
This is the constructor to use for building a new event
(just the event in a buffer, not the full evio file format).
|
CompactEventBuilder(int bufferSize,
java.nio.ByteOrder order,
boolean generateNodes)
This is the constructor to use for building a new event
(just the event in a buffer, not the full evio file format).
|
Modifier and Type | Method and Description |
---|---|
void |
addByteData(byte[] data)
Appends byte data to the structure.
|
void |
addCompositeData(CompositeData[] data)
Appends CompositeData objects to the structure.
|
void |
addDoubleData(double[] data)
Appends double data to the structure.
|
void |
addEvioNode(EvioNode node)
Adds the evio structure represented by the EvioNode object
into the buffer.
|
void |
addFloatData(float[] data)
Appends float data to the structure.
|
void |
addIntData(int[] data)
Appends int data to the structure.
|
void |
addIntData(int[] data,
int offset)
Appends int data to the structure.
|
void |
addIntData(int[] data,
int offset,
int len)
Appends int data to the structure.
|
void |
addLongData(long[] data)
Appends long data to the structure.
|
void |
addLongData(long[] data,
int offset,
int len)
Appends long data to the structure.
|
void |
addShortData(short data)
Appends a short integer to the structure.
|
void |
addShortData(short[] data)
Appends short data to the structure.
|
void |
addShortData(short[] data,
int offset,
int len)
Appends short data to the structure.
|
void |
addStringData(java.lang.String[] strings)
Appends string array to the structure.
|
void |
closeAll()
This method finishes the event writing by setting all the
proper lengths and padding and ends up at the event or top level.
|
boolean |
closeStructure()
This method ends the writing of the current evio structure and
makes sure the length and padding fields are properly set.
|
java.nio.ByteBuffer |
getBuffer()
Get the buffer being written into.
|
int |
getTotalBytes()
Get the total number of bytes written into the buffer.
|
EvioNode |
openBank(int tag,
int num,
DataType dataType)
This method adds an evio bank to the buffer.
|
EvioNode |
openSegment(int tag,
DataType dataType)
This method adds an evio segment structure to the buffer.
|
EvioNode |
openTagSegment(int tag,
DataType dataType)
This method adds an evio tagsegment structure to the buffer.
|
void |
setBuffer(java.nio.ByteBuffer buffer)
Set the buffer to be written into.
|
void |
setBuffer(java.nio.ByteBuffer buffer,
boolean generateNodes)
Set the buffer to be written into.
|
void |
setTopLevelTag(short tag)
In the emu software package, it's necessary to change the top level
tag after the top level bank has already been created.
|
void |
toFile(java.lang.String filename)
This method writes a file in proper evio format with block header
containing the single event constructed by this object.
|
public CompactEventBuilder(int bufferSize, java.nio.ByteOrder order) throws EvioException
bufferSize
- size of byte buffer (in bytes) to create.order
- byte order of created buffer.EvioException
- if arg is null;
if bufferSize arg too smallpublic CompactEventBuilder(int bufferSize, java.nio.ByteOrder order, boolean generateNodes) throws EvioException
bufferSize
- size of byte buffer (in bytes) to create.order
- byte order of created buffer.generateNodes
- generate and store an EvioNode object
for each evio structure created.EvioException
- if arg is null;
if bufferSize arg too smallpublic CompactEventBuilder(java.nio.ByteBuffer buffer) throws EvioException
buffer
- the byte buffer to write into.EvioException
- if arg is null;
if buffer is too smallpublic CompactEventBuilder(java.nio.ByteBuffer buffer, boolean generateNodes) throws EvioException
buffer
- the byte buffer to write into.generateNodes
- generate and store an EvioNode object
for each evio structure created.EvioException
- if arg is null;
if buffer is too smallpublic void setBuffer(java.nio.ByteBuffer buffer) throws EvioException
buffer
- buffer to be written into.EvioException
- if arg is null;
if buffer is too smallpublic void setBuffer(java.nio.ByteBuffer buffer, boolean generateNodes) throws EvioException
buffer
- buffer to be written into.generateNodes
- generate and store an EvioNode object
for each evio structure created.EvioException
- if arg is null;
if buffer is too smallpublic java.nio.ByteBuffer getBuffer()
public int getTotalBytes()
public EvioNode openSegment(int tag, DataType dataType) throws EvioException
tag
- tag of segment headerdataType
- type of data to be contained by this segmentEvioException
- if containing structure does not hold segments;
if no room in buffer for segment header;
if too many nested evio structures;
if top-level bank has not been added first.public EvioNode openTagSegment(int tag, DataType dataType) throws EvioException
tag
- tag of tagsegment headerdataType
- type of data to be contained by this tagsegmentEvioException
- if containing structure does not hold tagsegments;
if no room in buffer for tagsegment header;
if too many nested evio structures;
if top-level bank has not been added first.public EvioNode openBank(int tag, int num, DataType dataType) throws EvioException
tag
- tag of bank headernum
- num of bank headerdataType
- data type to be contained in this bankEvioException
- if containing structure does not hold banks;
if no room in buffer for bank header;
if too many nested evio structures;public boolean closeStructure()
true
if top structure was reached (is current), else false
.public void closeAll()
public void setTopLevelTag(short tag)
tag
- new tag value of top-level, event bank.public void addEvioNode(EvioNode node) throws EvioException
node
- the EvioNode object representing the evio structure to data.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addByteData(byte[] data) throws EvioException
data
- the byte data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addIntData(int[] data) throws EvioException
data
- the int data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addIntData(int[] data, int offset) throws EvioException
data
- the int data to append.offset
- offset into data array or number of integers at
beginning of data to skip (not to add to event).EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addIntData(int[] data, int offset, int len) throws EvioException
data
- the int data to append.offset
- offset into data array.len
- the number of ints from data to append.EvioException
- if data is null;
if count/offset negative or too large;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addShortData(short[] data) throws EvioException
data
- the short data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addShortData(short[] data, int offset, int len) throws EvioException
data
- the short data to append.offset
- offset into data array.len
- the number of shorts from data to append.EvioException
- if data is null;
if count/offset negative or too large;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addShortData(short data) throws EvioException
data
- the short data to append.EvioException
- if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addLongData(long[] data) throws EvioException
data
- the long data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addLongData(long[] data, int offset, int len) throws EvioException
data
- the long data to append.offset
- offset into data array.len
- the number of longs from data to append.EvioException
- if data is null;
if count/offset negative or too large;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addFloatData(float[] data) throws EvioException
data
- the float data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addDoubleData(double[] data) throws EvioException
data
- the double data to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addStringData(java.lang.String[] strings) throws EvioException
strings
- the strings to append.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void addCompositeData(CompositeData[] data) throws EvioException
data
- the CompositeData objects to append, or set if there is no existing data.EvioException
- if data is null or empty;
if adding wrong data type to structure;
if structure not added first;
if no room in buffer for data.public void toFile(java.lang.String filename)
filename
- name of file