edu.iris.Fissures.seed.builder
Class BasicExportBuilder

java.lang.Object
  extended by edu.iris.Fissures.seed.builder.ExportBuilder
      extended by edu.iris.Fissures.seed.builder.BasicExportBuilder
Direct Known Subclasses:
AhExportBuilder, CssExportBuilder

public class BasicExportBuilder
extends ExportBuilder


Nested Class Summary
protected static class BasicExportBuilder.ChannelInfo
          Store channel info for export.
protected static class BasicExportBuilder.ComplexNumber
           
protected  class BasicExportBuilder.DataInfo
          Data info for export.
protected static class BasicExportBuilder.EventInfo
          Store optional event info for export.
protected static class BasicExportBuilder.ResponseInfo
          Store optional response info for export.
protected static class BasicExportBuilder.StationInfo
          Store station info for Export.
 
Nested classes/interfaces inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
ExportBuilder.LogicalRecord
 
Field Summary
protected  BasicExportBuilder.ChannelInfo currentChannel
           
protected  BasicExportBuilder.StationInfo currentStation
           
static java.lang.String EMPTY_TEXT
          Empty text.
protected  BasicExportBuilder.EventInfo eventInfo
           
protected  boolean padFlag
           
protected  java.util.List stationList
           
static double TWO_PI
           
static java.lang.Double ZERO_NUMBER
          Zero number.
 
Fields inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
builderType, endOfGroup, endOfLogical, endOfPhysical, exportMold, exportScript, logicalPerPhysical, logicalRecord, logicalRecordCount, logicalRecordLength, logicalRecords, nestingDepth, nestingScore, outputStream, padEnabledFlag, penDown, physicalRecordLength, recordPadding, scriptCursor, scriptNesting, vaxOrder
 
Constructor Summary
  BasicExportBuilder()
          Create a basic export builder.
protected BasicExportBuilder(boolean padFlag, java.lang.String scriptString)
          Create a basic export builder.
 
Method Summary
static java.lang.Number blkGetNumber(Blockette blk, int fieldNum)
          Gets the number value from the Blockette.
static java.lang.Number blkGetNumber(Blockette blk, int fieldNum, int fieldIndex)
          Gets the number value from the Blockette.
static java.lang.Number blkGetNumber(Blockette blk, int fieldNum, int fieldIndex, java.lang.Number defaultValue)
          Gets the number value from the Blockette.
static java.lang.String blkGetString(Blockette blk, int fieldNum)
          Gets the string value from the Blockette.
static java.lang.String blkGetString(Blockette blk, int fieldNum, int fieldIndex)
          Gets the string value from the Blockette.
static Btime blkGetTime(Blockette blk, int fieldNum)
          Gets the time value from the Blockette.
static Btime blkGetTime(Blockette blk, int fieldNum, int fieldIndex)
          Gets the time value from the Blockette.
protected  boolean checkTrigger(java.lang.String s)
          Check provided string from export script to see if it's meant to trigger a special action.
protected  void clearDataInfo()
          Clears the data info.
static java.lang.Double convertNumber(java.lang.Number n)
          Convert Type B (Hz) to Type A (rad/sec).
protected  Blockette find_type_32(java.lang.String source_lookup_code)
          Find blockette type 32.
protected  Blockette find_type_33(java.lang.String instrument_code)
          Find blockette type 33.
protected  Blockette find_type_34(java.lang.String signal_units_code)
          Find blockette type 34.
protected  BasicExportBuilder.ChannelInfo findChannelInfo(BasicExportBuilder.DataInfo dataInfo, BasicExportBuilder.StationInfo stationInfo)
          Gets the channel information for the data.
protected  BasicExportBuilder.StationInfo findStationInfo(BasicExportBuilder.DataInfo dataInfo)
          Gets the station information for the data.
protected  BasicExportBuilder.DataInfo getDataInfo(int index)
          Gets the data information for the specified index.
static Btime getEndTime(Btime startTime, int numSamples, int srFactor, int srMult)
          Get the end time (as a Btime object).
static Btime getEndTime(Btime startTime, java.lang.Number numSamples, java.lang.Number srFactor, java.lang.Number srMult)
          Get the end time (as a Btime object).
protected  float[] getFloatData()
          Get the waveform data as floating point values.
protected  int[] getIntegerData()
          Get the waveform data as integer values.
protected  void initExportScript(java.lang.String scriptString)
          Initializes the export script array from the script string.
