Class DbfWriter
java.lang.Object
ch.so.agi.gretl.internal.shapefile.core.DbfWriter
- All Implemented Interfaces:
AutoCloseable
Low-level writer for the
.dbf attribute table (dBASE III).
The header is written first with a record count of 0 and patched at the end via patchRecordCount(int). Records are written one at a time; nothing is buffered.
Header geometry matches DbfReader: headerLength = 32 + 32 * numFields + 1
(including the 0x0D field terminator) and recordLength = 1 + sum(fieldLengths)
(including the leading deleted flag).
The FileChannel is owned by ShapefileDatasetWriter; close() therefore
does not close the channel.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intvoidpatchRecordCount(int recordCount) Patches the 4-byte little-endian record count at offset 4 in the header.intvoidWrites the trailing0x1Aend-of-file marker at the current channel position.voidwriteHeader(int recordCount) Writes the full DBF header at the start of the file with the given record count.voidwriteRecord(Object[] values) Appends a single record at the current channel position.
-
Constructor Details
-
DbfWriter
-
-
Method Details
-
headerLength
public int headerLength() -
recordLength
public int recordLength() -
writeHeader
Writes the full DBF header at the start of the file with the given record count.- Throws:
IOException
-
writeRecord
Appends a single record at the current channel position.- Throws:
IOExceptionShapefileMappingException
-
writeEndOfFile
Writes the trailing0x1Aend-of-file marker at the current channel position.- Throws:
IOException
-
patchRecordCount
Patches the 4-byte little-endian record count at offset 4 in the header.- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-