Package org.geotools.data.vpf.file
Class VPFFile
- Object
-
- VPFFile
-
public class VPFFile extends Object
This class encapsulates VPF files, serving as a factory for VPFColumns. Instances of this class should be created by VPFFileFactory.- Author:
- Jeff Yutzler
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the input stream pointed to by the objectintgetAttributeCount()chargetByteOrder()Gets the value of byteOrder variable.VPFColumngetColumn(int index)VPFColumngetColumn(String name)intgetColumnCount()AttributeDescriptorgetDescriptor(String name)StringgetDirectoryName()Returns the directory name for this file by chopping off the file name and the separator.SimpleFeatureTypegetFeatureType()StringgetFileName()Returns the file name (without path) for the fileStringgetNarrativeTable()Gets the value of narrativeTable variable file name.StringgetPathName()Gets the full path name for this fileprotected intgetRecordSize()Methodis used to return size in bytes of records stored in this table.getRecordSizeSimpleFeaturegetRowFromId(String idName, int id)Returns a row with a matching value for the provided columnSimpleFeaturegetRowFromId0(String idName, int id)StringgetTypeName()booleanhasNext()Determines if the stream contains storage for another object.booleanisAbstract()AbstractList<SimpleFeature>readAllRows()Generates a list containing all of the features in the fileprotected charreadChar()Reads a single byte as a character valueprotected doublereadDouble()Retrieves a double from the fileSimpleFeaturereadFeature()Retrieves a feature from the fileprotected ObjectreadFixedSizeData(char dataType, int instancesCount)Retrieves a fixed amount of data from the fileprotected floatreadFloat()Retrieves a floating point number from the file.protected ObjectreadGeometry(int instancesCount, int dimensionality, boolean readDoubles)Constructs an object which is an instance of Geometry by reading values from the file.protected voidreadHeader()Retrieves a number of attributes from the file headerprotected intreadInteger()Retrieves an integer value from the fileprotected byte[]readNumber(int cnt)Reads some byte data from the fileprotected shortreadShort()Retrieves a short value from the fileprotected StringreadString(String terminators)Reads a string value from the fileprotected TripletIdreadTripletId()Retrieves a triplet object from the fileprotected ObjectreadVariableSizeData(char dataType)Retrieves variable sized data from the file by first reading an integer which indicates how many instances of the data type to retrievevoidreset()Resets the file stream by setting its pointer to the first position after the header.protected voidsetPosition(long pos)Sets the position in the streamStringtoString()protected voidunread(long bytes)Back up a specified number of bytes in the file stream
-
-
-
Constructor Detail
-
VPFFile
public VPFFile(String cPathName) throws IOException, SchemaException
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 Detail
-
getFeatureType
public SimpleFeatureType 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
public 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 String getFileName()
Returns the file name (without path) for the file- Returns:
- the file name for this file
-
getNarrativeTable
public String getNarrativeTable()
Gets the value of narrativeTable variable file name.- Returns:
- the value of narrativeTable
-
getPathName
public String getPathName()
Gets the full path name for this file- Returns:
- the path name for this file
-
getRecordSize
protected int getRecordSize()
Methodis used to return size in bytes of records stored in this table. If table keeps variable length recordsgetRecordSize-1should be returned.- Returns:
- an
valueint
-
getRowFromId
public SimpleFeature getRowFromId(String idName, int id)
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
public SimpleFeature getRowFromId0(String idName, int id)
-
getTypeName
public String 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
public AbstractList<SimpleFeature> readAllRows() throws IOException
Generates a list containing all of the features in the file- Returns:
- a
Listvalue containing Feature objects - Throws:
IOException- if an error occurs
-
readChar
protected char readChar() throws IOExceptionReads a single byte as a character value- Returns:
- a
charvalue - 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
protected double readDouble() throws IOExceptionRetrieves a double from the file- Returns:
- a
doublevalue - Throws:
IOException- if an error occurs
-
readFeature
public SimpleFeature readFeature() throws IOException, IllegalAttributeException
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
protected Object readFixedSizeData(char dataType, int instancesCount) throws IOException
Retrieves a fixed amount of data from the file- Parameters:
dataType- acharvalue indicating the data typeinstancesCount- anintvalue indicating the number of instances to retrieve.- Returns:
- an
Objectvalue - Throws:
IOException- if an error occurs
-
readFloat
protected float readFloat() throws IOExceptionRetrieves a floating point number from the file.- Returns:
- a
floatvalue - Throws:
IOException- if an error occurs
-
readHeader
protected void readHeader() throws VPFHeaderFormatException, IOExceptionRetrieves a number of attributes from the file header- Throws:
VPFHeaderFormatException- if an error occursIOException- if an error occurs
-
readInteger
protected int readInteger() throws IOExceptionRetrieves an integer value from the file- Returns:
- an
intvalue - Throws:
IOException- if an error occurs
-
readNumber
protected byte[] readNumber(int cnt) throws IOExceptionReads some byte data from the file- Parameters:
cnt- anintvalue indicating the number of bytes to retrieve- Returns:
- a
byte[]value - Throws:
IOException- if an error occurs
-
readShort
protected short readShort() throws IOExceptionRetrieves a short value from the file- Returns:
- a
shortvalue - Throws:
IOException- if an error occurs
-
readString
protected String readString(String terminators) throws IOException
Reads a string value from the file- Parameters:
terminators- aStringvalue indicating the terminators to look for- Returns:
- a
Stringvalue - Throws:
IOException- if an error occurs
-
readTripletId
protected TripletId readTripletId() throws IOException
Retrieves a triplet object from the file- Returns:
- a
TripletIdvalue - Throws:
IOException- on any IO errors
-
readVariableSizeData
protected Object readVariableSizeData(char dataType) throws 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- acharvalue indicating the data type- Returns:
- an
Objectvalue - 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
public void close() throws IOExceptionClose the input stream pointed to by the object- Throws:
IOException- in some unlikely situation
-
setPosition
protected void setPosition(long pos) throws IOExceptionSets the position in the stream- Parameters:
pos- A 1-indexed position- Throws:
IOException- on any IO failures
-
unread
protected void unread(long bytes) throws IOExceptionBack up a specified number of bytes in the file stream- Parameters:
bytes- alongvalue- Throws:
IOException- if an error occurs
-
getColumn
public VPFColumn getColumn(int index)
-
getColumnCount
public int getColumnCount()
-
getDescriptor
public AttributeDescriptor getDescriptor(String name)
-
-