protected  void output_info()
          Output the information.
protected  void packToRecord()
          Pack (append) a byte array into a logical record.
protected  void packToRecord(Blockette blk)
          Pack (append) a byte array into a logical record.
protected  void padLogical()
          Pad the end of a logical record with recordPadding bytes.
protected  void padPhysical()
          Pad the end of a physical record with recordPadding bytes.
protected  void startNewLogical(SeedObject obj, boolean continuation)
          Create a new logical record and place it in the logicalRecord instance variable SeedObject is an object to be put into the new logical record, which can help to identify the traits that that logical record will have.
protected  void volumeFinish()
          Finish up volume export operations.
 
Methods inherited from class edu.iris.Fissures.seed.builder.ExportBuilder
build, close, finish, getNext, getType, isPaddingEnabled, open, push, setLogicalRecLen, setPaddingEnabled, setPhysicalRecLen, setVaxOrder, startVolume, writeRecord
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

padFlag

protected final boolean padFlag

ZERO_NUMBER

public static java.lang.Double ZERO_NUMBER
Zero number.


EMPTY_TEXT

public static java.lang.String EMPTY_TEXT
Empty text.


TWO_PI

public static final double TWO_PI
See Also:
Constant Field Values

stationList

protected java.util.List stationList

currentStation

protected BasicExportBuilder.StationInfo currentStation

currentChannel

protected BasicExportBuilder.ChannelInfo currentChannel

eventInfo

protected BasicExportBuilder.EventInfo eventInfo
Constructor Detail

BasicExportBuilder

public BasicExportBuilder()
Create a basic export builder.


BasicExportBuilder

protected BasicExportBuilder(boolean padFlag,
                             java.lang.String scriptString)
Create a basic export builder.

Parameters:
padFlag - true to pad, false otherwise.
scriptString - the script string.
See Also:
getNext
Method Detail

blkGetNumber

public static java.lang.Number blkGetNumber(Blockette blk,
                                            int fieldNum)
Gets the number value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
Returns:
the number value or 0 if error.

blkGetNumber

public static java.lang.Number blkGetNumber(Blockette blk,
                                            int fieldNum,
                                            int fieldIndex)
Gets the number value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
fieldIndex - the field index or 0 if none.
Returns:
the number value or 0 if error.

blkGetNumber

public static java.lang.Number blkGetNumber(Blockette blk,
                                            int fieldNum,
                                            int fieldIndex,
                                            java.lang.Number defaultValue)
Gets the number value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
fieldIndex - the field index or 0 if none.
defaultValue - the default value to use for error.
Returns:
the number value or the default value if error.

blkGetString

public static java.lang.String blkGetString(Blockette blk,
                                            int fieldNum)
Gets the string value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
Returns:
the string value.

blkGetString

public static java.lang.String blkGetString(Blockette blk,
                                            int fieldNum,
                                            int fieldIndex)
Gets the string value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
fieldIndex - the field index or 0 if none.
Returns:
the string value.

blkGetTime

public static Btime blkGetTime(Blockette blk,
                               int fieldNum)
                        throws java.lang.Exception
Gets the time value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
Returns:
the time value.
Throws:
java.lang.Exception - if error.

blkGetTime

public static Btime blkGetTime(Blockette blk,
                               int fieldNum,
                               int fieldIndex)
                        throws java.lang.Exception
Gets the time value from the Blockette.

Parameters:
blk - the Blockette.
fieldNum - the field number.
fieldIndex - the field index or 0 if none.
Returns:
the time value.
Throws:
java.lang.Exception - if error.

convertNumber

public static java.lang.Double convertNumber(java.lang.Number n)
Convert Type B (Hz) to Type A (rad/sec).

Parameters:
n - the Type B (Hz) number.
Returns:
the Type A (rad/sec) number.

getEndTime

public static Btime getEndTime(Btime startTime,
                               java.lang.Number numSamples,
                               java.lang.Number srFactor,
                               java.lang.Number srMult)
                        throws java.lang.Exception
Get the end time (as a Btime object). Projected from the start time based on the number of samples and the calculated sample rate.

Parameters:
startTime - the start time.
numSamples - the number of samples.
srFactor - sample rate factor.
srMult - sample rate multiplier.
Returns:
the end time.
Throws:
java.lang.Exception - if error.

getEndTime

public static Btime getEndTime(Btime startTime,
                               int numSamples,
                               int srFactor,
                               int srMult)
                        throws java.lang.Exception
