ucar.unidata.gis.shapefile
Class DbaseFile

java.lang.Object
  extended by ucar.unidata.gis.shapefile.DbaseFile

public class DbaseFile
extends Object

Class to read a dbase file in its entirety.

Version:
$Id: DbaseFile.java,v 1.9 2005/05/13 18:29:48 jeffmc Exp $
Author:
Kirk Waters, NOAA Coastal Services Center, 1997., Russ Rew, modified to restrict access to read-only

Field Summary
static int DBASE5DOS
          _more_
static int DBASE5WIN
          _more_
static int DBASEIII
          _more_
static int DBASEIV
          _more_
 
Constructor Summary
DbaseFile(File file)
           
DbaseFile(InputStream s)
          _more_
DbaseFile(String spec)
           
DbaseFile(URL url)
           
 
Method Summary
 boolean[] getBooleansByName(String Name)
          Extract the boolean array of data for a field by Name.
 double[] getDoublesByName(String Name)
          Extract the double array of data for a field by Name.
 DbaseData getField(int index)
          Extract the data for a field by field index number.
 DbaseData getField(String Name)
          Extract the data for a given field by name.
 String getFieldName(int i)
          Get the name of a field by column number.
 String[] getFieldNames()
          Get a list of all the field names in the dbase file
 int getNumFields()
          Get the number of fields in the file.
 int getNumRecords()
           
 String[] getStringsByName(String Name)
          Extract the string array of data for a field by Name.
 boolean isLoaded()
           
 int loadData()
          Load the dbase file data.
 int loadHeader()
          Load the dbase file header.
static void main(String[] args)
          Test program, dumps a Dbase file to stdout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DBASEIII

public static int DBASEIII
_more_


DBASEIV

public static int DBASEIV
_more_


DBASE5DOS

public static int DBASE5DOS
_more_


DBASE5WIN

public static int DBASE5WIN
_more_

Constructor Detail

DbaseFile

public DbaseFile(URL url)
          throws MalformedURLException,
                 IOException
Parameters:
url - URL to the *.dbf file
Throws:
IOException
MalformedURLException

DbaseFile

public DbaseFile(String spec)
          throws IOException
Parameters:
spec - Location of the *.dbf file, as either a URL or filename
Throws:
IOException

DbaseFile

public DbaseFile(File file)
Parameters:
file - A file object of the *.dbf file.

DbaseFile

public DbaseFile(InputStream s)
_more_

Parameters:
s -
Method Detail

loadHeader

public int loadHeader()
Load the dbase file header.

Returns:
0 for success, -1 for failure

loadData

public int loadData()
Load the dbase file data.

Returns:
0 for success, -1 for failure

getField

public DbaseData getField(int index)
Extract the data for a field by field index number.

Parameters:
index - Column number of the field to extract.
Returns:
A DbaseData object if the column is within bounds. Otherwise, null.

getField

public DbaseData getField(String Name)
Extract the data for a given field by name.

Parameters:
Name - String with the name of the field to retrieve.
Returns:
A DbaseData object if the name was found or null if not found

getDoublesByName

public double[] getDoublesByName(String Name)
Extract the double array of data for a field by Name.

Parameters:
Name - String with the name of the field to retrieve
Returns:
A double[] if valid numeric field, otherwise null

getStringsByName

public String[] getStringsByName(String Name)
Extract the string array of data for a field by Name.

Parameters:
Name - String with the name of the field to retrieve
Returns:
A String[] if valid character field, otherwise null

getBooleansByName

public boolean[] getBooleansByName(String Name)
Extract the boolean array of data for a field by Name.

Parameters:
Name - String with the name of the field to retrieve
Returns:
A boolean[] if valid character field, otherwise null

getFieldName

public String getFieldName(int i)
Get the name of a field by column number.

Parameters:
i - The column number of the field name.
Returns:
A String with the field name or null if out of bounds

getFieldNames

public String[] getFieldNames()
Get a list of all the field names in the dbase file

Returns:
A String array of all the field names

getNumFields

public int getNumFields()
Get the number of fields in the file.

Returns:
number of fields

getNumRecords

public int getNumRecords()
Returns:
number of records in the dbase file

isLoaded

public boolean isLoaded()
Returns:
Boolean true if the data has been loaded, otherwise false.

main

public static void main(String[] args)
Test program, dumps a Dbase file to stdout.

Parameters:
args -