org.jlab.coda.jevio
Class EvioFile

java.lang.Object
  extended by org.jlab.coda.jevio.EvioFile

Deprecated. Use the EvioReader class instead which can read both files and buffers.

public class EvioFile
extends java.lang.Object

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.

Author:
heddle

Nested Class Summary
static class EvioFile.ReadStatus
          Deprecated. This enum denotes the status of a read.
static class EvioFile.WriteStatus
          Deprecated. This enum denotes the status of a write.
SUCCESS indicates a successful write.
 
Constructor Summary
EvioFile(java.io.File file)
          Deprecated. Creates an event file for reading.
EvioFile(java.lang.String path)
          Deprecated. Creates an event file.
 
Method Summary
 void close()
          Deprecated. This is equivalent to closing the file.
static boolean compareEventFiles(java.io.File evFile1, java.io.File evFile2)
          Deprecated. Method used for diagnostics.
 int fileSize()
          Deprecated. Obtain the file size using the memory mapped buffer's capacity, which should be the same.
 IBlockHeader getCurrentBlockHeader()
          Deprecated. This returns the current (active) block (physical record) header.
 int getEventCount()
          Deprecated. This is the number of events in the file.
 java.nio.MappedByteBuffer getMappedByteBuffer()
          Deprecated. Get the memory mapped buffer corresponding to the event file.
 int getNumEventsRemaining()
          Deprecated. Get the number of events remaining in the file.
 EventParser getParser()
          Deprecated. Get the file/buffer parser.
 java.lang.String getPath()
          Deprecated. Get the path to the file.
 java.lang.String getXmlDictionary()
          Deprecated. Get the xml format dictionary is there is one.
 EvioEvent gotoEventNumber(int evNumber)
          Deprecated. Go to a specific event in the file.
 boolean hasDictionary()
          Deprecated. Does this evio file have an associated dictionary?
 EvioEvent nextEvent()
          Deprecated. Get the next event in the file.
 void parseEvent(EvioEvent evioEvent)
          Deprecated. This will parse an event, SAX-like.
 EvioEvent parseNextEvent()
          Deprecated. This is the workhorse method.
 int position()
          Deprecated. This is equivalent to obtaining the current position in the file.
 void position(int position)
          Deprecated. This is equivalent to setting the current position in the file.
 void rewind()
          Deprecated. The equivalent of rewinding the file.
 void setParser(EventParser parser)
          Deprecated. Set the file/buffer parser.
 EvioFile.WriteStatus toXMLFile(java.lang.String path)
          Deprecated. Rewrite the entire file to XML.
 EvioFile.WriteStatus toXMLFile(java.lang.String path, IEvioProgressListener progressListener)
          Deprecated. Rewrite the file to XML (not including dictionary).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EvioFile

public EvioFile(java.io.File file)
         throws java.io.IOException
Deprecated. 
Creates an event file for reading.

Parameters:
file - the file that contains EVIO events.
Throws:
java.io.IOException

EvioFile

public EvioFile(java.lang.String path)
         throws java.io.IOException
Deprecated. 
Creates an event file.

Parameters:
path - the full path to the file that contains events. For writing event files, use an EventWriter object.
Throws:
java.io.IOException
See Also:
EventWriter
Method Detail

getPath

public java.lang.String getPath()
Deprecated. 
Get the path to the file.

Returns:
path to the file

getParser

public EventParser getParser()
Deprecated. 
Get the file/buffer parser.

Returns:
file/buffer parser.

setParser

public void setParser(EventParser parser)
Deprecated. 
Set the file/buffer parser.

Parameters:
parser - file/buffer parser.

getXmlDictionary

public java.lang.String getXmlDictionary()
Deprecated. 
Get the xml format dictionary is there is one.

Returns:
xml format dictionary, else null.

hasDictionary

public boolean hasDictionary()
Deprecated. 
Does this evio file have an associated dictionary?

Returns:
true if this evio file has an associated dictionary, else false

getNumEventsRemaining

public int getNumEventsRemaining()
                          throws EvioException
Deprecated. 
Get the number of events remaining in the file.

Returns:
number of events remaining in the file
Throws:
EvioException - if failed reading from coda v3 file

fileSize

public int fileSize()
Deprecated. 
Obtain the file size using the memory mapped buffer's capacity, which should be the same.

Returns:
the file size in bytes--actually the mapped memory size.

getMappedByteBuffer

