|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jlab.coda.jevio.EventWriter
public class EventWriter
An EventWriter object is used for writing events to a file or to a byte buffer. This class does NOT write versions 1-3 data, only version 4! This class is threadsafe.
Nested Class Summary | |
---|---|
static class |
EventWriter.IOStatus
This enum denotes the status of a read. |
Constructor Summary | |
---|---|
EventWriter(java.nio.ByteBuffer buf)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.nio.ByteBuffer buf,
boolean append)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.nio.ByteBuffer buf,
int blockSizeMax,
int blockCountMax,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.nio.ByteBuffer buf,
int blockSizeMax,
int blockCountMax,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo,
boolean append)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.nio.ByteBuffer buf,
int blockSizeMax,
int blockCountMax,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo,
int reserved1)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.nio.ByteBuffer buf,
java.lang.String xmlDictionary,
boolean append)
Create an EventWriter for writing events to a ByteBuffer. |
|
EventWriter(java.io.File file)
Creates an EventWriter for writing to a file in native byte order. |
|
EventWriter(java.io.File file,
boolean append)
Creates an EventWriter for writing to a file in native byte order. |
|
EventWriter(java.io.File file,
int blockSizeMax,
int blockCountMax,
java.nio.ByteOrder byteOrder,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo)
Create an EventWriter for writing events to a file. |
|
EventWriter(java.io.File file,
int blockSizeMax,
int blockCountMax,
java.nio.ByteOrder byteOrder,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo,
boolean overWriteOK)
Create an EventWriter for writing events to a file. |
|
EventWriter(java.io.File file,
int blockSizeMax,
int blockCountMax,
java.nio.ByteOrder byteOrder,
java.lang.String xmlDictionary,
java.util.BitSet bitInfo,
boolean overWriteOK,
boolean append)
Create an EventWriter for writing events to a file. |
|
EventWriter(java.io.File file,
java.lang.String dictionary,
boolean append)
Creates an EventWriter for writing to a file in native byte order. |
|
EventWriter(java.lang.String filename)
Creates an EventWriter for writing to a file in native byte order. |
|
EventWriter(java.lang.String filename,
boolean append)
Creates an EventWriter for writing to a file in native byte order. |
|
EventWriter(java.lang.String filename,
boolean append,
java.nio.ByteOrder byteOrder)
Creates an EventWriter for writing to a file in the
specified byte order. |
Method Summary | |
---|---|
void |
close()
If writing to a file, flush events waiting to be written, close the underlying data output stream and with it the file. |
int |
getBlockNumber()
Get the current block number. |
java.nio.ByteBuffer |
getBuffer()
Get the buffer being written into. |
int |
getEventsWritten()
Get the number of events written to a file/buffer. |
static void |
main(java.lang.String[] args)
Main program for testing. |
static void |
mainOrig(java.lang.String[] args)
Main program for testing. |
void |
setBuffer(java.nio.ByteBuffer buf)
Set the buffer being written into (initially set in constructor). |
void |
setStartingBlockNumber(int startingBlockNumber)
Set the number with which to start block numbers. |
void |
writeEvent(EvioBank bank)
Write an event (bank) to the file in evio version 4 format in blocks. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EventWriter(java.io.File file) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten.
If it doesn't exist, it will be created.
file
- the file object to write to.EvioException
- block size too small or file cannot be createdpublic EventWriter(java.io.File file, boolean append) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten unless
it is being appended to. If it doesn't exist, it will be created.
file
- the file object to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.
EvioException
- block size too small or file cannot be createdpublic EventWriter(java.io.File file, java.lang.String dictionary, boolean append) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten unless
it is being appended to. If it doesn't exist, it will be created.
file
- the file object to write to.dictionary
- dictionary in xml format or null if none.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.
EvioException
- block size too small or file cannot be createdpublic EventWriter(java.lang.String filename) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten.
If it doesn't exist, it will be created.
filename
- name of the file to write to.EvioException
- block size too small or file cannot be createdpublic EventWriter(java.lang.String filename, boolean append) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten unless
it is being appended to. If it doesn't exist, it will be created.
filename
- name of the file to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.
EvioException
- block size too small or file cannot be createdpublic EventWriter(java.lang.String filename, boolean append, java.nio.ByteOrder byteOrder) throws EvioException
EventWriter
for writing to a file in the
specified byte order.
If the file already exists, its contents will be overwritten unless
it is being appended to. If it doesn't exist, it will be created.
filename
- name of the file to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.byteOrder
- the byte order in which to write the file.
EvioException
- block size too small or file cannot be createdpublic EventWriter(java.io.File file, int blockSizeMax, int blockCountMax, java.nio.ByteOrder byteOrder, java.lang.String xmlDictionary, java.util.BitSet bitInfo) throws EvioException
EventWriter
for writing events to a file.
If the file already exists, its contents will be overwritten.
If it doesn't exist, it will be created.
file
- the file object to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.byteOrder
- the byte order in which to write the file.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.
EvioException
- block size too small or file cannot be createdpublic EventWriter(java.io.File file, int blockSizeMax, int blockCountMax, java.nio.ByteOrder byteOrder, java.lang.String xmlDictionary, java.util.BitSet bitInfo, boolean overWriteOK) throws EvioException
EventWriter
for writing events to a file.
If the file already exists, its contents will be overwritten
unless the "overWriteOK" argument is false
in
which case an exception will be thrown. If it doesn't exist,
it will be created.
file
- the file to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.byteOrder
- the byte order in which to write the file.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.overWriteOK
- if false
and the file already exists,
an exception is thrown rather than overwriting it.
EvioException
- block size too small, file exists and cannot be deleted,
file exists and user requested no deletion.public EventWriter(java.io.File file, int blockSizeMax, int blockCountMax, java.nio.ByteOrder byteOrder, java.lang.String xmlDictionary, java.util.BitSet bitInfo, boolean overWriteOK, boolean append) throws EvioException
EventWriter
for writing events to a file.
If the file already exists, its contents will be overwritten
unless the "overWriteOK" argument is false
in
which case an exception will be thrown. Unless ..., the option to
append these events to an existing file is true
,
in which case everything is fine. If the file doesn't exist,
it will be created. Byte order defaults to big endian if arg is null.
file
- the file to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.byteOrder
- the byte order in which to write the file. This is ignored
if appending to existing file.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.overWriteOK
- if false
and the file already exists,
an exception is thrown rather than overwriting it.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.
EvioException
- if blockSizeMax or blockCountMax exceed limits;
if defined dictionary while appending;
if file arg is null;
if file could not be opened or positioned;
if file exists but user requested no over-writing or appending.public EventWriter(java.nio.ByteBuffer buf) throws EvioException
EventWriter
for writing events to a ByteBuffer.
Uses the default number and size of blocks in buffer. Will overwrite
any existing data in buffer!
buf
- the buffer to write to.
EvioException
- if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, boolean append) throws EvioException
EventWriter
for writing events to a ByteBuffer.
Uses the default number and size of blocks in buffer.
buf
- the buffer to write to.append
- if true
, all events to be written will be
appended to the end of the buffer.
EvioException
- if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, java.lang.String xmlDictionary, boolean append) throws EvioException
EventWriter
for writing events to a ByteBuffer.
Uses the default number and size of blocks in buffer.
buf
- the buffer to write to.xmlDictionary
- dictionary in xml format or null if none.append
- if true
, all events to be written will be
appended to the end of the buffer.
EvioException
- if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, int blockSizeMax, int blockCountMax, java.lang.String xmlDictionary, java.util.BitSet bitInfo) throws EvioException
EventWriter
for writing events to a ByteBuffer.
buf
- the buffer to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.
EvioException
- if blockSizeMax or blockCountMax exceed limits; if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, int blockSizeMax, int blockCountMax, java.lang.String xmlDictionary, java.util.BitSet bitInfo, boolean append) throws EvioException
EventWriter
for writing events to a ByteBuffer.
buf
- the buffer to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.append
- if true
, all events to be written will be
appended to the end of the buffer.
EvioException
- if blockSizeMax or blockCountMax exceed limits;
if buf arg is null;
if defined dictionary while appending;public EventWriter(java.nio.ByteBuffer buf, int blockSizeMax, int blockCountMax, java.lang.String xmlDictionary, java.util.BitSet bitInfo, int reserved1) throws EvioException
EventWriter
for writing events to a ByteBuffer.
buf
- the buffer to write to.blockSizeMax
- the max blocksize to use which must be >= MIN_BLOCK_SIZE
and <= MAX_BLOCK_SIZE
ints.
The size of the block will not be larger than this size
unless a single event itself is larger.blockCountMax
- the max number of events in a single block which must be
>= MIN_BLOCK_COUNT
and <= MAX_BLOCK_COUNT
.xmlDictionary
- dictionary in xml format or null if none.bitInfo
- set of bits to include in first block header.reserved1
- set the value of the first "reserved" int in first block header.
NOTE: only CODA (i.e. EMU) software should use this.
EvioException
- if blockSizeMax or blockCountMax exceed limits; if buf arg is nullMethod Detail |
---|
public void setBuffer(java.nio.ByteBuffer buf) throws EvioException
Do not use this method unless you know what you are doing.
buf
- the buffer to write to.
EvioException
- if this object was not closed prior to resetting the buffer,
or buffer arg is null.public java.nio.ByteBuffer getBuffer()
public int getBlockNumber()
public int getEventsWritten()
public void setStartingBlockNumber(int startingBlockNumber)
startingBlockNumber
- the number with which to start block numbers.public void close() throws EvioException, java.io.IOException
setBuffer(java.nio.ByteBuffer)
can be called after this method to reset and reopen this object.
java.io.IOException
- if error writing to file
EvioException
- if writing to buffer and not enough spacepublic void writeEvent(EvioBank bank) throws EvioException, java.io.IOException
bank
- the bank to write.
java.io.IOException
- error writing to file
EvioException
- if bank arg is null or not enough room in bufferpublic static void mainOrig(java.lang.String[] args)
args
- ignored command line arguments.public static void main(java.lang.String[] args)
args
- ignored command line arguments.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |