| java.lang.Object org.geotools.data.shapefile.dbf.DbaseFileReader
All known Subclasses: org.geotools.data.shapefile.dbf.IndexedDbaseFileReader,
DbaseFileReader | public class DbaseFileReader (Code) | | A DbaseFileReader is used to read a dbase III format file.
The general use of this class is:
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in ) Object[] fields = new
Object[r.getHeader().getNumFields()]; while (r.hasNext()) {
r.readEntry(fields); // do stuff } r.close();
For consumers who wish to be a bit more selective with their reading
of rows, the Row object has been added. The semantics are the same as using
the readEntry method, but remember that the Row object is always the same.
The values are parsed as they are read, so it pays to copy them out (as each
call to Row.read() will result in an expensive String parse).
EACH CALL TO readEntry OR readRow ADVANCES THE FILE!
An example of using the Row method of reading:
FileChannel in = new FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = new DbaseFileReader( in ) int fields =
r.getHeader().getNumFields(); while (r.hasNext()) { DbaseFileReader.Row row =
r.readRow(); for (int i = 0; i < fields; i++) { // do stuff Foo.bar(
row.read(i) ); } } r.close();
author: Ian Schneider |
Inner Class :final public class Row | |
buffer | ByteBuffer buffer(Code) | | |
charBuffer | CharBuffer charBuffer(Code) | | |
currentOffset | protected int currentOffset(Code) | | |
decoder | CharsetDecoder decoder(Code) | | |
fieldLengths | int[] fieldLengths(Code) | | |
fieldTypes | char[] fieldTypes(Code) | | |
randomAccessEnabled | final protected boolean randomAccessEnabled(Code) | | |
useMemoryMappedBuffer | protected boolean useMemoryMappedBuffer(Code) | | |
DbaseFileReader | public DbaseFileReader(ReadableByteChannel channel, boolean useMemoryMappedBuffer) throws IOException(Code) | | Creates a new instance of DBaseFileReader
Parameters: channel - The readable channel to use. throws: IOException - If an error occurs while initializing. |
DbaseFileReader | public DbaseFileReader(ReadableByteChannel channel, boolean useMemoryMappedBuffer, Charset charset) throws IOException(Code) | | Creates a new instance of DBaseFileReader
Parameters: channel - The readable channel to use. throws: IOException - If an error occurs while initializing. |
close | public void close() throws IOException(Code) | | Clean up all resources associated with this reader.Highly recomended.
throws: IOException - If an error occurs. |
getHeader | public DbaseFileHeader getHeader()(Code) | | Get the header from this file. The header is read upon instantiation.
The header associated with this file or null if an erroroccurred. |
hasNext | public boolean hasNext()(Code) | | Query the reader as to whether there is another record.
True if more records exist, false otherwise. |
readEntry | public Object[] readEntry() throws IOException(Code) | | Get the next record (entry). Will return a new array of values.
throws: IOException - If an error occurs. A new array of values. |
readEntry | public Object[] readEntry(Object[] entry, int offset) throws IOException(Code) | | Copy the next record into the array starting at offset.
Parameters: entry - Th array to copy into. Parameters: offset - The offset to start at throws: IOException - If an error occurs. The same array passed in. |
readEntry | public Object[] readEntry(Object[] entry) throws IOException(Code) | | Copy the next entry into the array.
Parameters: entry - The array to copy into. throws: IOException - If an error occurs. The same array passed in. |
|
|