org.geotools.data.vpf.file
Class VPFFile

java.lang.Object
  extended by org.geotools.data.vpf.file.VPFFile
All Implemented Interfaces:
DataTypesDefinition, FileConstants, org.opengis.feature.simple.SimpleFeatureType, org.opengis.feature.type.AttributeType, org.opengis.feature.type.ComplexType, org.opengis.feature.type.FeatureType, org.opengis.feature.type.PropertyType

public class VPFFile
extends java.lang.Object
implements org.opengis.feature.simple.SimpleFeatureType, FileConstants, DataTypesDefinition

This class encapsulates VPF files. By implementing the FeatureType interface, it serves as a factory for VPFColumns. Instances of this class should be created by VPFFileFactory.

Author:
Jeff Yutzler

Field Summary
 
Fields inherited from interface org.geotools.data.vpf.ifc.FileConstants
AREA_BOUMDING_RECTANGLE_TABLE, AREA_FEATURE_TABLE, AREA_JOIN_TABLE, AREA_THEMATIC_INDEX, CHARACTER_VALUE_DESCRIPTION_TABLE, COLUMN_MANDATORY, COLUMN_MANDATORY_AT_LEVEL_0, COLUMN_MANDATORY_AT_LEVEL_1, COLUMN_MANDATORY_AT_LEVEL_2, COLUMN_MANDATORY_AT_LEVEL_3, COLUMN_MANDATORY_IF_TILES, COLUMN_OPTIONAL, COLUMN_OPTIONAL_FP, COMPLEX_BOUNDING_RECTANGLE_TABLE, COMPLEX_FEATURE_TABLE, COMPLEX_JOIN_TABLE, COMPLEX_THEMATIC_INDEX, CONNECTED_NODE_PRIMITIVE, CONNECTED_NODE_SPATIAL_INDEX, COVERAGE_ATTRIBUTE_TABLE, DATA_QUALITY_COVERAGE, DATA_QUALITY_TABLE, DATABASE_HEADER_TABLE, DIAGNOSITC_POINT_TABLE, DIR_DQ, DIR_GAZETTE, DIR_LIBREF, DIR_TILEREF, EDGE_BOUNDING_RECTANGLE, EDGE_PRIMITIVE, EDGE_SPATIAL_INDEX, ENTITY_NODE_PRIMITIVE, ENTITY_NODE_SPATIAL_INDEX, EXT_ABR, EXT_AFT, EXT_AJT, EXT_ATI, EXT_CBR, EXT_CFT, EXT_CJT, EXT_CTI, EXT_DOC, EXT_DPT, EXT_FIT, EXT_FTI, EXT_JTI, EXT_LBR, EXT_LFT, EXT_LJT, EXT_LTI, EXT_PBR, EXT_PFT, EXT_PJT, EXT_PTI, EXT_RAT, EXT_RPT, EXT_TFT, EXT_TTI, FACE_BOUNDING_RECTANGLE, FACE_PRIMITIVE, FACE_SPATIAL_INDEX, FEATURE_CLASS_ATTRIBUTE_TABLE, FEATURE_CLASS_SCHEMA_TABLE, FEATURE_INDEX_TABLE, FEATURE_THEMATIC_INDEX, GEOGRAPHIC_REFERENCE_TABLE, INTEGER_VALUE_DESCRIPTION_TABLE, JOIN_THEMATIC_INDEX, KEY_NON_UNIQUE, KEY_PRIMARY, KEY_UNIQUE, LIBRARY_ATTTIBUTE_TABLE, LIBRARY_HEADER_TABLE, LIBRARY_REFERENCE_COVERAGE, LINE_BOUNDING_RECTANGLE_TABLE, LINE_FEATURE_TABLE, LINE_JOIN_TABLE, LINE_THEMATIC_INDEX, NAMES_REFERENCE_COVERAGE, NARRATIVE_TABLE, POINT_BOUNDING_RECTANGLE_TABLE, POINT_FEATURE_TABLE, POINT_JOIN_TABLE, POINT_THEMATIC_INDEX, REGISTRATION_POINT_TABLE, RELATED_ATTRIBUTE_TABLE, RING_TABLE, TABLE_CAT, TABLE_CHAR, TABLE_CND, TABLE_CSI, TABLE_DHT, TABLE_DQT, TABLE_EBR, TABLE_EDG, TABLE_END, TABLE_ESI, TABLE_FAC, TABLE_FBR, TABLE_FCA, TABLE_FCS, TABLE_FSI, TABLE_GRT, TABLE_INT, TABLE_LAT, TABLE_LHT, TABLE_NSI, TABLE_RNG, TABLE_TSI, TABLE_TXT, TEXT_FEATURE_TABLE, TEXT_PRIMITIVE, TEXT_SPATIAL_INDEX, TEXT_THEMATIC_TABLE, TILE_REFERENCE_COVERAGE, VPF_ELEMENT_SEPARATOR, VPF_FIELD_SEPARATOR, VPF_RECORD_SEPARATOR
 
Fields inherited from interface org.geotools.data.vpf.ifc.DataTypesDefinition
BIG_ENDIAN_ORDER, CHAR_NULL_VALUE, DATA_2_COORD_F, DATA_2_COORD_F_LEN, DATA_2_COORD_R, DATA_2_COORD_R_LEN, DATA_3_COORD_F, DATA_3_COORD_F_LEN, DATA_3_COORD_R, DATA_3_COORD_R_LEN, DATA_DATE_TIME, DATA_DATE_TIME_LEN, DATA_LEVEL1_TEXT, DATA_LEVEL2_TEXT, DATA_LEVEL3_TEXT, DATA_LONG_FLOAT, DATA_LONG_FLOAT_LEN, DATA_LONG_INTEGER, DATA_LONG_INTEGER_LEN, DATA_NULL_FIELD, DATA_NULL_FIELD_LEN, DATA_SHORT_FLOAT, DATA_SHORT_FLOAT_LEN, DATA_SHORT_INTEGER, DATA_SHORT_INTEGER_LEN, DATA_TEXT, DATA_TRIPLET_ID, DATA_TRIPLET_ID_LEN, LEAST_SIGNIF_FIRST, LITTLE_ENDIAN_ORDER, MOST_SIGNIF_FIRST, STRING_NULL_VALUE, STRING_NULL_VALUES
 
Constructor Summary
VPFFile(java.lang.String cPathName)
          Constructor.
 
Method Summary
 void close()
          Close the input stream pointed to by the object
 int getAttributeCount()
           
 java.util.List<org.opengis.feature.type.AttributeDescriptor> getAttributeDescriptors()
           
 java.lang.Class getBinding()
           
 char getByteOrder()
          Gets the value of byteOrder variable.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
           
 org.opengis.util.InternationalString getDescription()
           
 org.opengis.feature.type.AttributeDescriptor getDescriptor(int index)
           
 org.opengis.feature.type.AttributeDescriptor getDescriptor(org.opengis.feature.type.Name name)
           
 org.opengis.feature.type.AttributeDescriptor getDescriptor(java.lang.String name)
           
 java.util.Collection getDescriptors()
           
 java.lang.String getDirectoryName()
          Returns the directory name for this file by chopping off the file name and the separator.
 java.lang.String getFileName()
          Returns the file name (without path) for the file
 org.opengis.feature.type.GeometryDescriptor getGeometryDescriptor()
           
 org.opengis.feature.type.Name getName()
           
 java.lang.String getNarrativeTable()
          Gets the value of narrativeTable variable file name.
 java.lang.String getPathName()
          Gets the full path name for this file
