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 textMany 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 voidclose()Be sure to call close when you are finished with this reader; as it must close the file it has open.SimpleFeatureTypegetFeatureType()Return the FeatureType this reader has been configured to create.booleanhasNext()Check if additional content is available.SimpleFeaturenext()Grab the next feature from the property file.Objectread(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:FeatureReaderReturn the FeatureType this reader has been configured to create.- Specified by:
getFeatureTypein 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:
nextin 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:
IOExceptionArrayIndexOutOfBoundsException
-
hasNext
public boolean hasNext() throws IOExceptionCheck if additional content is available.- Specified by:
hasNextin interfaceFeatureReader<SimpleFeatureType,SimpleFeature>- Returns:
trueif additional content is available- Throws:
IOException- If an error occurs determining if there are more Features.
-
close
public void close() throws IOExceptionBe sure to call close when you are finished with this reader; as it must close the file it has open.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFeatureReader<SimpleFeatureType,SimpleFeature>- Throws:
IOException- if an I/O error occurs
-
-