Class DbaseFile

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

public class DbaseFile extends Object
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 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

      public DbaseFile(URL url) throws MalformedURLException, IOException
      Instantiates a new dbase file.
      Parameters:
      url - URL to the *.dbf file
      Throws:
      MalformedURLException - the malformed url exception
      IOException - Signals that an I/O exception has occurred.
    • DbaseFile

      public DbaseFile(String spec) throws IOException
      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

      public DbaseFile(File file)
      Instantiates a new dbase file.
      Parameters:
      file - A file object of the *.dbf file.
    • DbaseFile

      public DbaseFile(InputStream s)
      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

      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 - the arguments