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
ConstructorsConstructorDescriptionPropertyFeatureReader
(String namespace, File file) PropertyFeatureReader
(String namespace, File file, GeometryFactory geometryFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Be sure to call close when you are finished with this reader; as it must close the file it has open.Return the FeatureType this reader has been configured to create.boolean
hasNext()
Check if additional content is available.next()
Grab the next feature from the property file.read
(int index) Read attribute in position marked byindex
.
-
Constructor Details
-
PropertyFeatureReader
- Throws:
IOException
-
PropertyFeatureReader
public PropertyFeatureReader(String namespace, File file, GeometryFactory geometryFactory) throws IOException - Throws:
IOException
-
-
Method Details
-
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
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
Read attribute in position marked byindex
.- Parameters:
index
- Attribute position to read- Returns:
- Value for the attribtue in position
index
- Throws:
IOException
ArrayIndexOutOfBoundsException
-
hasNext
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
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
-