org.jlab.coda.jevio
Class BaseStructureHeader

java.lang.Object
  extended by org.jlab.coda.jevio.BaseStructureHeader
All Implemented Interfaces:
java.lang.Cloneable, IEvioWriter
Direct Known Subclasses:
BankHeader, SegmentHeader, TagSegmentHeader

public abstract class BaseStructureHeader
extends java.lang.Object
implements java.lang.Cloneable, IEvioWriter

This the header for the base structure (BaseStructure). It does not contain the raw data, just the header. The three headers for the actual structures found in evio (BANK, SEGMENT, and TAGSEMENT) all extend this.

Author:
heddle

Constructor Summary
BaseStructureHeader()
          Null constructor.
BaseStructureHeader(int tag, DataType dataType)
          Constructor
BaseStructureHeader(int tag, DataType dataType, int num)
          Constructor
 
Method Summary
 byte byteValue(java.lang.Integer integer)
          Convenience method to return the byte value of an integer.
 java.lang.Object clone()
          Clone this object by passing responsibility to the Object class which creates a bitwise copy which is fine since all fields are ints or enums.
 DataType getDataType()
          Returns the data type for data stored in this structure as a DataType enum.
 java.lang.String getDataTypeName()
          Returns the data type as a string.
 int getDataTypeValue()
          Get the data type for the structure.
abstract  int getHeaderLength()
          Get the length of the structure's header in ints.
 int getLength()
          Get the length of the structure in ints, not counting the length word.
 int getNumber()
          Get the number.
 int getPadding()
          Get the amount of padding bytes when storing short or byte data.
 int getTag()
          Get the structure tag.
 void setDataType(DataType dataType)
          Set the numeric data type for the structure.
 void setLength(int length)
          Set the length of the structure in ints, not counting the length word.
 void setNumber(int number)
          Set the number.
 void setTag(int tag)
          Set the structure tag.
 short shortValue(java.lang.Integer integer)
          Convenience method to return the short value of an integer.
 java.lang.String toString()
          Obtain a string representation of the structure header.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jlab.coda.jevio.IEvioWriter
write
 

Constructor Detail

BaseStructureHeader

public BaseStructureHeader()
Null constructor.


BaseStructureHeader

public BaseStructureHeader(int tag,
                           DataType dataType)
Constructor

Parameters:
tag - the tag for the header.
dataType - the enum data type for the content of the structure.

BaseStructureHeader

public BaseStructureHeader(int tag,
                           DataType dataType,
                           int num)
Constructor

Parameters:
tag - the tag for the header.
dataType - the data type for the content of the structure.
num - sometimes, but not necessarily, an ordinal enumeration.
Method Detail

clone

public java.lang.Object clone()
Clone this object by passing responsibility to the Object class which creates a bitwise copy which is fine since all fields are ints or enums.

Overrides:
clone in class java.lang.Object

getNumber

public int getNumber()
Get the number. Only Banks have a number field in their header, so this is only relevant for Banks.

Returns:
the number.

setNumber

public void setNumber(int number)
Set the number. Only Banks have a number field in their header, so this is only relevant for Banks.

Parameters:
number - the number.

getDataTypeValue

public int getDataTypeValue()
Get the data type for the structure.

Returns:
the data type for the structure.

setDataType

public void setDataType(DataType dataType)
Set the numeric data type for the structure.

Parameters:
dataType - the dataTtype for the structure.

getDataType

public DataType getDataType()
Returns the data type for data stored in this structure as a DataType enum.

Returns:
the data type for data stored in this structure as a DataType enum.
See Also:
DataType

getDataTypeName

public java.lang.String getDataTypeName()
Returns the data type as a string.

Returns:
the data type as a string.

getPadding

public int getPadding()
Get the amount of padding bytes when storing short or byte data. Value is 0, 1, 2, or 3 for bytes and 0 or 2 for shorts.

Returns:

getLength

public int getLength()
Get the length of the structure in ints, not counting the length word.

Returns:
Get the length of the structure in ints (not counting the length word).

setLength

public void setLength(int length)
Set the length of the structure in ints, not counting the length word.

Parameters:
length - the length of the structure in ints, not counting the length word.

getHeaderLength

public abstract int getHeaderLength()
Get the length of the structure's header in ints. This includes the first header word itself (which contains the length) and in the case of banks, it also includes the second header word.

Returns:
Get the length of the structure's header in ints.

getTag

public int getTag()
Get the structure tag.

Returns:
the structure tag.

setTag

public void setTag(int tag)
Set the structure tag.

Parameters:
tag - the structure tag.

toString

public java.lang.String toString()
Obtain a string representation of the structure header.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of the structure header.

byteValue

public byte byteValue(java.lang.Integer integer)
Convenience method to return the byte value of an integer. Although the parameter is an Integer, use "autoboxing" to pass in a primitive. I.e., byteValue(3) works just fine.

Parameters:
integer - the integer whose byte value is needed. Can pass in a primitive int.
Returns:
the byte value of the integer.

shortValue

public short shortValue(java.lang.Integer integer)
Convenience method to return the short value of an integer. Although the parameter is an Integer, use "autoboxing" to pass in a primitive. I.e., shortValue(3345) works just fine.

Parameters:
integer - the integer whose short value is needed. Can pass in a primitive int.
Returns:
the short value of the integer.