com.bbn.openmap.layer.vpf
Class DcwColumnInfo

java.lang.Object
  extended by com.bbn.openmap.layer.vpf.DcwColumnInfo

public class DcwColumnInfo
extends java.lang.Object

Encapsulate the information about a particular column in a vpf table. This class can read both VPF V1 (MIL-STD-600006, dated 1992) and VPF V2 (MIL-STD-2407, dated 1996, supercedes V1)


Field Summary
static char VPF_COLUMN_DATE
           
static char VPF_COLUMN_DOUBLE
           
static char VPF_COLUMN_DOUBLE_2COORD
           
static char VPF_COLUMN_DOUBLE_3COORD
           
static char VPF_COLUMN_FLOAT
           
static char VPF_COLUMN_FLOAT_2COORD
           
static char VPF_COLUMN_FLOAT_3COORD
           
static char VPF_COLUMN_FOREIGN_KEY
           
static char VPF_COLUMN_INT
           
static char VPF_COLUMN_INT_OR_SHORT
          VPF Column Type Constant for a column that can be either int or short.
static char VPF_COLUMN_NON_KEY
           
static char VPF_COLUMN_NULL
           
static char VPF_COLUMN_PRIMARY_KEY
          VPF Column Key Type Constants
static char VPF_COLUMN_SHORT
           
static char VPF_COLUMN_TEXT
          VPF Column Type Constants
static char VPF_COLUMN_TEXTL1
           
static char VPF_COLUMN_TEXTL2
           
static char VPF_COLUMN_TEXTL3
           
static char VPF_COLUMN_TRIPLET
           
 
Constructor Summary
DcwColumnInfo(BinaryFile inputFile)
          Construct a DcwColumnInfo from the specified input stream.
 
Method Summary
 void assertSchema(char type, int length, boolean strictlength)
          Claim that the column has a particular schema
 int fieldLength()
          the number of bytes a field of this type takes in the input file
 java.lang.String getColumnDescription()
          Get the column description
 java.lang.String getColumnName()
          get the name of the column
 char getFieldType()
          get the VPF datatype of the column
 char getKeyType()
          get the VPF key type (one of VPF_COLUMN_PRIMARY_KEY, VPF_COLUMN_FOREIGN_KEY, or VPF_COLUMN_NON_KEY)
 java.lang.String getNarrativeTable()
          get the name of the narrative table
 int getNumberOfElements()
          get the number of elements
 java.lang.String getThematicIndexName()
          get the name of the thematic index
 java.lang.String getValueDescriptionTable()
          Get the name of the value description table
 java.lang.String getVDT()
          Get the name of the value description table
 boolean isForeignKey()
          Return true if this column is a foreign key.
 boolean isNonKey()
          Return true if this column is not a key column.
 boolean isPrimaryKey()
          Return true if this column is a primary key.
 java.lang.Object parseField(BinaryFile inputFile)
          Read an element of the type specified by the column
 java.lang.String toString()
          produce a nice printed version of all our contained information
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VPF_COLUMN_TEXT

public static final char VPF_COLUMN_TEXT
VPF Column Type Constants

See Also:
Constant Field Values

VPF_COLUMN_TEXTL1

public static final char VPF_COLUMN_TEXTL1
See Also:
Constant Field Values

VPF_COLUMN_TEXTL2

public static final char VPF_COLUMN_TEXTL2
See Also:
Constant Field Values

VPF_COLUMN_TEXTL3

public static final char VPF_COLUMN_TEXTL3
See Also:
Constant Field Values

VPF_COLUMN_FLOAT

public static final char VPF_COLUMN_FLOAT
See Also:
Constant Field Values

VPF_COLUMN_DOUBLE

public static final char VPF_COLUMN_DOUBLE
See Also:
Constant Field Values

VPF_COLUMN_SHORT

public static final char VPF_COLUMN_SHORT
See Also:
Constant Field Values

VPF_COLUMN_INT

public static final char VPF_COLUMN_INT
See Also:
Constant Field Values

VPF_COLUMN_FLOAT_2COORD

public static final char VPF_COLUMN_FLOAT_2COORD
See Also:
Constant Field Values

VPF_COLUMN_DOUBLE_2COORD

public static final char VPF_COLUMN_DOUBLE_2COORD
See Also:
Constant Field Values

VPF_COLUMN_FLOAT_3COORD

public static final char VPF_COLUMN_FLOAT_3COORD
See Also:
Constant Field Values

VPF_COLUMN_DOUBLE_3COORD

public static final char VPF_COLUMN_DOUBLE_3COORD
See Also:
Constant Field Values

VPF_COLUMN_DATE

public static final char VPF_COLUMN_DATE
See Also:
Constant Field Values

VPF_COLUMN_NULL

