Class DbfFile
java.lang.Object
org.geotools.dbffile.DbfFile
- All Implemented Interfaces:
AutoCloseable
This class represents a DBF (or DBase) file.
Construct it with a filename (including the .dbf) this causes the header and field definitions to be read.
Later queries return rows or columns of the database.
- Author:
- Ian Turton Centre for Computaional Geography, University of Leeds, LS2 9JT, 1998.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SimpleDateFormatstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()byte[]GetDbfRec(long row) fetches the rowth row of the filegetFieldName(int col) getFieldType(int col) longReturns the size of the database file.intReturns the number of records in the database file.Returns the date of the last update of the file as a string.gets the next record and returns it as a string.intReturns the number of fields in the records in the database file.intReturns the size of the records in the database file.static voidprotected DateParseRecordColumn(byte[] rec, int wantedCol) Get a field value from the dbf record data (byte[]) and the field index
-
Field Details
-
fielddef
-
DATE_PARSER
-
DBF_CENTURY
static final int DBF_CENTURY- See Also:
-
DBF_MAXLEN
static final int DBF_MAXLEN- See Also:
-
DBF_NAMELEN
static final int DBF_NAMELEN- See Also:
-
DBF3_MAXFIELDS
static final int DBF3_MAXFIELDS- See Also:
-
DBF4_MAXFIELDS
static final int DBF4_MAXFIELDS- See Also:
-
DBF_MAXFIELDS
static final int DBF_MAXFIELDS- See Also:
-
DBF_BUFFSIZE
static final int DBF_BUFFSIZE- See Also:
-
DBF_END_OF_DEFS
static final int DBF_END_OF_DEFS- See Also:
-
DBF_OK
static final int DBF_OK- See Also:
-
DBF_READ_HEAD
static final int DBF_READ_HEAD- See Also:
-
DBF_BAD_DBFID
static final int DBF_BAD_DBFID- See Also:
-
DBF_WRITE_HEAD
static final int DBF_WRITE_HEAD- See Also:
-
DBF_READ_DEFS
static final int DBF_READ_DEFS- See Also:
-
DBF_TOO_MANY_FIELDS
static final int DBF_TOO_MANY_FIELDS- See Also:
-
DBF_NO_FIELDS
static final int DBF_NO_FIELDS- See Also:
-
DBF_BAD_EODEFS
static final int DBF_BAD_EODEFS- See Also:
-
DBF_WRITE_DEFS
static final int DBF_WRITE_DEFS- See Also:
-
DBF_BAD_ITYPE
static final int DBF_BAD_ITYPE- See Also:
-
DBF_CANNOT_DO_MEMO
static final int DBF_CANNOT_DO_MEMO- See Also:
-
DBF_BAD_INT_WIDTH
static final int DBF_BAD_INT_WIDTH- See Also:
-
DBF_BAD_OFFSET
static final int DBF_BAD_OFFSET- See Also:
-
DBF_FLOATING_N
static final int DBF_FLOATING_N- See Also:
-
DBF_READ_DATA
static final int DBF_READ_DATA- See Also:
-
DBF_UNPRINT_DATA
static final int DBF_UNPRINT_DATA- See Also:
-
DBF_WRITE_DATA
static final int DBF_WRITE_DATA- See Also:
-
DBF_INT_EXP
static final int DBF_INT_EXP- See Also:
-
DBF_INT_REAL
static final int DBF_INT_REAL- See Also:
-
DBF_INT_JUNK
static final int DBF_INT_JUNK- See Also:
-
DBF_REC_DELETED
static final int DBF_REC_DELETED- See Also:
-
DBF_ALL_DELETED
static final int DBF_ALL_DELETED- See Also:
-
DBF_BAD_SIZEOF
static final int DBF_BAD_SIZEOF- See Also:
-
DBF_REC_TOO_LONG
static final int DBF_REC_TOO_LONG- See Also:
-
DBF_TOO_WIDE_FOR_INF
static final int DBF_TOO_WIDE_FOR_INF- See Also:
-
DBF_MALLOC_FIELD
static final int DBF_MALLOC_FIELD- See Also:
-
DBF_MALLOC
static final int DBF_MALLOC- See Also:
-
DBF_GET_DATE
static final int DBF_GET_DATE- See Also:
-
-
Constructor Details
-
DbfFile
protected DbfFile() -
DbfFile
-
DbfFile
Constructor, opens the file and reads the header infomation.- Parameters:
file- The file to be opened, includes path and .dbf- Throws:
IOException- If the file can't be opened.
-
-
Method Details
-
getLastUpdate
Returns the date of the last update of the file as a string. -
getLastRec
public int getLastRec()Returns the number of records in the database file. -
getRecSize
public int getRecSize()Returns the size of the records in the database file. -
getNumFields
public int getNumFields()Returns the number of fields in the records in the database file. -
getFieldName
-
getFieldType
-
getFileSize
public long getFileSize()Returns the size of the database file. -
GetNextDbfRec
gets the next record and returns it as a string. This method works on a sequential stream and can not go backwards. Only useful if you want to read the whole file in one.- Throws:
IOException- on read error.
-
GetDbfRec
fetches the rowth row of the file- Parameters:
row- - the row to fetch- Throws:
IOException- on read error.
-
ParseRecordColumn
Get a field value from the dbf record data (byte[]) and the field index- Parameters:
rec- the byte array representing the recordwantedCol- the wanted column- Returns:
- an object representing the field
- Throws:
Exception- if an Exception occurred
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
parseDate
- Throws:
ParseException
-
main
-