Package nl.tudelft.simulation.dsol.animation.gis.io.esri

## Class DbfReader

- java.lang.Object
- - nl.tudelft.simulation.dsol.animation.gis.io.esri.DbfReader

All Implemented Interfaces:
  `Serializable`

    public class DbfReader
    extends Object
    implements Serializable

This class reads a dbf file (in dBase III format), as used in ESRI ShapeFiles.

Copyright (c) 2020-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.

The dsol-animation-gis project is based on the gisbeans project that has been part of DSOL since 2002, originally by Peter Jacobs and Paul Jacobs.

Author:
  Alexander Verbraeck
See Also:
  Serialized Form

### Constructor Summary

Constructors
`DbfReader​(URL dbfFile)` Construct a DbfReader.

### Method Summary

All Methods Instance Methods Concrete Methods
`String[]` `getColumnNames()` returns the columnNames.
`String[]` `getRow​(int rowNumber)` returns the row.
`int[]` `getRowNumbers​(String attribute, String columnName)` returns the array of rowNumbers belonging to a attribute/column pair.
`String[][]` `getRows()` returns a table of all attributes stored for the particular dbf-file.
`boolean` `isCache()` may we cache parsed data for a session.
`void` `setCache​(boolean cache)` Set whether caching is allowed or not.

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

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

### Constructor Detail

#### DbfReader

    public DbfReader​(URL dbfFile)
              throws IOException

Construct a DbfReader.

Parameters:
  `dbfFile` - URL; the URL of the dbfFile
Throws:
  `IOException` - whenever url does not occur to exist.

### Method Detail

#### getColumnNames

    public String[] getColumnNames()

returns the columnNames.

Returns:
  String[] the columnNames

#### getRow

    public String[] getRow​(int rowNumber)
                    throws IOException,
                           IndexOutOfBoundsException

returns the row.

Parameters:
  `rowNumber` - int; the rowNumber
Returns:
  String[] the attributes of the row
Throws:
  `IOException` - on read failure
  `IndexOutOfBoundsException` - whenever the rowNumber > numRecords

#### getRows

    public String[][] getRows()
                       throws IOException

returns a table of all attributes stored for the particular dbf-file.

Returns:
  String[][] a table of attributes
Throws:
  `IOException` - an IOException

#### getRowNumbers

    public int[] getRowNumbers​(String attribute,
                               String columnName)
                        throws IOException

returns the array of rowNumbers belonging to a attribute/column pair.

Parameters:
  `attribute` - String; the attribute value
  `columnName` - String; the name of the column
Returns:
  int[] the array of shape numbers.
Throws:
  `IOException` - on read failure

#### isCache

    public boolean isCache()

may we cache parsed data for a session. If false, every getRows results in IO activity. If true data is stored inMemory

Returns:
  Returns the cache.

#### setCache

    public void setCache​(boolean cache)

Set whether caching is allowed or not.

Parameters:
  `cache` - boolean; The caching preference to set