public java.nio.MappedByteBuffer getMappedByteBuffer()
Deprecated. 
Get the memory mapped buffer corresponding to the event file.

Returns:
the memory mapped buffer corresponding to the event file.

nextEvent

public EvioEvent nextEvent()
                    throws EvioException
Deprecated. 
Get the next event in the file. 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.

In evio version 4, 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 versions 2 & 3 in order to read the version 4 format as it is subset of versions 1-3 with variable block length.

Returns:
the next event in the file. On error it throws an EvioException. On end of file, it returns null.
Throws:
EvioException

parseNextEvent

public EvioEvent parseNextEvent()
                         throws EvioException
Deprecated. 
This is the workhorse method. It retrieves the next event from the file, and then parses is SAX-like. It will drill down and uncover all structures (banks, segments, and tagsegments) and notify any interested listeners.

Returns:
the event that was parsed. On error it throws an EvioException. On end of file, it returns null.
Throws:
EvioException

parseEvent

public void parseEvent(EvioEvent evioEvent)
                throws EvioException
Deprecated. 
This will parse an event, SAX-like. It will drill down and uncover all structures (banks, segments, and tagsegments) and notify any interested listeners. 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 .

Parameters:
evioEvent - the event to parse.
Throws:
EvioException

rewind

public void rewind()
Deprecated. 
The equivalent of rewinding the file. What it actually does is set the position of the mapped memory buffer back to 0. This method, along with the two position and the close method, allows applications to treat this in a normal random access file manner.


position

public int position()
Deprecated. 
This is equivalent to obtaining the current position in the file. What it actually does is return the position of the mapped memory buffer. This method, along with the rewind, position(int) and the close method, allows applications to treat this in a normal random access file manner.

Returns:
the position of the file.

position

public void position(int position)
Deprecated. 
This is equivalent to setting the current position in the file. What it actually does is set the position of the mapped memory buffer. This method, along with the rewind, position() and the close method, allows applications to treat this in a normal random access file manner.

Parameters:
position - the new position of the file.

close

public void close()
Deprecated. 
This is equivalent to closing the file. What it actually does is clear all data from the mapped memory buffer, and sets its position to 0. This method, along with the rewind and the two position() methods, allows applications to treat this in a normal random access file manner.


getCurrentBlockHeader

public IBlockHeader getCurrentBlockHeader()
Deprecated. 
This returns the current (active) block (physical record) header. Since most users have no interest in physical records, this method should not be used often. Mostly it is used by the test programs in the EvioFileTest class.

Returns:
the current block header.

gotoEventNumber

public EvioEvent gotoEventNumber(int evNumber)
Deprecated. 
Go to a specific event in the file. The events are numbered 1..N. This number is transient--it is not part of the event as stored in the evio file.

Parameters:
evNumber - the event number in a 1..N counting sense, from the start of the file.
Returns:
the specified event in the file.

toXMLFile

public EvioFile.WriteStatus toXMLFile(java.lang.String path)
Deprecated. 
Rewrite the entire file to XML.

Parameters:
path - the path to the XML file.
Returns:
the status of the write.

toXMLFile

public EvioFile.WriteStatus toXMLFile(java.lang.String path,
                                      IEvioProgressListener progressListener)
Deprecated. 
Rewrite the file to XML (not including dictionary).

Parameters:
path - the path to the XML file.
progressListener - and optional progress listener, can be null.
Returns:
the status of the write.
See Also:
IEvioProgressListener

getEventCount

public int getEventCount()
                  throws EvioException
Deprecated. 
This is the number of events in the file. It is not computed unless asked for, and if asked for it is computed and cached. Any dictionary event is not included in the count.

Returns:
the number of events in the file.
Throws:
EvioException

compareEventFiles

public static boolean compareEventFiles(java.io.File evFile1,
                                        java.io.File evFile2)
Deprecated. 
Method used for diagnostics. It compares two event files. It checks the following (in order):
  1. That neither file is null.
  2. That both files exist.
  3. That neither file is a directory.
  4. That both files can be read.
  5. That both files are the same size.
  6. That both files contain the same number of events.
  7. Finally, that they are the same in a byte-by-byte comparison.
NOTE: Two files with the same events but different physical record size will be reported as different. They will fail the same size test.

Parameters:
evFile1 - first file to be compared
evFile2 - second file to be compared
Returns:
true if the files are, byte-by-byte, identical.