org.geotools.data.property
Class PropertyAttributeReader

Object
  extended by PropertyAttributeReader
All Implemented Interfaces:
AttributeReader

public class PropertyAttributeReader
extends Object
implements AttributeReader

Simple AttributeReader that works against Java properties files.

This AttributeReader is part of the GeoTools AbstractDataStore tutorial, and should be considered a Toy.

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 attribtues 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
 
 

May values may be represented by a special tag: . An empty element: || is interpreted as the empty string:

  fid4=4||
 

You can use \ to escape a | character, you can also use it to protect newlines::

 fid4=4|I have a \\|splitting\\| headache|POINT(0,0)
 fid5=5|Example of \nmulti-lin text|POINT(1,1)
 fid6=6|Second \\
 example of multi-line text|POINT(2,2)
 

Author:
Jody Garnett

Constructor Summary
PropertyAttributeReader(File file)
          Creates a new PropertyAttributeReader object.
 
Method Summary
 void close()
          Close the internal reader accessing the file.
 int getAttributeCount()
          Number of attributes to expect based on header information.
 AttributeDescriptor getAttributeType(int index)
          AttribtueDescriptor (name and type) for position marked by index.
 String getFeatureID()
          Retrieve the FeatureId identifying the current line.
 boolean hasNext()
          Check if the file has another line.
 void next()
          Retrieve the next line.
 Object read(int index)
          Read attribute in position marked by index.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyAttributeReader

public PropertyAttributeReader(File file)
                        throws IOException
Creates a new PropertyAttributeReader object.

Parameters:
file - File being read
Throws:
IOException
DataSourceException
Method Detail

getAttributeCount

public int getAttributeCount()
Number of attributes to expect based on header information.

Specified by:
getAttributeCount in interface AttributeReader
Returns:
number of attribtues

getAttributeType

public AttributeDescriptor getAttributeType(int index)
                                     throws ArrayIndexOutOfBoundsException
AttribtueDescriptor (name and type) for position marked by index.

Specified by:
getAttributeType in interface AttributeReader
Parameters:
index -
Returns:
AttributeDescriptor describing attribute name and type
Throws:
ArrayIndexOutOfBoundsException

close

public void close()
           throws IOException
Close the internal reader accessing the file.

Specified by:
close in interface AttributeReader
Throws:
IOException

hasNext

public boolean hasNext()
                throws IOException
Check if the file has another line.

Specified by:
hasNext in interface AttributeReader
Returns:
true if the file has another line
Throws:
IOException

next

public void next()
          throws IOException
Retrieve the next line.

Specified by:
next in interface AttributeReader
Throws:
IOException
NoSuchElementException

getFeatureID

public String getFeatureID()
Retrieve the FeatureId identifying the current line.

Returns:
FeatureID for the current line.

read

public Object read(int index)
            throws IOException,
                   ArrayIndexOutOfBoundsException
Read attribute in position marked by index.

Specified by:
read in interface AttributeReader
Parameters:
index - Attribute position to read
Returns:
Value for the attribtue in position index
Throws:
IOException
ArrayIndexOutOfBoundsException


Copyright © 1996-2014 Geotools. All Rights Reserved.