edu.iris.Fissures.seed.container
Class BlocketteFactory

java.lang.Object
  extended by edu.iris.Fissures.seed.container.BlocketteFactory

public class BlocketteFactory
extends java.lang.Object

Factory class for all Blockette objects. Not only provides the creational method for constructing Blockettes but also acts as the reference engine for all particulars about the different blockette types. This is by design a static class.

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

Constructor Summary
BlocketteFactory()
           
 
Method Summary
static Blockette createBlockette(byte[] blocketteStream, boolean swapFlag, boolean isData)
          Instructs the factory to build a Blockette object of the appropriate type based on SEED binary input.
static Blockette createBlockette(byte[] blocketteStream, boolean swapFlag, boolean isData, float version)
          Instructs the factory to build a Blockette object of the appropriate type based on SEED binary input.
static Blockette createBlockette(int blkType)
          Instructs the factory to build a BLANK Blockette object of the indicated type number using the default version.
static Blockette createBlockette(java.lang.String inputString)
          Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.
static Blockette createBlockette(java.lang.String inputString, float version)
          Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.
static Blockette createBlockette(java.lang.String inputString, java.lang.String delimiter, java.lang.String blank)
          Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.
static Blockette createBlockette(java.lang.String inputString, java.lang.String delimiter, java.lang.String blank, float version)
          Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.
static java.lang.String formatDecimal(int blkType, int fieldNum, java.lang.Object value)
          Format the string value according the the field number's mask of the specified blockette type.
static java.lang.String getBlocketteDefinition(int blkType)
          Get blockette definitions.
static byte[] getBytes(int blkType, int fieldNum, java.lang.String stringVal)
          Convert a String to SEED binary for one blockette field.
static java.lang.String getCategory(int blkType)
          Return the category (Control Header type) of the blockette type.
static float getDefaultVersion()
           
static java.lang.String getFieldLength(int blkType, int fieldNum)
          Return the length in bytes of the indicated field for the blockette type.
static java.lang.String getFieldMask(int blkType, int fieldNum)
          Return the field mask or flags for the indicated field based on the blockette type.
static java.lang.String getFieldName(int blkType, int fieldNum)
          Return the full name of the indicated field for the blockette type.
static int getFieldRepeat(int blkType, int fieldNum)
          Indicate whether this is a repeating field.
static java.lang.String getFieldType(int blkType, int fieldNum)
          Return the data type of the indicated field for the blockette type.
static java.lang.String getListValue(java.lang.String listStr, int listIndex)
           
static java.util.Vector getListVector(java.lang.String listStr)
           
static java.lang.String getName(int blkType)
          Return the full name of the blockette type
static java.lang.String getNumFields(int blkType)
          Return the number of fields String, which is a comma-separated list associating number of fields with the SEED version, for the indicated blockette type.
static int getNumFields(int blkType, float version)
          Return the number of fields in this blockette type based on the indicated SEED version.
static int getStageField(int blkType)
          get the field number that contains the response stage number for the indicated blockette type.
static java.lang.String getTranslation(int blkType, int fieldNum, java.lang.Object value)
          Return description of value at the indicated field number.
static float getVersion(int blkType)
          Return the initial SEED version of the blockette type.
static boolean isResponseBlkType(int blkType)
          return true if this is a response blockette
static void main(java.lang.String[] args)
          Test case method.
