DbaseFileReader class
A DbaseFileReader is used to read a dbase III format file.
The general use of this class is:
FileChannel in = FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = DbaseFileReader( in ) Object[] fields = new
Objectr.getHeader().getNumFields()
; while (r.hasNext()) {
r.readEntry(fields); // do stuff } r.close();
For consumers who wish to be a bit more selective with their reading of rows, the
Row object has been added. The semantics are the same as using the readEntry method, but remember
that the Row object is always the same. The values are parsed as they are read, so it pays to
copy them out (as each call to Row.read() will result in an expensive String parse). EACH CALL TO readEntry OR readRow ADVANCES THE FILE!
An example of using the Row method of reading:
FileChannel in = FileInputStream("thefile.dbf").getChannel();
DbaseFileReader r = DbaseFileReader( in ) int fields =
r.getHeader().getNumFields(); while (r.hasNext()) { DbaseFileReader.Row row =
r.readRow(); for (int i = 0; i < fields; i++) { // do stuff Foo.bar(
row.read(i) ); } } r.close();
@author Ian Schneider, Andrea Aaime
Constructors
- DbaseFileReader(AFileReader? afileReader, [Charset? stringCharset, TimeZones? timeZone])
Properties
- afileReader ↔ AFileReader?
-
getter/setter pair
- buffer ↔ LByteBuffer?
-
getter/setter pair
-
bytes
↔ List<
int> ? -
getter/setter pair
- cnt ↔ int
-
getter/setter pair
- currentOffset ↔ int
-
getter/setter pair
- endian ↔ Endian
-
getter/setter pair
-
fieldLengths
↔ List<
int> ? -
getter/setter pair
-
fieldOffsets
↔ List<
int> ? -
getter/setter pair
-
fieldTypes
↔ List<
int> ? -
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- header ↔ DbaseFileHeader?
-
getter/setter pair
- MILLISECS_PER_DAY → int
-
final
- oneBytePerChar ↔ bool
-
getter/setter pair
- row ↔ Row?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stringCharset ↔ Charset?
-
getter/setter pair
- timeZone ↔ TimeZones?
-
getter/setter pair
Methods
-
bufferCheck(
) → Future< void> -
close(
) → void - Clean up all resources associated with this reader.Highly recomended.
-
fastParse(
List< int> bytes, int fieldOffset, int fieldLen) → String - Performs a faster byte[] to String conversion under the assumption the content is represented with one byte per char
-
fill(
LByteBuffer buffer, AFileReader channel) → Future< int> -
getHeader(
) → DbaseFileHeader - Get the header from this file. The header is read upon instantiation.
-
handleFloat(
int fieldOffset, dynamic object, int fieldLen) → dynamic -
hasNext(
) → bool - Query the reader as to whether there is another record.
-
id(
) → String -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
) → Future< void> -
read(
) → Future - Reads the next record into memory. You need to use this directly when reading only a subset of the fields using {@link #readField(int)}.
-
readEntry(
) → Future< List?> - Get the next record (entry). Will return a array of values.
-
readEntryInto(
List entry) → Future< List?> - Copy the next entry into the array.
-
readEntryWithOffset(
List entry, int offset) → Future< List?> - Copy the next record into the array starting at offset.
-
readField(
int fieldNum) → Future - Reads a single field from the current record and returns it. Remember to call {@link #read()} before starting to read fields from the dbf, and call it every time you need to move to the next record.
-
readObject(
int fieldOffset, int fieldNum) → Future -
readRow(
) → Future< Row?> -
skip(
) → void - Skip the next record.
-
toString(
) → String -
A string representation of this object.
inherited
-
transferTo(
DbaseFileWriter writer) → void - Transfer, by bytes, the next record to the writer. */
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited