org.jlab.coda.jevio
Interface IBlockHeader

All Known Implementing Classes:
BlockHeaderV2, BlockHeaderV4

public interface IBlockHeader

Make a common interface for different versions of the BlockHeader.

Author:
timmer

Field Summary
static int MAGIC_NUMBER
          The magic number, should be the value of magicNumber.
 
Method Summary
 int bytesRemaining(int position)
          Gives the bytes remaining in this block (physical record) given a buffer position.
 int firstEventStartingPosition()
          Determines where the start of the first event (logical record) in this block (physical record) is located (in bytes).
 int getBufferEndingPosition()
          Get the position in the buffer (in bytes) of this block's last data word.
 int getBufferStartingPosition()
          Get the starting position in the buffer (in bytes) from which this header was read--if that happened.
This is not part of the block header proper.
 int getHeaderLength()
          Get the block header length, in ints.
 int getMagicNumber()
          Get the magic number the block (physical record) header which should be 0xc0da0100.
 int getNumber()
          Get the block number for this block (physical record).
 int getSize()
          Get the size of the block (physical record).
 int getVersion()
          Get the evio version of the block (physical record) header.
 boolean hasDictionary()
          Is this block's first event is an evio dictionary?
 boolean isLastBlock()
          Is this the last block in the file or being sent over the network?
 int nextBufferStartingPosition()
          Determines where the start of the next block (physical record) header in some buffer is located (in bytes).
 void setBufferStartingPosition(int bufferStartingPosition)
          Set the starting position in the buffer (in bytes) from which this header was read--if that happened.
This is not part of the block header proper.
 java.lang.String toString()
          Obtain a string representation of the block (physical record) header.
 int write(java.nio.ByteBuffer byteBuffer)
          Write myself out a byte buffer.
 

Field Detail

MAGIC_NUMBER

static final int MAGIC_NUMBER
The magic number, should be the value of magicNumber.

See Also:
Constant Field Values
Method Detail

getSize

int getSize()
Get the size of the block (physical record).

Returns:
the size of the block (physical record) in ints.

getNumber

int getNumber()
Get the block number for this block (physical record). In a file, this is usually sequential.

Returns:
the block number for this block (physical record).

getHeaderLength

int getHeaderLength()
Get the block header length, in ints. This should be 8.

Returns:
the block header length. This should be 8.

getVersion

int getVersion()
Get the evio version of the block (physical record) header.

Returns:
the evio version of the block (physical record) header.

getMagicNumber

int getMagicNumber()
Get the magic number the block (physical record) header which should be 0xc0da0100.

Returns:
the magic number in the block (physical record).

getBufferEndingPosition

int getBufferEndingPosition()
Get the position in the buffer (in bytes) of this block's last data word.

Returns:
the position in the buffer (in bytes) of this block's last data word.

getBufferStartingPosition

int getBufferStartingPosition()
Get the starting position in the buffer (in bytes) from which this header was read--if that happened.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (physical record). It is kept for convenience. It is up to the reader to set it.

Returns:
the starting position in the buffer (in bytes) from which this header was read--if that happened.

setBufferStartingPosition

void setBufferStartingPosition(int bufferStartingPosition)
Set the starting position in the buffer (in bytes) from which this header was read--if that happened.
This is not part of the block header proper. It is a position in a memory buffer of the start of the block (physical record). It is kept for convenience. It is up to the reader to set it.

Parameters:
bufferStartingPosition - the starting position in the buffer from which this header was read--if that happened.

nextBufferStartingPosition

int nextBufferStartingPosition()
Determines where the start of the next block (physical record) header in some buffer is located (in bytes). This assumes the start position has been maintained by the object performing the buffer read.

Returns:
the start of the next block (physical record) header in some buffer is located (in bytes).

firstEventStartingPosition

int firstEventStartingPosition()
Determines where the start of the first event (logical record) in this block (physical record) is located (in bytes). This assumes the start position has been maintained by the object performing the buffer read.

Returns:
where the start of the first event (logical record) in this block (physical record) is located (in bytes). Returns 0 if start is 0, signaling that this entire physical record is part of a logical record that spans at least three physical records.

bytesRemaining

int bytesRemaining(int position)
                   throws EvioException
Gives the bytes remaining in this block (physical record) given a buffer position. The position is an absolute position in a byte buffer. This assumes that the absolute position in bufferStartingPosition is being maintained properly by the reader.

Parameters:
position - the absolute current position is a byte buffer.
Returns:
the number of bytes remaining in this block (physical record.)
Throws:
EvioException

hasDictionary

boolean hasDictionary()
Is this block's first event is an evio dictionary?

Returns:
true if this block's first event is an evio dictionary, else false

isLastBlock

boolean isLastBlock()
Is this the last block in the file or being sent over the network?

Returns:
true if this is the last block in the file or being sent over the network, else false

write

int write(java.nio.ByteBuffer byteBuffer)
Write myself out a byte buffer. This write is relative--i.e., it uses the current position of the buffer.

Parameters:
byteBuffer - the byteBuffer to write to.
Returns:
the number of bytes written, which for a BlockHeader is 32.

toString

java.lang.String toString()
Obtain a string representation of the block (physical record) header.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the block (physical record) header.