|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.data.shapefile.shp.ShapefileReader
The general use of this class is:
You don't have to immediately ask for the shape from the record. The
record will contain the bounds of the shape and will only read the shape when
the shape() method is called. This ShapefileReader.Record is the same object
every time, so if you need data from the Record, be sure to copy it.
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
ShapefileReader r = new ShapefileReader( in ) while (r.hasNext()) { Geometry
shape = (Geometry) r.nextRecord().shape() // do stuff } r.close();
Nested Class Summary | |
class |
ShapefileReader.Record
The reader returns only one Record instance in its lifetime. |
Constructor Summary | |
ShapefileReader(java.nio.channels.ReadableByteChannel channel,
boolean strict,
boolean useMemoryMapped,
Lock lock)
Creates a new instance of ShapeFile. |
|
ShapefileReader(java.nio.channels.ReadableByteChannel channel,
Lock lock)
Default constructor. |
Method Summary | |
void |
close()
Clean up any resources. |
static java.nio.ByteBuffer |
ensureCapacity(java.nio.ByteBuffer buffer,
int size,
boolean useMemoryMappedBuffer)
|
static int |
fill(java.nio.ByteBuffer buffer,
java.nio.channels.ReadableByteChannel channel)
|
int |
getCount(int count)
Parses the shpfile counting the records. |
ShapefileHeader |
getHeader()
Get the header. |
void |
goTo(int offset)
Needs better data, what is the requirements for offset? |
boolean |
hasNext()
If there exists another record. |
static void |
main(java.lang.String[] args)
|
ShapefileReader.Record |
nextRecord()
Fetch the next record information. |
static ShapefileHeader |
readHeader(java.nio.channels.ReadableByteChannel channel,
boolean strict)
A short cut for reading the header from the given channel. |
ShapefileReader.Record |
recordAt(int offset)
Sets the current location of the byteStream to offset and returns the next record. |
void |
setHandler(ShapeHandler handler)
|
java.lang.Object |
shapeAt(int offset)
TODO needs better java docs!!! |
boolean |
supportsRandomAccess()
|
int |
transferTo(ShapefileWriter writer,
int recordNum,
double[] bounds)
Transfer (by bytes) the data at the current record to the ShapefileWriter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ShapefileReader(java.nio.channels.ReadableByteChannel channel, boolean strict, boolean useMemoryMapped, Lock lock) throws java.io.IOException, ShapefileException
channel
- The ReadableByteChannel this reader will use.strict
- True to make the header parsing throw Exceptions if the
version or magic number are incorrect.
java.io.IOException
- If problems arise.
ShapefileException
- If for some reason the file contains invalid records.public ShapefileReader(java.nio.channels.ReadableByteChannel channel, Lock lock) throws java.io.IOException, ShapefileException
channel
-
java.io.IOException
ShapefileException
Method Detail |
public static ShapefileHeader readHeader(java.nio.channels.ReadableByteChannel channel, boolean strict) throws java.io.IOException
channel
- The channel to read from.strict
- True to make the header parsing throw Exceptions if the
version or magic number are incorrect.
java.io.IOException
- If problems arise.public static java.nio.ByteBuffer ensureCapacity(java.nio.ByteBuffer buffer, int size, boolean useMemoryMappedBuffer)
public static int fill(java.nio.ByteBuffer buffer, java.nio.channels.ReadableByteChannel channel) throws java.io.IOException
java.io.IOException
public ShapefileHeader getHeader()
public void close() throws java.io.IOException
java.io.IOException
- If errors occur while closing the channel.public boolean supportsRandomAccess()
public boolean hasNext() throws java.io.IOException
java.io.IOException
public int transferTo(ShapefileWriter writer, int recordNum, double[] bounds) throws java.io.IOException
bounds
- double array of length four for transfering the bounds into
java.io.IOException
public ShapefileReader.Record nextRecord() throws java.io.IOException
java.io.IOException
public void goTo(int offset) throws java.io.IOException, java.lang.UnsupportedOperationException
offset
-
java.io.IOException
java.lang.UnsupportedOperationException
public java.lang.Object shapeAt(int offset) throws java.io.IOException, java.lang.UnsupportedOperationException
offset
-
java.io.IOException
java.lang.UnsupportedOperationException
public ShapefileReader.Record recordAt(int offset) throws java.io.IOException, java.lang.UnsupportedOperationException
offset
- If using an shx file the offset would be: 2 *
(index.getOffset(i))
java.io.IOException
- thrown in a read error occurs
java.lang.UnsupportedOperationException
- thrown if not a random access filepublic int getCount(int count) throws DataSourceException
DataSourceException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void setHandler(ShapeHandler handler)
handler
- The handler to set.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |