|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnl.knaw.dans.common.dbflib.Table
public class Table
Represents a single table in a xBase database. A table is represented by a single
.DBF file. Some tables have an associated .DBT file to store memo field data.
| Constructor Summary | |
|---|---|
Table(File tableFile)
Creates a new Table object. |
|
Table(File tableFile,
String charsetName)
Creates a new Table object. |
|
Table(File tableFile,
Version version,
List<Field> fields)
As Table(File, Version, List, String) but uses the platform's default character set. |
|
Table(File tableFile,
Version version,
List<Field> fields,
String charsetName)
Creates a new Table object. |
|
| Method Summary | |
|---|---|
void |
addRecord(Object... fieldValues)
Constructs and adds a record. |
void |
addRecord(Record record)
Adds a record to this table. |
void |
close()
Closes this table for reading and writing. |
void |
delete()
Closes and deletes the underlying table file and associated files. |
void |
deleteRecordAt(int index)
Flags the record at index as "deleted". |
String |
getCharsetName()
Returns the name of the character set used to read and write from/to this table file. |
List<Field> |
getFields()
Returns a List of Field objects, which provide a description of each field
(column) in the table. |
Date |
getLastModifiedDate()
Returns the date on which this table was last modified. |
String |
getName()
Returns the name of the table, including the extension. |
Record |
getRecordAt(int index)
Returns the record at index. |
int |
getRecordCount()
Returns the record count. |
Version |
getVersion()
Returns the version of DBF use to write to the table file. |
void |
open()
Opens the table for reading and writing. |
void |
open(IfNonExistent ifNonExistent)
Opens the table for reading and writing. |
void |
pack()
Physically remove the records currently flagged as "deleted". |
Iterator<Record> |
recordIterator()
Returns a Record iterator. |
Iterator<Record> |
recordIterator(boolean includeDeleted)
Returns a Record iterator. |
void |
updateRecordAt(int index,
Record record)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Table(File tableFile)
throws IllegalArgumentException
Table object. A File object representing the
.DBF file must be provided. To read from or write to the table it must first be
opened.
tableFile - a File object representing the .DBF file that
stores this table's data.
IllegalArgumentException - if tableFile is nullopen(IfNonExistent)
public Table(File tableFile,
String charsetName)
throws IllegalArgumentException
File object representing the .DBF file
must be provided. To read from or write to the table it must first be opened.
tableFile - a File object representing the .DBF file that
stores this table's data.charsetName - the charset to use for reading and writing this file
IllegalArgumentException - if tableFile is nullopen(IfNonExistent)
public Table(File tableFile,
Version version,
List<Field> fields,
String charsetName)
throws InvalidFieldTypeException,
InvalidFieldLengthException
Note: if the .DBF file already exists aFields will be
overwritten by the values in the existing file when opened. To replace an existing table,
first delete it and then create and open a new Table object.
tableFile - the .DBF file that contains the table dataversion - the dBase version to supportfields - the fields to create if this is a new tablecharsetName - the charset to use for reading and writing this file
IllegalArgumentException - if aTableField is null
InvalidFieldLengthException
InvalidFieldTypeExceptionopen(IfNonExistent)
public Table(File tableFile,
Version version,
List<Field> fields)
throws InvalidFieldTypeException,
InvalidFieldLengthException
Table(File, Version, List, String) but uses the platform's default character set.
InvalidFieldTypeException
InvalidFieldLengthException| Method Detail |
|---|
public void open()
throws IOException,
CorruptedTableException
Table.open(IfNonExistent.ERROR)
IOException - if the table file does not exist or could not be opened
CorruptedTableException - if the header of the table file was corrupt
public void open(IfNonExistent ifNonExistent)
throws IOException,
CorruptedTableException
ifNonExistent - what to do if the table file does not exist yet
IOException - if the table does not exist or could be opened
CorruptedTableException - if the header of the table file was corrupt
public void close()
throws IOException
IOException - if the table file or an associated file cannot be closed
public void delete()
throws IOException
IOException - if the table file or an associated file cannot be closed or deletedpublic Date getLastModifiedDate()
public String getName()
public List<Field> getFields()
List of Field objects, which provide a description of each field
(column) in the table. The order of the Field objects is guaranteed to be the
same as the order of the fields in each record returned. A new copy of the field list is
returned on each call.
public Iterator<Record> recordIterator()
Record iterator. Note that, to use the iterator the table must be opened.
This iterator skips the records flagged as "deleted".
Record iteratorRecord,
recordIterator(boolean)public Iterator<Record> recordIterator(boolean includeDeleted)
Record iterator. Note that, to use the iterator the table must be opened.
If includeDeleted is true, records flagged as "deleted" are
included in the iteration.
includeDeleted - if true deleted records are returned, otherwise not
Record iterator
public void addRecord(Object... fieldValues)
throws IOException,
DbfLibException
IOException - if the record could not be written to the database file
CorruptedTableException - if the table was corrupt
ValueTooLargeException - if a field value exceeds the length of its corresponding field
RecordTooLargeException - if more field values are provided than there are field in
this table
DbfLibException
public void addRecord(Record record)
throws IOException,
DbfLibException
record - the record to add.
IOException - if the record could not be written to the database file
CorruptedTableException - if the table was corrupt
ValueTooLargeException - if a field value exceeds the length of its corresponding field
DbfLibExceptionRecord
public void updateRecordAt(int index,
Record record)
throws IOException,
DbfLibException
IOException
DbfLibException
public void deleteRecordAt(int index)
throws IOException
index as "deleted". To physically remove "deleted" records,
a call to pack() is necessary.
index - the index of the record to delete
IOException
public Record getRecordAt(int index)
throws IOException,
CorruptedTableException
NoSuchElementException is thrown. Attention: records marked as deleted are
returned.
index - the zero-based index of the record
IOException
CorruptedTableException
public void pack()
throws IOException,
DbfLibException
IOException
DbfLibExceptionpublic String getCharsetName()
public Version getVersion()
public int getRecordCount()
pack()
pack(),
Record.isMarkedDeleted()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||