Get the end time (as a Btime object). Projected from the start time based on the number of samples and the calculated sample rate.

Parameters:
startTime - the start time.
numSamples - the number of samples.
srFactor - sample rate factor.
srMult - sample rate multiplier.
Returns:
the end time.
Throws:
java.lang.Exception - if error.

find_type_32

protected Blockette find_type_32(java.lang.String source_lookup_code)
Find blockette type 32.

Parameters:
source_lookup_code - the source lookup code.
Returns:
the Blockette.

find_type_33

protected Blockette find_type_33(java.lang.String instrument_code)
Find blockette type 33.

Parameters:
instrument_code - the instrument code.
Returns:
the Blockette.

find_type_34

protected Blockette find_type_34(java.lang.String signal_units_code)
Find blockette type 34.

Parameters:
signal_units_code - the signal units code.
Returns:
the Blockette.

initExportScript

protected final void initExportScript(java.lang.String scriptString)
Initializes the export script array from the script string.

Parameters:
scriptString - the script string.
See Also:
getNext

padLogical

protected void padLogical()
Pad the end of a logical record with recordPadding bytes. Shift the logical record position to equal logicalRecordLength. Push the logical record onto the vector and clear the current register.

Overrides:
padLogical in class ExportBuilder

padPhysical

protected void padPhysical()
                    throws java.lang.Exception
Pad the end of a physical record with recordPadding bytes. Push the latest partial logical record onto the logical records vector and pad it. Generate extra empty logical records if necessary.

Overrides:
padPhysical in class ExportBuilder
Throws:
java.lang.Exception - if error.

packToRecord

protected void packToRecord()
                     throws java.lang.Exception
Pack (append) a byte array into a logical record. Use objects from the exportMold as the data source. If the current logical record is full, append the current one to the logicalRecords vector and start a new one. This method knows how to properly start, preface, and finish a complete logical record.

Specified by:
packToRecord in class ExportBuilder
Throws:
java.lang.Exception - if error.

packToRecord

protected void packToRecord(Blockette blk)
                     throws java.lang.Exception
Pack (append) a byte array into a logical record.

Parameters:
blk - the blockette.
Throws:
java.lang.Exception - if error.

clearDataInfo

protected void clearDataInfo()
Clears the data info.


getDataInfo

protected BasicExportBuilder.DataInfo getDataInfo(int index)
Gets the data information for the specified index.

Parameters:
index - the index.
Returns:
the DataInfo or null if none.

getFloatData

protected float[] getFloatData()
Get the waveform data as floating point values.

Returns:
the waveform data as floating point values.

getIntegerData

protected int[] getIntegerData()
Get the waveform data as integer values.

Returns:
the waveform data as integer values.

checkTrigger

protected boolean checkTrigger(java.lang.String s)
                        throws java.lang.Exception
Check provided string from export script to see if it's meant to trigger a special action. If so, implement the intended action.

Specified by:
checkTrigger in class ExportBuilder
Parameters:
s - the string.
Returns:
true if the string is a trigger.
Throws:
java.lang.Exception - if error.

volumeFinish

protected void volumeFinish()
                     throws BuilderException
Finish up volume export operations.

Specified by:
volumeFinish in class ExportBuilder
Throws:
BuilderException - if error.

output_info

protected void output_info()
Output the information.


startNewLogical

protected void startNewLogical(SeedObject obj,
                               boolean continuation)
                        throws java.lang.Exception
Create a new logical record and place it in the logicalRecord instance variable SeedObject is an object to be put into the new logical record, which can help to identify the traits that that logical record will have.

Specified by:
startNewLogical in class ExportBuilder
Parameters:
obj - the SEED object.
continuation - true if continuation, false otherwise. If SeedObject is null, this implies that a blank logical record is being created. continuation, when set to true, can mark the logical record as a continuation of the last one.
Throws:
java.lang.Exception - if error.

findChannelInfo

protected BasicExportBuilder.ChannelInfo findChannelInfo(BasicExportBuilder.DataInfo dataInfo,
                                                         BasicExportBuilder.StationInfo stationInfo)
Gets the channel information for the data.

Parameters:
dataInfo - the data information.
stationInfo - the station information.
Returns:
the channel information.

findStationInfo

protected BasicExportBuilder.StationInfo findStationInfo(BasicExportBuilder.DataInfo dataInfo)
Gets the station information for the data.

Parameters:
dataInfo - the data information.
Returns:
the station information.