Class DBF

java.lang.Object
io.github.zazalng.DBF

public final class DBF extends Object
Minimal DBF reader focused on reading and accessing DBF data.

This implementation aims to be conservative and extensible, focusing on core DBF file features like reading the header, field descriptors, and all data records as a snapshot. It also supports up to 60 charsets possible for text encoding.

Key Features:
  • Read header and field descriptors.
  • Read all records as a snapshot at construction and on reload().
Limitations / Notes:
  • Memo fields (.dbt/.fpt/.dbt-like memo) are not parsed here (placeholder).
  • Visual FoxPro-specific binary types, timestamps, and some Level 7 features are partially unsupported.
Since:
1.0.0
Version:
1.0.0
Author:
Zazalng
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    DBF(Path path)
    Constructs a new DBF reader instance and immediately attempts to load the file data.
    DBF(Path path, DBFEncoding encoding)
    Constructs a new DBF reader instance with Enforce with forcing Decode with DBFEncoding and immediately attempts to load the file data.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets a list of field descriptors (columns) as defined in the DBF header.
    Gets the parsed header information for the DBF file.
    Gets the list of all data records read from the DBF file.
    Gets the version/dialect of the DBF file format.
    void
    Clears the current data and reloads the DBF file from the disk.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DBF

      public DBF(Path path, DBFEncoding encoding) throws IOException
      Constructs a new DBF reader instance with Enforce with forcing Decode with DBFEncoding and immediately attempts to load the file data.
      Parameters:
      path - The path to the DBF file. Must not be null.
      encoding - The character encoding to use for text fields. If null, defaults based on header info.
      Throws:
      IOException - If an I/O error occurs while reading the file.
      NullPointerException - If the provided path is null.
    • DBF

      public DBF(Path path) throws IOException
      Constructs a new DBF reader instance and immediately attempts to load the file data.
      Parameters:
      path - The path to the DBF file. Must not be null.
      Throws:
      IOException - If an I/O error occurs while reading the file.
      NullPointerException - If the provided path is null.
  • Method Details

    • reload

      public void reload() throws IOException
      Clears the current data and reloads the DBF file from the disk. This will re-read the header and all records, updating the internal state.
      Throws:
      IOException - If an I/O error occurs while reading the file.
    • getHeader

      public DBFHeader getHeader()
      Gets the parsed header information for the DBF file.
      Returns:
      The DBFHeader object.
    • getFields

      public List<DBFField> getFields()
      Gets a list of field descriptors (columns) as defined in the DBF header.
      Returns:
      An unmodifiable List of DBFField objects.
    • getRecords

      public List<DBFRow> getRecords()
      Gets the list of all data records read from the DBF file. This is a snapshot taken during the last load(DBFEncoding) or reload() call.
      Returns:
      An unmodifiable List of DBFRow objects.
    • getVersion

      public DBFVersion getVersion()
      Gets the version/dialect of the DBF file format.
      Returns:
      The DBFVersion of the file.