public interface IEvioReader
Modifier and Type | Method and Description |
---|---|
boolean |
checkBlockNumberSequence()
Is this reader checking the block number sequence and
throwing an exception if it's not sequential and starting with 1?
|
void |
close()
This is closes the file, but for buffers it only sets the position to 0.
|
long |
fileSize()
Get the size of the file being read, in bytes.
|
int |
getBlockCount()
This is the number of records in the file/buffer including the empty
record or trailer at the end.
|
java.nio.ByteBuffer |
getByteBuffer()
Get the byte buffer being read directly or corresponding to the event file.
|
java.nio.ByteOrder |
getByteOrder()
Get the byte order of the file/buffer being read.
|
IBlockHeader |
getCurrentBlockHeader()
This returns the current (active) block (physical record) header.
|
java.lang.String |
getDictionaryXML()
Get the XML format dictionary if there is one.
|
EvioEvent |
getEvent(int index)
Get the event in the file/buffer at a given index (starting at 1).
|
byte[] |
getEventArray(int eventNumber)
Get an evio bank or event in byte array form.
|
java.nio.ByteBuffer |
getEventBuffer(int eventNumber)
Get an evio bank or event in ByteBuffer form.
|
int |
getEventCount()
This is the number of events in the file/buffer.
|
int |
getEvioVersion()
Get the evio version number.
|
IBlockHeader |
getFirstBlockHeader()
This returns the FIRST block (physical record) header.
|
EvioEvent |
getFirstEvent()
Get the "first" event if there is one.
|
int |
getNumEventsRemaining()
Get the number of events remaining in the file.
|
EventParser |
getParser()
Get the file/buffer parser.
|
java.lang.String |
getPath()
Get the path to the file.
|
EvioEvent |
gotoEventNumber(int evNumber)
Go to a specific event in the file.
|
boolean |
hasDictionaryXML()
Does this evio file have an associated XML dictionary?
|
boolean |
hasFirstEvent()
Does this evio file have an associated first event?
It's also called the Beginning-Of-Run event.
|
boolean |
isClosed()
Has
close() been called (without reopening by calling
setBuffer(ByteBuffer) )? |
EvioEvent |
nextEvent()
Get the next event in the file/buffer.
|
void |
parseEvent(EvioEvent evioEvent)
This will parse an event, SAX-like.
|
EvioEvent |
parseEvent(int index)
This is a workhorse method.
|
EvioEvent |
parseNextEvent()
This is a workhorse method.
|
long |
position()
This is equivalent to obtaining the current position in the file.
|
void |
rewind()
The equivalent of rewinding the file.
|
void |
setBuffer(java.nio.ByteBuffer buf)
This method can be used to avoid creating additional EvioReader
objects by reusing this one with another buffer.
|
void |
setParser(EventParser parser)
Set the file/buffer parser.
|
WriteStatus |
toXMLFile(java.lang.String path)
Rewrite the file to XML (not including dictionary and "first" event).
|
WriteStatus |
toXMLFile(java.lang.String path,
boolean hex)
Rewrite the file to XML (not including dictionary and "first" event).
|
WriteStatus |
toXMLFile(java.lang.String path,
IEvioProgressListener progressListener)
Rewrite the file to XML (not including dictionary and "first" event).
|
WriteStatus |
toXMLFile(java.lang.String path,
IEvioProgressListener progressListener,
boolean hex)
Rewrite the file to XML (not including dictionary and "first" event).
|
void setBuffer(java.nio.ByteBuffer buf) throws EvioException, java.io.IOException
close()
is called before anything else.buf
- ByteBuffer to be readjava.io.IOException
- if read failureEvioException
- if buf is null;
if first block number != 1 when checkBlkNumSeq arg is trueboolean isClosed()
close()
been called (without reopening by calling
setBuffer(ByteBuffer)
)?true
if this object closed, else false
.boolean checkBlockNumberSequence()
true
if checking block number sequence, else false
java.nio.ByteOrder getByteOrder()
int getEvioVersion()
java.lang.String getPath()
EventParser getParser()
void setParser(EventParser parser)
parser
- file/buffer parser.java.lang.String getDictionaryXML()
boolean hasDictionaryXML()
true
if this evio file has an associated XML dictionary,
else false
EvioEvent getFirstEvent()
boolean hasFirstEvent()
true
if this evio file has an associated first event,
else false
int getNumEventsRemaining() throws java.io.IOException, EvioException
java.io.IOException
- if failed file accessEvioException
- if failed reading from coda v3 filejava.nio.ByteBuffer getByteBuffer()
long fileSize()
IBlockHeader getFirstBlockHeader()
EvioEvent getEvent(int index) throws java.io.IOException, EvioException
parseNextEvent()
or parseEvent(int)
instead,
since it combines combines getting an event with parsing it.index
- number of event desired, starting at 1, from beginning of file/bufferjava.io.IOException
- if failed file accessEvioException
- if failed read due to bad file/buffer format;
if out of memory;
if index out of bounds;
if object closedEvioEvent parseEvent(int index) throws java.io.IOException, EvioException
index
- number of event desired, starting at 1, from beginning of file/bufferjava.io.IOException
- if failed file accessEvioException
- if failed read due to bad file/buffer format;
if out of memory;
if index out of bounds;
if object closedEvioEvent nextEvent() throws java.io.IOException, EvioException
parseNextEvent()
instead, since
it combines getting the next event with parsing the next event.Although this method can get events in versions 4+, it now delegates that to another method. No changes were made to this method from versions 1-3 in order to read the version 4 format as it is subset of versions 1-3 with variable block length.
null
.java.io.IOException
- if failed file accessEvioException
- if failed read due to bad buffer format;
if object closedEvioEvent parseNextEvent() throws java.io.IOException, EvioException
null
.java.io.IOException
- if failed file accessEvioException
- if read failure or bad format
if object closedvoid parseEvent(EvioEvent evioEvent) throws EvioException
As useful as this sounds, most applications will probably call parseNextEvent()
instead, since it combines combines getting the next event with parsing the next event.
This method is only called by synchronized methods and therefore is not synchronized.
evioEvent
- the event to parse.EvioException
- if bad formatbyte[] getEventArray(int eventNumber) throws EvioException, java.io.IOException
eventNumber
- number of event of interest (starting at 1).java.io.IOException
- if failed file accessEvioException
- if eventNumber out of bounds (starts at 1);
if the event number does not correspond to an existing event;
if object closedjava.nio.ByteBuffer getEventBuffer(int eventNumber) throws EvioException, java.io.IOException
eventNumber
- number of event of interestjava.io.IOException
- if failed file accessEvioException
- if eventNumber is out of bounds;
if the event number does not correspond to an existing event;
if object closedvoid rewind() throws java.io.IOException, EvioException
position()
and the
close()
method, allows applications to treat files
in a normal random access manner.java.io.IOException
- if failed file access or buffer/file readEvioException
- if object closedlong position() throws java.io.IOException, EvioException
rewind()
, position(int)
and the close()
method, allows applications to treat files
in a normal random access manner. Only meaningful to evio versions 1-3
and for sequential reading.java.io.IOException
- if error accessing fileEvioException
- if object closedvoid close() throws java.io.IOException
rewind()
and the two
position()
methods, allows applications to treat files
in a normal random access manner.java.io.IOException
- if error accessing fileIBlockHeader getCurrentBlockHeader()
EvioEvent gotoEventNumber(int evNumber) throws java.io.IOException, EvioException
getEvent(int)
.evNumber
- the event number in a 1..N counting sense, from the start of the file.java.io.IOException
- if failed file accessEvioException
- if object closedWriteStatus toXMLFile(java.lang.String path) throws java.io.IOException, EvioException
path
- the path to the XML file.java.io.IOException
- if failed file accessEvioException
- if object closedWriteStatus toXMLFile(java.lang.String path, boolean hex) throws java.io.IOException, EvioException
path
- the path to the XML file.hex
- if true, ints get displayed in hexadecimaljava.io.IOException
- if failed file accessEvioException
- if object closedWriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener) throws java.io.IOException, EvioException
path
- the path to the XML file.progressListener
- and optional progress listener, can be null
.java.io.IOException
- if failed file accessEvioException
- if object closedIEvioProgressListener
WriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener, boolean hex) throws java.io.IOException, EvioException
path
- the path to the XML file.progressListener
- and optional progress listener, can be null
.hex
- if true, ints get displayed in hexadecimaljava.io.IOException
- if failed file accessEvioException
- if object closedIEvioProgressListener
int getEventCount() throws java.io.IOException, EvioException
java.io.IOException
- if failed file accessEvioException
- if read failure;
if object closedint getBlockCount() throws EvioException
EvioException
- if object closed.