in baremaps-core/src/main/java/org/apache/baremaps/storage/shapefile/internal/DbaseByteReader.java [232:285]
private void loadDescriptor() throws IOException {
try {
this.dbaseVersion = getByteBuffer().get();
getByteBuffer().get(this.dbaseLastUpdate);
getByteBuffer().order(ByteOrder.LITTLE_ENDIAN);
this.rowCount = getByteBuffer().getInt();
this.firstRecordPosition = getByteBuffer().getShort();
this.recordLength = getByteBuffer().getShort();
getByteBuffer().order(ByteOrder.BIG_ENDIAN);
getByteBuffer().get(this.reservedFiller1);
this.reservedIncompleteTransaction = getByteBuffer().get();
this.reservedEncryptionFlag = getByteBuffer().get();
getByteBuffer().get(this.reservedFreeRecordThread);
getByteBuffer().get(this.reservedMultiUser);
this.reservedMDXFlag = getByteBuffer().get();
// Translate code page value to a known charset.
this.codePage = getByteBuffer().get();
if (this.charset == null) {
try {
this.charset = toCharset(this.codePage);
} catch (UnsupportedCharsetException e) {
// Warn the caller that he will have to perform is own conversions.
}
}
getByteBuffer().get(this.reservedFiller2);
while (getByteBuffer().position() < this.firstRecordPosition - 1) {
DBaseFieldDescriptor fd = new DBaseFieldDescriptor(getByteBuffer());
this.fieldsDescriptors.add(fd);
// loop until you hit the 0Dh field terminator
}
this.descriptorTerminator = getByteBuffer().get();
// If the last character read after the field descriptor isn't 0x0D, the expected mark has not
// been found and the DBF is corrupted.
if (this.descriptorTerminator != 0x0D) {
throw new DbaseException("File descriptor problem");
}
} catch (BufferUnderflowException e) {
// This exception doesn't denote a trouble of file opening because the file has been checked
// before
// the calling of this private function.
// Therefore, an internal structure problem cause maybe a premature End of file or anything
// else, but the only thing
// we can conclude is : we are not before a device trouble, but a file format trouble.
throw new DbaseException("File descriptor problem");
}
}