public class DbfFile
extends java.lang.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(java.lang.String file)
For compatibilty reasons, this method is a wrapper to the new with
Charset functions.
|
|
DbfFile(java.lang.String file,
java.nio.charset.Charset charset)
Constructor, opens the file and reads the header infomation.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
byte[] |
GetDbfRec(long row)
fetches the rowth row of the file
|
java.lang.String |
getFieldName(int col) |
java.lang.String |
getFieldType(int col) |
long |
getFileSize()
Returns the size of the database file.
|
java.lang.Double[] |
getFloatCol(int col)
Fetches a column of Double from the database file.
|
java.lang.Double[] |
getFloatCol(int col,
int start,
int end)
Fetches a part column of Double from the database file.
|
java.lang.Integer[] |
getIntegerCol(int col)
Fetches a column of Integers from the database file.
|
java.lang.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.
|
java.lang.String |
getLastUpdate()
Returns the date of the last update of the file as a string.
|
java.lang.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.
|
java.lang.String[] |
getStringCol(int col)
Fetches a column of Strings from the database file.
|
java.lang.String[] |
getStringCol(int col,
int start,
int end)
Fetches a part column of Strings from the database file.
|
static void |
main(java.lang.String[] args) |
protected java.util.Date |
parseDate(java.lang.String s) |
java.util.Vector |
ParseDbfRecord(long row)
fetches the rowth row of the file and parses it into an vector
of objects.
|
java.util.Vector |
ParseRecord(byte[] rec)
Parses the record stored in the StringBuffer rec into a vector of
objects
|
java.lang.Object |
ParseRecordColumn(byte[] rec,
int wantedCol) |
public DbfFieldDef[] fielddef
public static final java.text.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(java.lang.String file) throws java.io.IOException, DbfFileException
file
- file namejava.io.IOException
DbfFileException
public DbfFile(java.lang.String file, java.nio.charset.Charset charset) throws java.io.IOException, DbfFileException
file
- The file to be opened, includes path and .dbfjava.io.IOException
- If the file can't be opened.DbfFileException
- If there is an error reading header.public java.lang.String getLastUpdate()
public int getLastRec()
public int getRecSize()
public int getNumFields()
public java.lang.String getFieldName(int col)
public java.lang.String getFieldType(int col)
public long getFileSize()
public java.lang.StringBuffer GetNextDbfRec() throws java.io.IOException
java.io.IOException
- on read error.public byte[] GetDbfRec(long row) throws java.io.IOException
row
- - the row to fetchjava.io.IOException
- on read error.public java.util.Vector ParseDbfRecord(long row) throws java.io.IOException
row
- - the row to fetchjava.io.IOException
- on read error.public java.lang.Object ParseRecordColumn(byte[] rec, int wantedCol) throws java.lang.Exception
java.lang.Exception
public java.util.Vector ParseRecord(byte[] rec)
rec
- the record to be parsed.public java.lang.Integer[] getIntegerCol(int col) throws java.io.IOException, DbfFileException
col
- - the column to fetchjava.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public java.lang.Integer[] getIntegerCol(int col, int start, int end) throws java.io.IOException, DbfFileException
col
- - the column to fetchstart
- - the row to start fetching fromend
- - the row to stop fetching at.java.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public java.lang.Double[] getFloatCol(int col) throws DbfFileException, java.io.IOException
col
- - the column to fetchjava.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public java.lang.Double[] getFloatCol(int col, int start, int end) throws DbfFileException, java.io.IOException
col
- - the column to fetchstart
- - the row to start fetching fromend
- - the row to stop fetching at.java.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public java.lang.String[] getStringCol(int col) throws DbfFileException, java.io.IOException
col
- - the column to fetchjava.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public java.lang.String[] getStringCol(int col, int start, int end) throws DbfFileException, java.io.IOException
col
- - the column to fetchstart
- - the row to start fetching fromend
- - the row to stop fetching at.java.io.IOException
- - on read errorDbfFileException
- - column is not an Integer.public void close() throws java.io.IOException
java.io.IOException
protected java.util.Date parseDate(java.lang.String s) throws java.text.ParseException
java.text.ParseException
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception