Package ucar.unidata.gis.shapefile
Class DbaseFile
java.lang.Object
ucar.unidata.gis.shapefile.DbaseFile
Class to read a dbase file in its entirety.
- Author:
- Kirk Waters, NOAA Coastal Services Center, 1997., Russ Rew, modified to restrict access to read-only
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean[]
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.getField
(int index) Extract the data for a field by field index number.Extract the data for a given field by name.getFieldName
(int i) Get the name of a field by column number.String[]
Get a list of all the field names in the dbase fileint
Get the number of fields in the file.int
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
Load the dbase file header.static void
Test program, dumps a Dbase file to stdout.
-
Field Details
-
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 Details
-
DbaseFile
Instantiates a new dbase file.- Parameters:
url
- URL to the *.dbf file- Throws:
MalformedURLException
- the malformed url exceptionIOException
- Signals that an I/O exception has occurred.
-
DbaseFile
Instantiates a new dbase file.- Parameters:
spec
- Location of the *.dbf file, as either a URL or filename- Throws:
IOException
- Signals that an I/O exception has occurred.
-
DbaseFile
Instantiates a new dbase file.- Parameters:
file
- A file object of the *.dbf file.
-
DbaseFile
Instantiates a new dbase file.- Parameters:
s
- the s
-
-
Method Details
-
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
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
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
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
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
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
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
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
Test program, dumps a Dbase file to stdout.- Parameters:
args
- the arguments
-