org.jlab.coda.jevio
Class StructureTransformer

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

public class StructureTransformer
extends java.lang.Object

This class contains methods to transform structures from one type to another, for example changing an EvioSegment into an EvioBank. Date: Oct 1, 2010

Author:
timmer

Constructor Summary
StructureTransformer()
           
 
Method Summary
static EvioSegment transform(EvioBank bank)
          Create an EvioSegment object from an EvioBank.
static EvioTagSegment transform(EvioBank bank, int dummy)
          Create an EvioTagSegment object from an EvioBank.
static EvioTagSegment transform(EvioSegment segment)
          Create an EvioTagSegment object from an EvioSegment.
static EvioBank transform(EvioSegment segment, int num)
          Create an EvioBank object from an EvioSegment.
static EvioSegment transform(EvioTagSegment tagsegment)
          Create an EvioSegment object from an EvioTagSegment.
static EvioBank transform(EvioTagSegment tagsegment, int num)
          Create an EvioBank object from an EvioTagSegment.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructureTransformer

public StructureTransformer()
Method Detail

transform

public static EvioBank transform(EvioSegment segment,
                                 int num)
Create an EvioBank object from an EvioSegment. The new object has all data copied over, except that the segment's children were are added (not deep cloned) to the bank. Because a segment has no num, the user supplies that as an arg.

Parameters:
segment - EvioSegment object to transform.
num - num of the created EvioBank.
Returns:
the created EvioBank.

transform

public static EvioBank transform(EvioTagSegment tagsegment,
                                 int num)
Create an EvioBank object from an EvioTagSegment. The new object has all data copied over, except that the tagsegment's children were are added (not deep cloned) to the bank. Because a segment has no num, the user supplies that as an arg.

NOTE: A tagsegment has no associated padding data. However, if a tagsegment is read from a file/buffer, padding info is already lost (=0), and if a tagsegment is created "by hand", the padding has already been calculated and exists in the header.

Parameters:
tagsegment - EvioTagSegment object to transform.
num - num of the created EvioBank.
Returns:
the created EvioBank.

transform

public static EvioTagSegment transform(EvioSegment segment)
Create an EvioTagSegment object from an EvioSegment. The new object has all data copied over, except that the segment's children were are added (not deep cloned) to the tagsegment.

NOTE: No data should be lost in this transformaton since even though the segment has 6 bits of data type while the tag segment has only 4, only 4 bits are needed to contain the type data. And, the segment's tag is 8 bits while the tagsegment's tag is 12 bits so no problem there.

Parameters:
segment - EvioSegment object to transform.
Returns:
the created EvioTagSegment.

transform

public static EvioSegment transform(EvioTagSegment tagsegment)
Create an EvioSegment object from an EvioTagSegment. The new object has all data copied over, except that the tagsegment's children were are added (not deep cloned) to the segment.

NOTE: A tagsegment has no associated padding data. However, if a tagsegment is read from a file/buffer, padding info is already lost (=0), and if a tagsegment is created "by hand", the padding has already been calculated and exists in the header. It is also possible that data is lost in this transformaton since the segment's tag is 8 bits while the tagsegment's tag is 12 bits. The user can override the truncation of the tagsegment's tag and simply set the created segment's tag by calling segment.getHeader().setTag(tag).

Parameters:
tagsegment - EvioTagSegment object to transform.
Returns:
the created EvioSegment.

transform

public static EvioSegment transform(EvioBank bank)
                             throws EvioException
Create an EvioSegment object from an EvioBank. The new object has all data copied over, except that the bank's children were are added (not deep cloned) to the segment.

NOTE: It is possible that data is lost in this transformaton since the segment's tag is 8 bits while the bank's tag is 16 bits. To override the truncation of the tag, simply set the created segment's tag by calling segment.getHeader().setTag(tag). It is also possible that the length of the bank (32 bits) is too big for the segment (16 bits). This condition will cause an exception.

Parameters:
bank - EvioBank object to transform.
Returns:
the created EvioSegment.
Throws:
EvioException - if the bank is too long to change into a segment

transform

public static EvioTagSegment transform(EvioBank bank,
                                       int dummy)
                                throws EvioException
Create an EvioTagSegment object from an EvioBank. The new object has all data copied over, except that the bank's children were are added (not deep cloned) to the segment.

NOTE: It is possible that data is lost in this transformaton since the tagsegment's tag is 12 bits while the bank's tag is 16 bits. To override the truncation of the tag, simply set the created tagsegment's tag by calling tagsegment.getHeader().setTag(tag). It is also possible that the length of the bank (32 bits) is too big for the tagsegment (16 bits). This condition will cause an exception.

Parameters:
bank - EvioBank object to transform.
dummy - only used to distinguish this method from transform(EvioBank).
Returns:
the created EvioTagSegment.
Throws:
EvioException - if the bank is too long to change into a tagsegment