protected  int getRecordSize()
          Method getRecordSize is used to return size in bytes of records stored in this table.
 java.util.List getRestrictions()
           
 org.opengis.feature.simple.SimpleFeature getRowFromId(java.lang.String idName, int id)
          Returns a row with a matching value for the provided column
 org.opengis.feature.type.AttributeType getSuper()
           
 org.opengis.feature.type.AttributeType getType(int index)
           
 org.opengis.feature.type.AttributeType getType(org.opengis.feature.type.Name name)
           
 org.opengis.feature.type.AttributeType getType(java.lang.String name)
           
 java.lang.String getTypeName()
           
 java.util.List getTypes()
           
 java.util.Map<java.lang.Object,java.lang.Object> getUserData()
           
 boolean hasNext()
          Determines if the stream contains storage for another object.
 int indexOf(org.opengis.feature.type.Name name)
           
 int indexOf(java.lang.String name)
           
 boolean isAbstract()
           
 boolean isIdentified()
           
 boolean isInline()
           
 java.util.AbstractList readAllRows()
          Generates a list containing all of the features in the file
protected  char readChar()
          Reads a single byte as a character value
protected  double readDouble()
          Retrieves a double from the file
 org.opengis.feature.simple.SimpleFeature readFeature()
          Retrieves a feature from the file
protected  java.lang.Object readFixedSizeData(char dataType, int instancesCount)
          Retrieves a fixed amount of data from the file
protected  float readFloat()
          Retrieves a floating point number from the file.
protected  java.lang.Object readGeometry(int instancesCount, int dimensionality, boolean readDoubles)
          Constructs an object which is an instance of Geometry by reading values from the file.
protected  void readHeader()
          Retrieves a number of attributes from the file header
protected  int readInteger()
          Retrieves an integer value from the file
protected  byte[] readNumber(int cnt)
          Reads some byte data from the file
protected  short readShort()
          Retrieves a short value from the file
protected  java.lang.String readString(java.lang.String terminators)
          Reads a string value from the file
protected  TripletId readTripletId()
          Retrieves a triplet object from the file
protected  java.lang.Object readVariableSizeData(char dataType)
          Retrieves variable sized data from the file by first reading an integer which indicates how many instances of the data type to retrieve
 void reset()
          Resets the file stream by setting its pointer to the first position after the header.
protected  void setPosition(long pos)
          Sets the position in the stream
 java.lang.String toString()
           
protected  void unread(long bytes)
          Back up a specified number of bytes in the file stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.feature.type.PropertyType
equals, hashCode
 

Constructor Detail

VPFFile

public VPFFile(java.lang.String cPathName)
        throws java.io.IOException,
               SchemaException
Constructor.

Parameters:
cPathName - The path to this file
Throws:
java.io.IOException - if the path or the file are invalid
SchemaException - if the contained feature type can not be constructed
Method Detail

getAttributeCount

public int getAttributeCount()
Specified by:
getAttributeCount in interface org.opengis.feature.simple.SimpleFeatureType

getByteOrder

public char getByteOrder()
Gets the value of byteOrder variable. Byte order in which table is written:

Returns:
the value of byteOrder

getDirectoryName

public java.lang.String getDirectoryName()
Returns the directory name for this file by chopping off the file name and the separator.

Returns:
the directory name for this file

getFileName

public java.lang.String getFileName()
Returns the file name (without path) for the file

Returns:
the file name for this file

getNarrativeTable

public java.lang.String getNarrativeTable()
Gets the value of narrativeTable variable file name.

Returns:
the value of narrativeTable

getPathName

public java.lang.String getPathName()
Gets the full path name for this file

Returns:
the path name for this file

getRecordSize

protected int getRecordSize()
Method getRecordSize is used to return size in bytes of records stored in this table. If table keeps variable length records -1 should be returned.

Returns:
an int value

getRowFromId

public org.opengis.feature.simple.SimpleFeature getRowFromId(java.lang.String idName,
                                                             int id)
                                                      throws IllegalAttributeException
Returns a row with a matching value for the provided column

Parameters:
idName - The name of the column to look for, such as "id"
id - An identifier for the requested row
Returns:
The first row which matches the ID
Throws:
IllegalAttributeException - The feature can not be created due to illegal attributes in the source file

getTypeName

public java.lang.String getTypeName()
Specified by:
getTypeName in interface org.opengis.feature.simple.SimpleFeatureType

hasNext

public boolean hasNext()
Determines if the stream contains storage for another object. Who knows how well this will work on variable length objects?

