Package org.geotools.data.property
Class PropertyFeatureReader
- Object
-
- PropertyFeatureReader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FeatureReader<SimpleFeatureType,SimpleFeature>
public class PropertyFeatureReader extends Object implements FeatureReader<SimpleFeatureType,SimpleFeature>
Read a property file directly.This implementation does not perform any filtering or processing; it leaves that up to wrappers to manipulate the content into the format or projection requested by the user.
The content of this file should start with a the property "_" with the value being the typeSpec describing the featureType. Thereafter each line will should have a FeatureID as the property and the attributes as the value separated by | characters.
_=id:Integer|name:String|geom:Geometry fid1=1|Jody|well known text fid2=2|Brent|well known text fid3=3|Dave|well known text
Many values may be represented by a special tag:
. An empty element:||
is interpreted as the empty string:fid4=4||
-> Feature( id=2, name="", geom=null ) - Since:
- 8.0
- Author:
- Jody Garnett (LISAsoft), Torben Barsballe (Boundless)
-
-
Constructor Summary
Constructors Constructor Description PropertyFeatureReader(String namespace, File file)
PropertyFeatureReader(String namespace, File file, GeometryFactory geometryFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Be sure to call close when you are finished with this reader; as it must close the file it has open.SimpleFeatureType
getFeatureType()
Return the FeatureType this reader has been configured to create.boolean
hasNext()
Check if additional content is available.SimpleFeature
next()
Grab the next feature from the property file.Object
read(int index)
Read attribute in position marked byindex
.
-
-
-
Constructor Detail
-
PropertyFeatureReader
public PropertyFeatureReader(String namespace, File file) throws IOException
- Throws:
IOException
-
PropertyFeatureReader
public PropertyFeatureReader(String namespace, File file, GeometryFactory geometryFactory) throws IOException
- Throws:
IOException
-
-
Method Detail
-
getFeatureType
public SimpleFeatureType getFeatureType()
Description copied from interface:FeatureReader
Return the FeatureType this reader has been configured to create.- Specified by:
getFeatureType
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
- the FeatureType of the Features this FeatureReader will create.
-
next
public SimpleFeature next() throws IOException, NoSuchElementException
Grab the next feature from the property file.- Specified by:
next
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
- feature
- Throws:
NoSuchElementException
- Check hasNext() to avoid reading off the end of the fileIOException
- If an error occurs reading the Feature.
-
read
public Object read(int index) throws IOException, ArrayIndexOutOfBoundsException
Read attribute in position marked byindex
.- Parameters:
index
- Attribute position to read- Returns:
- Value for the attribtue in position
index
- Throws:
IOException
ArrayIndexOutOfBoundsException
-
hasNext
public boolean hasNext() throws IOException
Check if additional content is available.- Specified by:
hasNext
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Returns:
true
if additional content is available- Throws:
IOException
- If an error occurs determining if there are more Features.
-
close
public void close() throws IOException
Be sure to call close when you are finished with this reader; as it must close the file it has open.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFeatureReader<SimpleFeatureType,SimpleFeature>
- Throws:
IOException
- if an I/O error occurs
-
-