Package org.geotools.data.vpf.file
Class VPFFile
Object
VPFFile
This class encapsulates VPF files, serving as a factory for VPFColumns. Instances of this class should be created by
VPFFileFactory.
- Author:
- Jeff Yutzler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the input stream pointed to by the objectint
char
Gets the value of byteOrder variable.getColumn
(int index) int
getDescriptor
(String name) Returns the directory name for this file by chopping off the file name and the separator.Returns the file name (without path) for the fileGets the value of narrativeTable variable file name.Gets the full path name for this fileprotected int
Method
is used to return size in bytes of records stored in this table.getRecordSize
getRowFromId
(String idName, int id) Returns a row with a matching value for the provided columngetRowFromId0
(String idName, int id) boolean
hasNext()
Determines if the stream contains storage for another object.boolean
Generates a list containing all of the features in the fileprotected char
readChar()
Reads a single byte as a character valueprotected double
Retrieves a double from the fileRetrieves a feature from the fileprotected Object
readFixedSizeData
(char dataType, int instancesCount) Retrieves a fixed amount of data from the fileprotected float
Retrieves a floating point number from the file.protected 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
Retrieves a number of attributes from the file headerprotected int
Retrieves an integer value from the fileprotected byte[]
readNumber
(int cnt) Reads some byte data from the fileprotected short
Retrieves a short value from the fileprotected String
readString
(String terminators) Reads a string value from the fileprotected TripletId
Retrieves a triplet object from the fileprotected 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 retrievevoid
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 streamtoString()
protected void
unread
(long bytes) Back up a specified number of bytes in the file stream
-
Constructor Details
-
VPFFile
Constructor.- Parameters:
cPathName
- The path to this file- Throws:
IOException
- if the path or the file are invalidSchemaException
- if the contained feature type can not be constructed
-
-
Method Details
-
getFeatureType
-
getAttributeCount
public int getAttributeCount() -
getByteOrder
public char getByteOrder()Gets the value of byteOrder variable. Byte order in which table is written:- L - least-significant-first
- M - most-significant-first
- Returns:
- the value of byteOrder
-
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
Returns the file name (without path) for the file- Returns:
- the file name for this file
-
getNarrativeTable
Gets the value of narrativeTable variable file name.- Returns:
- the value of narrativeTable
-
getPathName
Gets the full path name for this file- Returns:
- the path name for this file
-
getRecordSize
protected int getRecordSize()Method
is used to return size in bytes of records stored in this table. If table keeps variable length recordsgetRecordSize
-1
should be returned.- Returns:
- an
valueint
-
getRowFromId
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
-
getRowFromId0
-
getTypeName
-
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() -
readAllRows
Generates a list containing all of the features in the file- Returns:
- a
List
value containing Feature objects - Throws:
IOException
- if an error occurs
-
readChar
Reads a single byte as a character value- Returns:
- a
char
value - Throws:
IOException
- if an error occurs
-
readGeometry
protected Object readGeometry(int instancesCount, int dimensionality, boolean readDoubles) throws IOException Constructs an object which is an instance of Geometry by reading values from the file.- Parameters:
instancesCount
- number of coordinates to readdimensionality
- either 2 or 3readDoubles
- true: read a double value; false: read a float value- Returns:
- the constructed object
- Throws:
IOException
- on any file IO errors
-
readDouble
Retrieves a double from the file- Returns:
- a
double
value - Throws:
IOException
- if an error occurs
-
readFeature
Retrieves a feature from the file- Returns:
- the retieved feature
- Throws:
IOException
- on any file IO errorsIllegalAttributeException
- if any of the attributes retrieved are illegal
-
readFixedSizeData
Retrieves a fixed amount of data from the file- Parameters:
dataType
- achar
value indicating the data typeinstancesCount
- anint
value indicating the number of instances to retrieve.- Returns:
- an
Object
value - Throws:
IOException
- if an error occurs
-
readFloat
Retrieves a floating point number from the file.- Returns:
- a
float
value - Throws:
IOException
- if an error occurs
-
readHeader
Retrieves a number of attributes from the file header- Throws:
VPFHeaderFormatException
- if an error occursIOException
- if an error occurs
-
readInteger
Retrieves an integer value from the file- Returns:
- an
int
value - Throws:
IOException
- if an error occurs
-
readNumber
Reads some byte data from the file- Parameters:
cnt
- anint
value indicating the number of bytes to retrieve- Returns:
- a
byte[]
value - Throws:
IOException
- if an error occurs
-
readShort
Retrieves a short value from the file- Returns:
- a
short
value - Throws:
IOException
- if an error occurs
-
readString
Reads a string value from the file- Parameters:
terminators
- aString
value indicating the terminators to look for- Returns:
- a
String
value - Throws:
IOException
- if an error occurs
-
readTripletId
Retrieves a triplet object from the file- Returns:
- a
TripletId
value - Throws:
IOException
- on any IO errors
-
readVariableSizeData
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
- achar
value indicating the data type- Returns:
- an
Object
value - Throws:
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
Close the input stream pointed to by the object- Throws:
IOException
- in some unlikely situation
-
setPosition
Sets the position in the stream- Parameters:
pos
- A 1-indexed position- Throws:
IOException
- on any IO failures
-
toString
-
unread
Back up a specified number of bytes in the file stream- Parameters:
bytes
- along
value- Throws:
IOException
- if an error occurs
-
getColumn
-
getColumnCount
public int getColumnCount() -
getColumn
-
getDescriptor
-