public class EvioReaderUnsyncV6 extends java.lang.Object implements IEvioReader
EvioReader object. This class is mostly
a wrapper to the new hipo library.The streaming effect of parsing an event is that the parser will read the event and hand off structures, such as banks, to any IEvioListeners. For those familiar with XML, the event is processed SAX-like. It is up to the listener to decide what to do with the structures.
As an alternative to stream processing, after an event is parsed, the user can use the events treeModel for access to the structures. For those familiar with XML, the event is processed DOM-like.
| Constructor and Description |
|---|
EvioReaderUnsyncV6(java.nio.ByteBuffer byteBuffer)
Constructor for reading a buffer.
|
EvioReaderUnsyncV6(java.nio.ByteBuffer byteBuffer,
boolean checkRecNumSeq)
Constructor for reading a buffer.
|
EvioReaderUnsyncV6(java.io.File file)
Constructor for reading an event file.
|
EvioReaderUnsyncV6(java.lang.String path)
Constructor for reading an event file.
|
EvioReaderUnsyncV6(java.lang.String path,
boolean checkRecNumSeq)
Constructor for reading an event file.
|
| 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)
Deprecated.
use
parseEvent(int). |
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
IEvioReader.close() been called (without reopening by calling
IEvioReader.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 method is not relevant in evio 6, does nothing, and returns 0.
|
void |
rewind()
This method is not relevant in evio 6 and does nothing.
|
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).
|
public EvioReaderUnsyncV6(java.lang.String path)
throws EvioException,
java.io.IOException
path - the full path to the file that contains events.
For writing event files, use an EventWriter object.java.io.IOException - if read failureEvioException - if file arg is nullEventWriterpublic EvioReaderUnsyncV6(java.lang.String path,
boolean checkRecNumSeq)
throws EvioException,
java.io.IOException
path - the full path to the file that contains events.
For writing event files, use an EventWriter object.checkRecNumSeq - if true check the record number sequence
and throw an exception if it is not sequential starting
with 1java.io.IOException - if read failureEvioException - if file arg is null;
if first record number != 1 when checkRecNumSeq arg is trueEventWriterpublic EvioReaderUnsyncV6(java.io.File file)
throws EvioException,
java.io.IOException
file - the file that contains events.java.io.IOException - if read failureEvioException - if file arg is nullEventWriterpublic EvioReaderUnsyncV6(java.nio.ByteBuffer byteBuffer)
throws EvioException
byteBuffer - the buffer that contains events.EvioException - if buffer arg is nullEventWriterpublic EvioReaderUnsyncV6(java.nio.ByteBuffer byteBuffer,
boolean checkRecNumSeq)
throws EvioException
byteBuffer - the buffer that contains events.checkRecNumSeq - if true check the record number sequence
and throw an exception if it is not sequential starting
with 1EvioException - if buf is null;
if first record number != 1 when checkRecNumSeq arg is true;
if buffer too small, not in the proper format, or earlier than version 6.EventWriterpublic void setBuffer(java.nio.ByteBuffer buf)
throws EvioException,
java.io.IOException
close() is called before anything else.setBuffer in interface IEvioReaderbuf - ByteBuffer to be readjava.io.IOException - if read failureEvioException - if buf is null;
if first record number != 1 when checkRecNumSeq arg is true;
if buffer too small, not in the proper format, or earlier than version 6.public boolean isClosed()
IEvioReader.close() been called (without reopening by calling
IEvioReader.setBuffer(ByteBuffer))?isClosed in interface IEvioReadertrue if this object closed, else false.public boolean checkBlockNumberSequence()
checkBlockNumberSequence in interface IEvioReadertrue if checking block number sequence, else falsepublic java.nio.ByteOrder getByteOrder()
getByteOrder in interface IEvioReaderpublic int getEvioVersion()
getEvioVersion in interface IEvioReaderpublic java.lang.String getPath()
getPath in interface IEvioReaderpublic EventParser getParser()
getParser in interface IEvioReaderpublic void setParser(EventParser parser)
setParser in interface IEvioReaderparser - file/buffer parser.public java.lang.String getDictionaryXML()
getDictionaryXML in interface IEvioReaderpublic boolean hasDictionaryXML()
hasDictionaryXML in interface IEvioReadertrue if this evio file has an associated XML dictionary,
else falsepublic EvioEvent getFirstEvent()
getFirstEvent in interface IEvioReaderpublic boolean hasFirstEvent()
hasFirstEvent in interface IEvioReadertrue if this evio file has an associated first event,
else falsepublic int getNumEventsRemaining()
getNumEventsRemaining in interface IEvioReaderpublic java.nio.ByteBuffer getByteBuffer()
getByteBuffer in interface IEvioReaderpublic long fileSize()
fileSize in interface IEvioReaderpublic IBlockHeader getFirstBlockHeader()
getFirstBlockHeader in interface IEvioReaderpublic EvioEvent getEvent(int index) throws EvioException
parseNextEvent() or parseEvent(int) instead,
since it combines combines getting an event with parsing it.getEvent in interface IEvioReaderindex - the event number in a 1,2,..N counting sense, from beginning of file/buffer.EvioException - if failed read due to bad file/buffer format;
if out of memory;
if index out of bounds;
if object closedpublic EvioEvent parseEvent(int index) throws EvioException
parseEvent in interface IEvioReaderindex - number of event desired, starting at 1, from beginning of file/bufferEvioException - if failed read due to bad file/buffer format;
if out of memory;
if index out of bounds;
if object closedpublic EvioEvent nextEvent() throws EvioException
IEvioReader.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.
nextEvent in interface IEvioReadernull.EvioException - if failed read due to bad buffer format;
if object closedpublic EvioEvent parseNextEvent() throws java.io.IOException, EvioException
parseNextEvent in interface IEvioReadernull.java.io.IOException - if failed file accessEvioException - if read failure or bad format
if object closedpublic void parseEvent(EvioEvent evioEvent) throws EvioException
As useful as this sounds, most applications will probably call IEvioReader.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.
parseEvent in interface IEvioReaderevioEvent - the event to parse.EvioException - if bad formatpublic byte[] getEventArray(int eventNumber)
throws EvioException
getEventArray in interface IEvioReadereventNumber - number of event of interest (starting at 1).EvioException - if eventNumber out of bounds (starts at 1);
if the event number does not correspond to an existing event;
if object closedpublic java.nio.ByteBuffer getEventBuffer(int eventNumber)
throws EvioException,
java.io.IOException
getEventBuffer in interface IEvioReadereventNumber - number of event of interestEvioException - if eventNumber is out of bounds;
if the event number does not correspond to an existing event;
if object closedjava.io.IOException - if failed file accesspublic void rewind()
rewind in interface IEvioReaderpublic long position()
position in interface IEvioReaderpublic void close()
throws java.io.IOException
close in interface IEvioReaderjava.io.IOException - if error accessing filepublic IBlockHeader getCurrentBlockHeader()
getCurrentBlockHeader in interface IEvioReader@Deprecated public EvioEvent gotoEventNumber(int evNumber) throws EvioException
parseEvent(int).parseEvent(int).gotoEventNumber in interface IEvioReaderevNumber - the event number from the start of the file starting at 1.EvioException - if object closedpublic WriteStatus toXMLFile(java.lang.String path) throws EvioException
toXMLFile in interface IEvioReaderpath - the path to the XML file.EvioException - if object closedpublic WriteStatus toXMLFile(java.lang.String path, boolean hex) throws EvioException
toXMLFile in interface IEvioReaderpath - the path to the XML file.hex - if true, ints get displayed in hexadecimalEvioException - if object closedpublic WriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener) throws EvioException
toXMLFile in interface IEvioReaderpath - the path to the XML file.progressListener - and optional progress listener, can be null.EvioException - if object closedIEvioProgressListenerpublic WriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener, boolean hex) throws EvioException
toXMLFile in interface IEvioReaderpath - the path to the XML file.progressListener - and optional progress listener, can be null.hex - if true, ints get displayed in hexadecimalEvioException - if object closedIEvioProgressListenerpublic int getEventCount()
throws EvioException
getEventCount in interface IEvioReaderEvioException - if read failure;
if object closedpublic int getBlockCount()
throws EvioException
getBlockCount in interface IEvioReaderEvioException - if object closed.