|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.jevio.EvioFile
public class EvioFile
This is the a class of interest to the user. Create an EvioFile
from a File
object corresponding to an event file, and from this class you can test the file for consistency and,
more importantly, you can call parseNextEvent
to get new events and to stream the embedded
structures to an IEvioListener.
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.
NOTE: Even though this class has a constructor that accepts an i/o mode, that is for backwards
compatibility only. An EvioFile
is used for reading and parsing events only.
To write an event file, use an EventWriter
object.
Nested Class Summary | |
---|---|
static class |
EvioFile.ReadStatus
This enum denotes the status of a read. |
static class |
EvioFile.WriteStatus
This enum denotes the status of a write.SUCCESS indicates a successful write. |
Constructor Summary | |
---|---|
EvioFile(java.io.File file)
Creates an event file for reading. |
|
EvioFile(java.lang.String path)
Creates an event file. |
Method Summary | |
---|---|
void |
close()
This is equivalent to closing the file. |
static boolean |
compareEventFiles(java.io.File evFile1,
java.io.File evFile2)
Method used for diagnostics. |
int |
fileSize()
Obtain the file size using the memory mapped buffer's capacity, which should be the same. |
BlockHeader |
getCurrentBlockHeader()
This returns the current (active) block (physical record) header. |
int |
getEventCount()
This is the number of events in the file. |
java.nio.MappedByteBuffer |
getMappedByteBuffer()
Get the memory mapped buffer corresponding to the event file. |
EvioEvent |
gotoEventNumber(int evNumber)
Go to a specific event in the file. |
static void |
main(java.lang.String[] args)
For testing only |
EvioEvent |
nextEvent()
Get the next event in the file. |
void |
parseEvent(EvioEvent evioEvent)
This will parse an event, SAX-like. |
EvioEvent |
parseNextEvent()
This is the workhorse method. |
int |
position()
This is equivalent to obtaining the current position in the file. |
void |
position(int position)
This is equivalent to setting the current position in the file. |
void |
rewind()
The equivalent of rewinding the file. |
EvioFile.WriteStatus |
toXMLFile(java.lang.String path)
Rewrite the entire file to XML. |
EvioFile.WriteStatus |
toXMLFile(java.lang.String path,
IEvioProgressListener progressListener)
Rewrite the entire file to XML. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EvioFile(java.io.File file) throws java.io.IOException
file
- the file that contains EVIO events.
java.io.IOException
public EvioFile(java.lang.String path) throws java.io.IOException
path
- the full path to the file that contains events.
For writing event files, use an EventWriter
object.
java.io.IOException
EventWriter
Method Detail |
---|
public int fileSize()
public java.nio.MappedByteBuffer getMappedByteBuffer()
public EvioEvent nextEvent() throws EvioException
parseNextEvent
instead, since it combines combines getting the next
event with parsing the next event.In evio version 3, events no longer cross block boundaries. There are only one or more complete events in each block. No changes were made to this method from version 2 in order to read the version 3 format as it is subset of version 2 with variable block length.
null
.
EvioException
public EvioEvent parseNextEvent() throws EvioException
null
.
EvioException
public void parseEvent(EvioEvent evioEvent) throws EvioException
parseNextEvent
instead,
since it combines combines getting the next event with parsing the next event .
evioEvent
- the event to parse.
EvioException
public void rewind()
position
and the close
method, allows
applications to treat this in a normal random access file manner.
public int position()
rewind
, position(int)
and the
close
method, allows applications to treat this in a normal random access file manner.
public void position(int position)
rewind
, position()
and the
close
method, allows applications to treat this in a normal random access file manner.
position
- the new position of the file.public void close()
rewind
and the two position()
methods, allows applications to treat this in a normal random access file manner.
public BlockHeader getCurrentBlockHeader()
EvioFileTest
class.
public EvioEvent gotoEventNumber(int evNumber)
evNumber
- the event number in a 1..N counting sense, from the start of the file.public EvioFile.WriteStatus toXMLFile(java.lang.String path)
path
- the path to the XML file.
public EvioFile.WriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener)
path
- the path to the XML file.progressListener
- and optional progress listener, can be null
.
IEvioProgressListener
public int getEventCount() throws EvioException
EvioException
public static boolean compareEventFiles(java.io.File evFile1, java.io.File evFile2)
true
if the files are, byte-by-byte, identical.public static void main(java.lang.String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |