public class DbfFile extends Object
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.
| Modifier | Constructor and Description |
|---|---|
protected |
DbfFile() |
|
DbfFile(String file)
Constructor, opens the file and reads the header infomation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
StringBuffer |
GetDbfRec(int row)
fetches the rowth row of the file
|
String |
getFieldName(int row) |
String |
getFieldType(int row) |
int |
getFileSize()
Returns the size of the database file.
|
Double[] |
getFloatCol(int col)
Fetches a column of Double from the database file.
|
Double[] |
getFloatCol(int col,
int start,
int end)
Fetches a part column of Double from the database file.
|
Integer[] |
getIntegerCol(int col)
Fetches a column of Integers from the database file.
|
Integer[] |
getIntegerCol(int col,
int start,
int end)
Fetches a part column of Integers from the database file.
|
int |
getLastRec()
Returns the number of records in the database file.
|
String |
getLastUpdate()
Returns the date of the last update of the file as a string.
|
StringBuffer |
GetNextDbfRec()
gets the next record and returns it as a string.
|
int |
getNumFields()
Returns the number of fields in the records in the database file.
|
int |
getRecSize()
Returns the size of the records in the database file.
|
String[] |
getStringCol(int col)
Fetches a column of Strings from the database file.
|
String[] |
getStringCol(int col,
int start,
int end)
Fetches a part column of Strings from the database file.
|
static void |
main(String[] args) |
protected Date |
parseDate(String s) |
Vector |
ParseDbfRecord(int row)
fetches the rowth row of the file and parses it into an vector
of objects.
|
Vector |
ParseRecord(StringBuffer rec)
Parses the record stored in the StringBuffer rec into a vector of
objects
|
Object |
ParseRecordColumn(StringBuffer rec,
int wantedCol) |
public EndianDataInputStream dFile
public DbfFieldDef[] fielddef
public static final SimpleDateFormat DATE_PARSER
public static final int DBF_CENTURY
public static final int DBF_MAXLEN
public static final int DBF_NAMELEN
public static final int DBF3_MAXFIELDS
public static final int DBF4_MAXFIELDS
public static final int DBF_MAXFIELDS
public static final int DBF_BUFFSIZE
public static final int DBF_END_OF_DEFS
public static final int DBF_OK
public static final int DBF_READ_HEAD
public static final int DBF_BAD_DBFID
public static final int DBF_WRITE_HEAD
public static final int DBF_READ_DEFS
public static final int DBF_TOO_MANY_FIELDS
public static final int DBF_NO_FIELDS
public static final int DBF_BAD_EODEFS
public static final int DBF_WRITE_DEFS
public static final int DBF_BAD_ITYPE
public static final int DBF_CANNOT_DO_MEMO
public static final int DBF_BAD_INT_WIDTH
public static final int DBF_BAD_OFFSET
public static final int DBF_FLOATING_N
public static final int DBF_READ_DATA
public static final int DBF_UNPRINT_DATA
public static final int DBF_WRITE_DATA
public static final int DBF_INT_EXP
public static final int DBF_INT_REAL
public static final int DBF_INT_JUNK
public static final int DBF_REC_DELETED
public static final int DBF_ALL_DELETED
public static final int DBF_BAD_SIZEOF
public static final int DBF_REC_TOO_LONG
public static final int DBF_TOO_WIDE_FOR_INF
public static final int DBF_MALLOC_FIELD
public static final int DBF_MALLOC
public static final int DBF_GET_DATE
protected DbfFile()
public DbfFile(String file) throws IOException, DbfFileException
file - The file to be opened, includes path and .dbfIOException - If the file can't be opened.DbfFileException - If there is an error reading header.public String getLastUpdate()
public int getLastRec()
public int getRecSize()
public int getNumFields()
public String getFieldName(int row)
public String getFieldType(int row)
public int getFileSize()
public StringBuffer GetNextDbfRec() throws IOException
IOException - on read error.public StringBuffer GetDbfRec(int row) throws IOException
row - - the row to fetchIOException - on read error.public Vector ParseDbfRecord(int row) throws IOException
row - - the row to fetchIOException - on read error.public Object ParseRecordColumn(StringBuffer rec, int wantedCol) throws Exception
Exceptionpublic Vector ParseRecord(StringBuffer rec)
StringBuffer - rec - the record to be parsed.public Integer[] getIntegerCol(int col) throws IOException, DbfFileException
int - col - the column to fetchIOException - - on read errorDbfFileException - - column is not an Integer.public Integer[] getIntegerCol(int col, int start, int end) throws IOException, DbfFileException
int - col - the column to fetchint - start - the row to start fetching fromint - end - the row to stop fetching at.IOException - - on read errorDbfFileException - - column is not an Integer.public Double[] getFloatCol(int col) throws DbfFileException, IOException
int - col - the column to fetchIOException - - on read errorDbfFileException - - column is not an Integer.public Double[] getFloatCol(int col, int start, int end) throws DbfFileException, IOException
int - col - the column to fetchint - start - the row to start fetching fromint - end - the row to stop fetching at.IOException - - on read errorDbfFileException - - column is not an Integer.public String[] getStringCol(int col) throws DbfFileException, IOException
int - col - the column to fetchIOException - - on read errorDbfFileException - - column is not an Integer.public String[] getStringCol(int col, int start, int end) throws DbfFileException, IOException
int - col - the column to fetchint - start - the row to start fetching fromint - end - the row to stop fetching at.IOException - - on read errorDbfFileException - - column is not an Integer.public void close()
throws IOException
IOExceptionprotected Date parseDate(String s) throws ParseException
ParseExceptionCopyright © 2015. All rights reserved.