public static final char VPF_COLUMN_NULL
See Also:
Constant Field Values

VPF_COLUMN_TRIPLET

public static final char VPF_COLUMN_TRIPLET
See Also:
Constant Field Values

VPF_COLUMN_INT_OR_SHORT

public static final char VPF_COLUMN_INT_OR_SHORT
VPF Column Type Constant for a column that can be either int or short. This value will never be read from a VPF file, its a special value that is accepted by lookupSchema

See Also:
Constant Field Values

VPF_COLUMN_PRIMARY_KEY

public static final char VPF_COLUMN_PRIMARY_KEY
VPF Column Key Type Constants

See Also:
Constant Field Values

VPF_COLUMN_FOREIGN_KEY

public static final char VPF_COLUMN_FOREIGN_KEY
See Also:
Constant Field Values

VPF_COLUMN_NON_KEY

public static final char VPF_COLUMN_NON_KEY
See Also:
Constant Field Values
Constructor Detail

DcwColumnInfo

public DcwColumnInfo(BinaryFile inputFile)
              throws java.io.EOFException,
                     FormatException
Construct a DcwColumnInfo from the specified input stream.

Parameters:
inputFile - the filestream to construct from
Throws:
java.io.EOFException - when the first character read is a ';', indicating that we've reached the end of the column list; also thrown for an end of file
FormatException - some error was detected while reading the info for the column.
Method Detail

assertSchema

public void assertSchema(char type,
                         int length,
                         boolean strictlength)
                  throws FormatException
Claim that the column has a particular schema

Parameters:
type - the FieldType (datatype) this column is expected to contain legal values are specified by the VPF standard. the non-standard value 'i' is also accepted (equivalent to 'I' or 'S'), indicating an integral type.
length - the number of elements in this column
strictlength - false means that variable length columns can be fixed length instead
Throws:
FormatException - the column is not of the particular type/length

fieldLength

public int fieldLength()
                throws FormatException
the number of bytes a field of this type takes in the input file

Returns:
the number of bytes (-1 for a variable-length field)
Throws:
FormatException - the FieldType of this Column is not a valid VPF fieldtype

getColumnName

public java.lang.String getColumnName()
get the name of the column

Returns:
the name of the column

getFieldType

public char getFieldType()
get the VPF datatype of the column

Returns:
the VPF datatype

getNumberOfElements

public int getNumberOfElements()
get the number of elements

Returns:
the number of elements

getKeyType

public char getKeyType()
get the VPF key type (one of VPF_COLUMN_PRIMARY_KEY, VPF_COLUMN_FOREIGN_KEY, or VPF_COLUMN_NON_KEY)

Returns:
the vpf key type

isPrimaryKey

public boolean isPrimaryKey()
Return true if this column is a primary key. For any valid column, exactly one of isPrimaryKey, isForeignKey and isNonKey will be true.

Returns:
true for a primary key, false otherwise.
See Also:
isForeignKey(), isNonKey()

isForeignKey

public boolean isForeignKey()
Return true if this column is a foreign key. For any valid column, exactly one of isPrimaryKey, isForeignKey and isNonKey will be true.

Returns:
true for a foreign key, false otherwise.
See Also:
isPrimaryKey(), isNonKey()

isNonKey

public boolean isNonKey()
Return true if this column is not a key column. For any valid column, exactly one of isPrimaryKey, isForeignKey and isNonKey will be true.

Returns:
false for a primary or foreign key, true otherwise.
See Also:
isForeignKey(), isPrimaryKey()

getColumnDescription

public java.lang.String getColumnDescription()
Get the column description

Returns:
the column description (possibly null)

getValueDescriptionTable

public java.lang.String getValueDescriptionTable()
Get the name of the value description table

Returns:
the name of the value description table (possibly null). The same as getVDT()
See Also:
getVDT()

getVDT

public java.lang.String getVDT()
Get the name of the value description table

Returns:
the name of the value description table (possibly null). The same as getValueDescriptionTable
See Also:
getValueDescriptionTable()

getThematicIndexName

public java.lang.String getThematicIndexName()
get the name of the thematic index

Returns:
the thematic index name (possibly null)

getNarrativeTable

public java.lang.String getNarrativeTable()
get the name of the narrative table

Returns:
the name of the narrative table (possibly null)

parseField

public java.lang.Object parseField(BinaryFile inputFile)
                            throws java.io.EOFException,
                                   FormatException
Read an element of the type specified by the column

Returns:
the value read from the input file
Throws:
java.io.EOFException - an end-of-file was encountered before reading any of the field
FormatException - some data-consistency check failed while reading the data, or an end-of-file condition popped up in the middle of reading a field (partial read)

toString

public java.lang.String toString()
produce a nice printed version of all our contained information

Overrides:
toString in class java.lang.Object
Returns:
a nice little string


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details