static java.lang.String setListValue(java.lang.String listStr, java.lang.String value, int listIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlocketteFactory

public BlocketteFactory()
Method Detail

createBlockette

public static Blockette createBlockette(byte[] blocketteStream,
                                        boolean swapFlag,
                                        boolean isData,
                                        float version)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on SEED binary input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(byte[] blocketteStream,
                                        boolean swapFlag,
                                        boolean isData)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on SEED binary input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(java.lang.String inputString,
                                        java.lang.String delimiter,
                                        java.lang.String blank,
                                        float version)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(java.lang.String inputString,
                                        java.lang.String delimiter,
                                        java.lang.String blank)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(java.lang.String inputString)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(java.lang.String inputString,
                                        float version)
                                 throws SeedException
Instructs the factory to build a Blockette object of the appropriate type based on tokenized String input.

Throws:
SeedException

createBlockette

public static Blockette createBlockette(int blkType)
                                 throws SeedException
Instructs the factory to build a BLANK Blockette object of the indicated type number using the default version.

Throws:
SeedException

getName

public static java.lang.String getName(int blkType)
                                throws SeedException
Return the full name of the blockette type

Throws:
SeedException

getCategory

public static java.lang.String getCategory(int blkType)
                                    throws SeedException
Return the category (Control Header type) of the blockette type.

Throws:
SeedException

getVersion

public static float getVersion(int blkType)
                        throws SeedException
Return the initial SEED version of the blockette type. This represents the version of SEED where this blockette was introduced.

Throws:
SeedException

getDefaultVersion

public static float getDefaultVersion()

getNumFields

public static java.lang.String getNumFields(int blkType)
                                     throws SeedException
Return the number of fields String, which is a comma-separated list associating number of fields with the SEED version, for the indicated blockette type.

Throws:
SeedException

getNumFields

public static int getNumFields(int blkType,
                               float version)
                        throws SeedException
Return the number of fields in this blockette type based on the indicated SEED version.

Throws:
SeedException

getFieldName

public static java.lang.String getFieldName(int blkType,
                                            int fieldNum)
                                     throws SeedException
Return the full name of the indicated field for the blockette type. Makes use of array optimization if possible.

Throws:
SeedException

getFieldType

public static java.lang.String getFieldType(int blkType,
                                            int fieldNum)
                                     throws SeedException
Return the data type of the indicated field for the blockette type. Makes use of array optimization if possible.

Throws:
SeedException

getFieldLength

public static java.lang.String getFieldLength(int blkType,
                                              int fieldNum)
                                       throws SeedException
Return the length in bytes of the indicated field for the blockette type. Makes use of array optimization if possible.

Throws:
SeedException

getFieldMask

public static java.lang.String getFieldMask(int blkType,
                                            int fieldNum)
                                     throws SeedException
Return the field mask or flags for the indicated field based on the blockette type. Makes use of array optimization if possible.

Throws:
SeedException

getFieldRepeat

public static int getFieldRepeat(int blkType,
                                 int fieldNum)
                          throws SeedException
Indicate whether this is a repeating field. If the indicated field is a repeating field, it will have a non-zero value that lists the field number that indicates the number of times this field repeats. Otherwise the value is zero for non-repeating fields. Makes use of array optimization if possible.

Throws:
SeedException

getStageField

public static int getStageField(int blkType)
                         throws SeedException
get the field number that contains the response stage number for the indicated blockette type. for registered response blockettes, a non-zero field number will be returned. for everything else, a -1 will be returned, indicating that a stage number is not present.

Throws:
SeedException

isResponseBlkType

public static boolean isResponseBlkType(int blkType)
                                 throws SeedException
return true if this is a response blockette

Throws:
SeedException

formatDecimal

public static java.lang.String formatDecimal(int blkType,
                                             int fieldNum,
                                             java.lang.Object value)
                                      throws SeedException
Format the string value according the the field number's mask of the specified blockette type. The formatting will ensure that it is SEED compliant. This method is intended only for numeric fields but will pass alphanumeric fields safely through.

Throws:
SeedException

getBytes

public static byte[] getBytes(int blkType,
                              int fieldNum,
                              java.lang.String stringVal)
                       throws SeedException
Convert a String to SEED binary for one blockette field. Take the value in stringVal and return a byte array properly sized and formatted for the indicated blockette type and field number.

Throws:
SeedException

getListVector

public static java.util.Vector getListVector(java.lang.String listStr)

getListValue

public static java.lang.String getListValue(java.lang.String listStr,
                                            int listIndex)

setListValue

public static java.lang.String setListValue(java.lang.String listStr,
                                            java.lang.String value,
                                            int listIndex)

getBlocketteDefinition

public static java.lang.String getBlocketteDefinition(int blkType)
                                               throws SeedException
Get blockette definitions. All information is provided as a set of static String returns in a rudimentary selection branch so that no time is wasted loading data, since this is a statically invoked class...the data is effectively bound with the code. The first record is the general blockette definition, followed by subsequent records detailing each blockette field. Each record is separated by a newline character and the columns of each record are tab-separated. The Number Fields column is a specially formatted string of the form a0=b0,a1=b1,... where (a) is the SEED version and (b) is the number of fields available at that version. Newer versions always append fields to the end of the blockette. The first version number (a0) always represents the initial version of the blockette. This method is kept public so that applications have the option of dumping the entire definition outward for their own purposes, such as some form of documentation.

Throws:
SeedException

getTranslation

public static java.lang.String getTranslation(int blkType,
                                              int fieldNum,
                                              java.lang.Object value)
Return description of value at the indicated field number. Sometimes fields will have special values that have a more descriptive meaning attached to them...if such an interpretation is present, return the string describing the meaning of the value provided. For multiple flags, each interpretation is shown on a separate line, newline separated.


main

public static void main(java.lang.String[] args)
Test case method.