public class EvioCompactStructureHandler
extends java.lang.Object
EvioCompactReader
class is similar but reads files and buffers
in the complete evio version 4 format.
It is theoretically thread-safe.
It is designed to be fast and does NOT do a deserialization
on the buffer examined.Constructor and Description |
---|
EvioCompactStructureHandler(java.nio.ByteBuffer byteBuffer,
DataType type)
Constructor for reading a buffer that contains 1 structure only (no block headers).
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
addStructure(java.nio.ByteBuffer addBuffer)
This method adds a bank, segment, or tagsegment onto the end of a
structure which contains banks, segments, or tagsegments respectively.
|
void |
close()
This only sets the position to its initial value.
|
java.nio.ByteBuffer |
getByteBuffer()
Get the byte buffer being read.
|
java.util.List<EvioNode> |
getChildNodes()
This method returns an unmodifiable list of all
evio structures in buffer as EvioNode objects.
|
java.nio.ByteBuffer |
getData(EvioNode node)
Get the data associated with an evio structure in ByteBuffer form.
|
java.nio.ByteBuffer |
getData(EvioNode node,
boolean copy)
Get the data associated with an evio structure in ByteBuffer form.
|
java.util.List<EvioNode> |
getNodes()
This method returns an unmodifiable list of all
evio structures in buffer as EvioNode objects.
|
EvioNode |
getStructure()
Get the EvioNode object associated with the structure.
|
java.nio.ByteBuffer |
getStructureBuffer(EvioNode node)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
|
java.nio.ByteBuffer |
getStructureBuffer(EvioNode node,
boolean copy)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
|
boolean |
isClosed()
Has
close() been called (without reopening by calling
setBuffer(java.nio.ByteBuffer, DataType) )? |
java.util.List<EvioNode> |
searchStructure(int tag,
int num)
This method searches the event and
returns a list of objects each of which contain information
about a single evio structure which matches the given tag and num.
|
java.util.List<EvioNode> |
searchStructure(java.lang.String dictName,
EvioXMLDictionary dictionary)
This method searches the event and
returns a list of objects each of which contain information
about a single evio structure which matches the given dictionary
entry name.
|
void |
setBuffer(java.nio.ByteBuffer buf,
DataType type)
This method can be used to avoid creating additional EvioCompactEventReader
objects by reusing this one with another buffer.
|
public EvioCompactStructureHandler(java.nio.ByteBuffer byteBuffer, DataType type) throws EvioException
byteBuffer
- the buffer to be read that contains 1 structure only (no block headers).type
- the type of outermost structure contained in buffer, may be DataType.BANK
,
DataType.SEGMENT
, DataType.TAGSEGMENT
or equivalent.EvioException
- if byteBuffer arg is null;
if type arg is null or is not an evio structure;
if byteBuffer not in proper format;public void setBuffer(java.nio.ByteBuffer buf, DataType type) throws EvioException
close()
is called before anything else.buf
- the buffer to be read that contains 1 structure only (no block headers).type
- the type of outermost structure contained in buffer, may be DataType.BANK
,
DataType.SEGMENT
, DataType.TAGSEGMENT
or equivalent.EvioException
- if buf arg is null;
if type arg is null or is not an evio structure;
if buf not in proper format;public boolean isClosed()
close()
been called (without reopening by calling
setBuffer(java.nio.ByteBuffer, DataType)
)?true
if this object closed, else false
.public java.nio.ByteBuffer getByteBuffer()
public EvioNode getStructure()
public java.util.List<EvioNode> searchStructure(int tag, int num) throws EvioException
tag
- tag to matchnum
- num to matchEvioException
- if bad arg value(s);
if object closedpublic java.util.List<EvioNode> searchStructure(java.lang.String dictName, EvioXMLDictionary dictionary) throws EvioException
dictName
- name of dictionary entry to search fordictionary
- dictionary to useEvioException
- if either dictName or dictionary arg is null;
if dictName is an invalid dictionary entry;
if object closedpublic java.nio.ByteBuffer addStructure(java.nio.ByteBuffer addBuffer) throws EvioException
To produce properly formatted evio data, use
BaseStructure.write(java.nio.ByteBuffer)
,
BaseStructure.write(java.nio.ByteBuffer)
or
BaseStructure.write(java.nio.ByteBuffer)
depending on whether
a bank, seg, or tagseg is being added.
A note about files here. If the constructor of this reader read in data
from a file, it will now switch to using a new, internal buffer which
is returned by this method or can be retrieved by calling
getByteBuffer()
. It will not expand the file originally used.
The given buffer argument must be ready to read with its position and limit
defining the limits of the data to copy.
This method is synchronized due to the bulk, relative puts.
addBuffer
- buffer containing evio data to add (not evio file format,
i.e. no bank headers)EvioException
- if addBuffer is null;
if addBuffer arg is empty or has non-evio format;
if addBuffer is opposite endian to current event buffer;
if added data is not the proper length (i.e. multiple of 4 bytes);
if there is an internal programming error;
if object closedpublic java.nio.ByteBuffer getData(EvioNode node) throws EvioException
node
- evio structure whose data is to be retrievedEvioException
- if object closedpublic java.nio.ByteBuffer getData(EvioNode node, boolean copy) throws EvioException
This method is synchronized due to the bulk, relative gets & puts.
node
- evio structure whose data is to be retrievedcopy
- if true
, then return a copy as opposed to a
view into this reader object's buffer.EvioException
- if object closedpublic java.nio.ByteBuffer getStructureBuffer(EvioNode node) throws EvioException
This method is synchronized due to the bulk, relative gets & puts.
node
- node object representing evio structure of interestEvioException
- if node is null;public java.nio.ByteBuffer getStructureBuffer(EvioNode node, boolean copy) throws EvioException
This method is synchronized due to the bulk, relative gets & puts.
node
- node object representing evio structure of interestcopy
- if true
, then return a copy as opposed to a
view into this reader object's buffer.EvioException
- if node is null;
if object closedpublic java.util.List<EvioNode> getNodes() throws EvioException
EvioException
- if object closedpublic java.util.List<EvioNode> getChildNodes() throws EvioException
EvioException
- if object closedpublic void close()