Package org.h2gis.functions.io.dbf.internal

## Class DbaseFileReader

- java.lang.Object
- - org.h2gis.functions.io.dbf.internal.DbaseFileReader

    public class DbaseFileReader
    extends Object

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
See Also:
  "http://svn.geotools.org/geotools/tags/2.3.1/plugin/shapefile/src/org/geotools/data/shapefile/dbf/DbaseFileReader.java"

### Constructor Summary

Constructors
`DbaseFileReader​(FileChannel channel, String forceEncoding)` Creates a new instance of DBaseFileReader

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Clean up all resources associated with this reader.Highly recomended.
`int` `getFieldCount()`
`org.h2.value.Value` `getFieldValue​(int row, int column)`
`DbaseFileHeader` `getHeader()` Get the header from this file.
`int` `getLengthFor​(int column)`
`protected long` `getPositionFor​(int row, int column)`
`int` `getRecordCount()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### DbaseFileReader

    public DbaseFileReader​(FileChannel channel,
                           String forceEncoding)
                    throws IOException

Creates a new instance of DBaseFileReader

Parameters:
  `channel` - The readable channel to use.
Throws:
  `IOException` - If an error occurs while initializing.

### Method Detail

#### getHeader

    public DbaseFileHeader getHeader()

Get the header from this file. The header is read upon instantiation.

Returns:
  The header associated with this file or null if an error occurred.

#### close

    public void close()
               throws IOException

Clean up all resources associated with this reader.Highly recomended.

Throws:
  `IOException` - If an error occurs.

#### getFieldValue

    public org.h2.value.Value getFieldValue​(int row,
                                            int column)
                                     throws IOException

Throws:
  `IOException`

#### getLengthFor

    public int getLengthFor​(int column)

#### getPositionFor

    protected long getPositionFor​(int row,
                                  int column)

#### getRecordCount

    public int getRecordCount()

#### getFieldCount

    public int getFieldCount()

Returns:
  The number of columns