org.jlab.coda.jevio
Class EventBuilder

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

public class EventBuilder
extends java.lang.Object

This class is used for creating and manipulating events. One constructor is convenient for creating new events while another is useful for manipulating existing events. You can create a new EventBuilder for each event being handled, However, in many cases one can use the same EventBuilder for all events by calling the setEvent method. The only reason a singleton pattern was not used was to allow for the possibility that events will be built or manipulated on multiple threads.

Author:
heddle

Constructor Summary
EventBuilder(EvioEvent event)
          This is the constructor to use when you want to manipulate an existing event.
EventBuilder(int tag, DataType dataType, int num)
          This is the constructor to use for an EventBuilder object that will operate on a new, empty event.
 
Method Summary
 void addChild(BaseStructure parent, BaseStructure child)
          Add a child to a parent structure.
 void appendByteData(BaseStructure structure, byte[] data)
          Appends byte data to the structure.
 void appendCharData(BaseStructure structure, char[] data)
          Appends char data to the structure.
 void appendDoubleData(BaseStructure structure, double[] data)
          Appends double data to the structure.
 void appendFloatData(BaseStructure structure, float[] data)
          Appends float data to the structure.
 void appendIntData(BaseStructure structure, int[] data)
          Appends int data to the structure.
 void appendLongData(BaseStructure structure, long[] data)
          Appends long data to the structure.
 void appendShortData(BaseStructure structure, short[] data)
          Appends short data to the structure.
 void clearData(BaseStructure structure)
          This clears all the data fields in a structure, but not the parent or the children.
 EvioEvent getEvent()
          Get the underlying event.
static void main(java.lang.String[] args)
          Main program for testing.
 void remove(BaseStructure child)
          This removes a structure (and all its descendants) from the tree.
 void setAllHeaderLengths()
          This goes through the event recursively, and makes sure all the length fields in the headers are properly set.
 void setEvent(EvioEvent event)
          Set the underlying event.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventBuilder

public EventBuilder(int tag,
                    DataType dataType,
                    int num)
This is the constructor to use for an EventBuilder object that will operate on a new, empty event.

Parameters:
tag - the tag for the event header (which is just a bank header).
dataType - the data type for the event object--which again is just the type for the outer most bank. Often an event is a bank of banks, so typically this will be DataType.BANK, or 0xe (14).
num - often an ordinal enumeration.

EventBuilder

public EventBuilder(EvioEvent event)
This is the constructor to use when you want to manipulate an existing event.

Parameters:
event - the event to manipulate.
Method Detail

setAllHeaderLengths

public void setAllHeaderLengths()
This goes through the event recursively, and makes sure all the length fields in the headers are properly set.


clearData

public void clearData(BaseStructure structure)
This clears all the data fields in a structure, but not the parent or the children. This keeps the existing tree structure intact. To remove a structure (and, consequently, all its descendants) from the tree, use remove

Parameters:
structure - the segment to clear.

addChild

public void addChild(BaseStructure parent,
                     BaseStructure child)
              throws EvioException
Add a child to a parent structure.

Parameters:
parent - the parent structure.
child - the child structure.
Throws:
EvioException

remove

public void remove(BaseStructure child)
            throws EvioException
This removes a structure (and all its descendants) from the tree.

Parameters:
child - the child structure to remove.
Throws:
EvioException

appendIntData

public void appendIntData(BaseStructure structure,
                          int[] data)
                   throws EvioException
Appends int data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the int data to append, or set if there is no existing data.
Throws:
EvioException

appendShortData

public void appendShortData(BaseStructure structure,
                            short[] data)
                     throws EvioException
Appends short data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the short data to append, or set if there is no existing data.
Throws:
EvioException

appendLongData

public void appendLongData(BaseStructure structure,
                           long[] data)
                    throws EvioException
Appends long data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the long data to append, or set if there is no existing data.
Throws:
EvioException

appendByteData

public void appendByteData(BaseStructure structure,
                           byte[] data)
                    throws EvioException
Appends byte data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the byte data to append, or set if there is no existing data.
Throws:
EvioException

appendFloatData

public void appendFloatData(BaseStructure structure,
                            float[] data)
                     throws EvioException
Appends float data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the float data to append, or set if there is no existing data.
Throws:
EvioException

appendCharData

public void appendCharData(BaseStructure structure,
                           char[] data)
                    throws EvioException
Appends char data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the char data to append, or set if there is no existing data.
Throws:
EvioException

appendDoubleData

public void appendDoubleData(BaseStructure structure,
                             double[] data)
                      throws EvioException
Appends double data to the structure. If the structure has no data, then this is the same as setting the data.

Parameters:
structure - the structure to receive the data, which is appended.
data - the double data to append, or set if there is no existing data.
Throws:
EvioException

getEvent

public EvioEvent getEvent()
Get the underlying event.

Returns:
the underlying event.

setEvent

public void setEvent(EvioEvent event)
Set the underlying event. As far as this event builder is concerned, the previous underlying event is lost, and all subsequent calls will affect the newly supplied event. param the new underlying event.


main

public static void main(java.lang.String[] args)
Main program for testing.

Parameters:
args - ignored command line arguments.