edu.iris.Fissures.seed.builder
Class ObjectBuilder

java.lang.Object
  extended by edu.iris.Fissures.seed.builder.ObjectBuilder
Direct Known Subclasses:
SeedMMAPImportBuilder, SeedObjectBuilder

public abstract class ObjectBuilder
extends java.lang.Object

This class is the abstract representation of all builders for the SEED classes framework. The primary builder class derived from this will be for building SEED objects, but the design is being left open for other types of things to be built on the import end of things.

Version:
1/12/2010
Author:
Robert Casey, IRIS DMC

Field Summary
protected  ObjectContainer buildContainer
           
protected  java.lang.String builderType
           
protected  java.util.Vector buildFilterVector
           
protected  boolean continuationFlag
           
protected  java.lang.Object currentObject
           
protected  boolean largeCoeffFlag
           
protected  boolean recordBeginFlag
           
protected  char recordType
           
protected  int volumeNumber
           
 
Constructor Summary
ObjectBuilder()
          Create a new object builder.
 
Method Summary
abstract  int build(byte[] record)
          This is the generic build function that the caller uses to have objects constructed.
abstract  int build(java.lang.String delStr)
          Construct an object or objects from the delimited String.
 ObjectContainer getContainer()
          Return the persistent storage container to the caller.
 java.lang.Object getObject()
          Return the most recently built object to the caller.
 java.lang.String getType()
          Get Object Builder type.
 int getVolume()
          Get the volume number that this builder is currently set at.
 void incrementVolume()
          Increment the volume number when a new data stream is being read in.
 void registerFilter(BuilderFilter bf)
          Register an instantiated BuilderFilter with this builder.
 void removeCurrent()
          Delete current object from the Builder.
abstract  void reset()
          Reset the builder to its initial state.
 void setContinuationFlag(boolean flag)
          This method flags that the arriving record section is a continuation of a previous record section.
 void setLargeCoeffFlag(boolean flag)
          Set this flag to true when the current input group represents a continuation of coefficients, where the previous group ran out of characters to represent the entire dataset.
 void setRecordBeginFlag(boolean flag)
          Set this flag to true if the incoming record section originated from the beginning of a logical record.
 void setRecordType(byte recType)
          Indicate the type of record the object is being built from.
 void setVolume(int volNum)
          Set the volume number to specific starting value.
abstract  int store()
          Store object to concrete Object Container.
 java.lang.String toString()
          Display a String representation of the Builder's current object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

builderType

protected java.lang.String builderType

buildContainer

protected ObjectContainer buildContainer

currentObject

protected java.lang.Object currentObject

buildFilterVector

protected java.util.Vector buildFilterVector

recordType

protected char recordType

continuationFlag

protected boolean continuationFlag

recordBeginFlag

protected boolean recordBeginFlag

largeCoeffFlag

protected boolean largeCoeffFlag

volumeNumber

protected int volumeNumber
Constructor Detail

ObjectBuilder

public ObjectBuilder()
Create a new object builder.

Method Detail

registerFilter

public void registerFilter(BuilderFilter bf)
                    throws BuilderException
Register an instantiated BuilderFilter with this builder. The filter 'type' pertains to the format of data that the filter compares against, and must match the type of the concrete builder class. So, a SeedObjectBuilder will only accept BuilderFilters that report a filterType of "SEED".

The BuilderFilter acts as a 'request module' or 'query module' that will restrict what objects are built and stored, based on the restriction parameters contained in the registered BuilderFilter object attached to this Builder.

Because a single BuilderFilter parameter is an OR condition (such as you get a positive response for a station match if ANY ONE of the stations in the list matches), to have a list of separate, internally bound conditions (such as one station ask for long-period data, but another station ask for broadband data), each condition 'cluster' must be contained in a separate BuilderFilter.

For this reason, the registerFilter method accepts multiple builderFilters to be registered with it, each representing a separate nucleus of acceptable values all bound to each other. Simply call registerFilter multiple times, each with a different BuilderFilter instance and each will be added to a Vector. Once registered, a BuilderFilter cannot be unregistered.

Throws:
BuilderException

getType

public java.lang.String getType()
                         throws BuilderException
Get Object Builder type. This method returns the type of builder we are in the form of a unique string.

Throws:
BuilderException

getObject

public java.lang.Object getObject()
Return the most recently built object to the caller. Returns null if there is no current object available.


getContainer

public ObjectContainer getContainer()
                             throws BuilderException
Return the persistent storage container to the caller.

Throws:
BuilderException

toString

public java.lang.String toString()
Display a String representation of the Builder's current object. Once an object is built, we have the option of viewing a String of the object's contents.

Overrides:
toString in class java.lang.Object

setRecordType

public void setRecordType(byte recType)
Indicate the type of record the object is being built from. Use this method to indicate the type of data record, using a letter or digit interpretation is left to child builder class.


setContinuationFlag

public void setContinuationFlag(boolean flag)
This method flags that the arriving record section is a continuation of a previous record section. Usually happens at logical record boundaries interpretation is left to child builder class.


setRecordBeginFlag

public void setRecordBeginFlag(boolean flag)
Set this flag to true if the incoming record section originated from the beginning of a logical record. This helps to orient the builder as to where in the logical record the record section came from. Interpretation is left to concrete Builder class


setLargeCoeffFlag

public void setLargeCoeffFlag(boolean flag)
Set this flag to true when the current input group represents a continuation of coefficients, where the previous group ran out of characters to represent the entire dataset. This allows the two coefficient sets to merge into a single object.


removeCurrent

public void removeCurrent()
Delete current object from the Builder. Set's current object pointer to null.


getVolume

public int getVolume()
Get the volume number that this builder is currently set at.

Returns:
the volume number that the builder is set to

incrementVolume

public void incrementVolume()
Increment the volume number when a new data stream is being read in. Also reset state of the Builder.


setVolume

public void setVolume(int volNum)
Set the volume number to specific starting value. Generally this is just done at the start of the Builder.

Parameters:
volNum - volume number to set to

build

public abstract int build(byte[] record)
                   throws java.lang.Exception
This is the generic build function that the caller uses to have objects constructed. Returns the number of bytes consumed by the builder when reading from the record.

Throws:
java.lang.Exception

build

public abstract int build(java.lang.String delStr)
                   throws java.lang.Exception
Construct an object or objects from the delimited String. Return the length in bytes of the processed String as a confirmation of success. Return -1 on failure.

Throws:
java.lang.Exception

store

public abstract int store()
                   throws java.lang.Exception
Store object to concrete Object Container. Once an object is built, we have the option of storing it into some form of persistent container for later reference. If another build is called before the currently created object is stored, the current object is discarded. Returns an integer reflecting the object's assigned ID number, or a -1 on failure.

Throws:
java.lang.Exception

reset

public abstract void reset()
Reset the builder to its initial state. Generally used during volume transitions.