Returns:
a boolean

isAbstract

public boolean isAbstract()
Specified by:
isAbstract in interface org.opengis.feature.type.PropertyType

readAllRows

public java.util.AbstractList readAllRows()
                                   throws java.io.IOException
Generates a list containing all of the features in the file

Returns:
a List value containing Feature objects
Throws:
java.io.IOException - if an error occurs

readChar

protected char readChar()
                 throws java.io.IOException
Reads a single byte as a character value

Returns:
a char value
Throws:
java.io.IOException - if an error occurs

readGeometry

protected java.lang.Object readGeometry(int instancesCount,
                                        int dimensionality,
                                        boolean readDoubles)
                                 throws java.io.IOException
Constructs an object which is an instance of Geometry by reading values from the file.

Parameters:
instancesCount - number of coordinates to read
dimensionality - either 2 or 3
readDoubles - true: read a double value; false: read a float value
Returns:
the constructed object
Throws:
java.io.IOException - on any file IO errors

readDouble

protected double readDouble()
                     throws java.io.IOException
Retrieves a double from the file

Returns:
a double value
Throws:
java.io.IOException - if an error occurs

readFeature

public org.opengis.feature.simple.SimpleFeature readFeature()
                                                     throws java.io.IOException,
                                                            IllegalAttributeException
Retrieves a feature from the file

Returns:
the retieved feature
Throws:
java.io.IOException - on any file IO errors
IllegalAttributeException - if any of the attributes retrieved are illegal

readFixedSizeData

protected java.lang.Object readFixedSizeData(char dataType,
                                             int instancesCount)
                                      throws java.io.IOException
Retrieves a fixed amount of data from the file

Parameters:
dataType - a char value indicating the data type
instancesCount - an int value indicating the number of instances to retrieve.
Returns:
an Object value
Throws:
java.io.IOException - if an error occurs

readFloat

protected float readFloat()
                   throws java.io.IOException
Retrieves a floating point number from the file.

Returns:
a float value
Throws:
java.io.IOException - if an error occurs

readHeader

protected void readHeader()
                   throws VPFHeaderFormatException,
                          java.io.IOException
Retrieves a number of attributes from the file header

Throws:
VPFHeaderFormatException - if an error occurs
java.io.IOException - if an error occurs

readInteger

protected int readInteger()
                   throws java.io.IOException
Retrieves an integer value from the file

Returns:
an int value
Throws:
java.io.IOException - if an error occurs

readNumber

protected byte[] readNumber(int cnt)
                     throws java.io.IOException
Reads some byte data from the file

Parameters:
cnt - an int value indicating the number of bytes to retrieve
Returns:
a byte[] value
Throws:
java.io.IOException - if an error occurs

readShort

protected short readShort()
                   throws java.io.IOException
Retrieves a short value from the file

Returns:
a short value
Throws:
java.io.IOException - if an error occurs

readString

protected java.lang.String readString(java.lang.String terminators)
                               throws java.io.IOException
Reads a string value from the file

Parameters:
terminators - a String value indicating the terminators to look for
Returns:
a String value
Throws:
java.io.IOException - if an error occurs

readTripletId

protected TripletId readTripletId()
                           throws java.io.IOException
Retrieves a triplet object from the file

Returns:
a TripletId value
Throws:
java.io.IOException - on any IO errors

readVariableSizeData

protected java.lang.Object readVariableSizeData(char dataType)
                                         throws java.io.IOException
Retrieves variable sized data from the file by first reading an integer which indicates how many instances of the data type to retrieve

Parameters:
dataType - a char value indicating the data type
Returns:
an Object value
Throws:
java.io.IOException - if an error occurs

reset

public void reset()
Resets the file stream by setting its pointer to the first position after the header.


close

public void close()
           throws java.io.IOException
Close the input stream pointed to by the object

Throws:
java.io.IOException - in some unlikely situation

setPosition

protected void setPosition(long pos)
                    throws java.io.IOException
Sets the position in the stream

Parameters:
pos - A 1-indexed position
Throws:
java.io.IOException - on any IO failures

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unread

protected void unread(long bytes)
               throws java.io.IOException
Back up a specified number of bytes in the file stream

Parameters:
bytes - a long value
Throws:
java.io.IOException - if an error occurs

getAttributeDescriptors

public java.util.List<org.opengis.feature.type.AttributeDescriptor> getAttributeDescriptors()
Specified by:
getAttributeDescriptors in interface org.opengis.feature.simple.SimpleFeatureType

getDescriptor

public org.opengis.feature.type.AttributeDescriptor getDescriptor(java.lang.String name)
Specified by:
getDescriptor in interface org.opengis.feature.simple.SimpleFeatureType
Specified by:
getDescriptor in interface org.opengis.feature.type.ComplexType

getDescriptor

public org.opengis.feature.type.AttributeDescriptor getDescriptor(org.opengis.feature.type.Name name)
Specified by:
getDescriptor in interface org.opengis.feature.simple.SimpleFeatureType
Specified by:
getDescriptor in interface org.opengis.feature.type.ComplexType

getDescriptor

public org.opengis.feature.type.AttributeDescriptor getDescriptor(int index)
Specified by:
getDescriptor in interface org.opengis.feature.simple.SimpleFeatureType

getType

public org.opengis.feature.type.AttributeType getType(org.opengis.feature.type.Name name)
Specified by:
getType in interface org.opengis.feature.simple.SimpleFeatureType

getType

public org.opengis.feature.type.AttributeType getType(java.lang.String name)
Specified by:
getType in interface org.opengis.feature.simple.SimpleFeatureType

getType

public org.opengis.feature.type.AttributeType getType(int index)
Specified by:
getType in interface org.opengis.feature.simple.SimpleFeatureType

getTypes

public java.util.List getTypes()
Specified by:
getTypes in interface org.opengis.feature.simple.SimpleFeatureType

getCoordinateReferenceSystem

public org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Specified by:
getCoordinateReferenceSystem in interface org.opengis.feature.type.FeatureType

getGeometryDescriptor

public org.opengis.feature.type.GeometryDescriptor getGeometryDescriptor()
Specified by:
getGeometryDescriptor in interface org.opengis.feature.type.FeatureType

getBinding

public java.lang.Class getBinding()
Specified by:
getBinding in interface org.opengis.feature.type.ComplexType
Specified by:
getBinding in interface org.opengis.feature.type.PropertyType

getDescriptors

public java.util.Collection getDescriptors()
Specified by:
getDescriptors in interface org.opengis.feature.type.ComplexType

isInline

public boolean isInline()
Specified by:
isInline in interface org.opengis.feature.type.ComplexType

getRestrictions

public java.util.List getRestrictions()
Specified by:
getRestrictions in interface org.opengis.feature.type.PropertyType

getSuper

public org.opengis.feature.type.AttributeType getSuper()
Specified by:
getSuper in interface org.opengis.feature.type.AttributeType
Specified by:
getSuper in interface org.opengis.feature.type.PropertyType

isIdentified

public boolean isIdentified()
Specified by:
isIdentified in interface org.opengis.feature.type.AttributeType
Specified by:
isIdentified in interface org.opengis.feature.type.FeatureType

getDescription

public org.opengis.util.InternationalString getDescription()
Specified by:
getDescription in interface org.opengis.feature.type.PropertyType

getName

public org.opengis.feature.type.Name getName()
Specified by:
getName in interface org.opengis.feature.type.PropertyType

indexOf

public int indexOf(java.lang.String name)
Specified by:
indexOf in interface org.opengis.feature.simple.SimpleFeatureType

indexOf

public int indexOf(org.opengis.feature.type.Name name)
Specified by:
indexOf in interface org.opengis.feature.simple.SimpleFeatureType

getUserData

public java.util.Map<java.lang.Object,java.lang.Object> getUserData()
Specified by:
getUserData in interface org.opengis.feature.type.PropertyType


Copyright © 1996-2010 Geotools. All Rights Reserved.