Class DbaseFileHeader
java.lang.Object
org.gvsig.fmap.dal.store.dbf.utils.DbaseFileHeader
Class to represent the header of a Dbase III file.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a column to this DbaseFileHeader.The type is one of (C N L or D) character, number, logical(true/false), or date.static DbaseFileHeaderfromFeatureType(org.gvsig.fmap.dal.feature.FeatureType featureType) static DbaseFileHeaderfromFeatureType(org.gvsig.fmap.dal.feature.FeatureType featureType, String charsetName) getCharsetName(int ldid) getFieldDescription(int index) Return the Field Descriptor for the given field.getFieldDescription(String name) intgetFieldIndex(String name) intReturn the length of the headerintGets the Language driver IDs (code page) defined on the file header (or guessed from the provided charset) Some examples: 01h DOS USA code page 437 02h DOS Multilingual code page 850 03h Windows ANSI code page 1252 04h Standard Macintosh 64h EE MS-DOS code page 852 65h Nordic MS-DOS code page 865 66h Russian MS-DOS code page 866 67h Icelandic MS-DOS 68h Kamenicky (Czech) MS-DOS 69h Mazovia (Polish) MS-DOS 6Ah Greek MS-DOS (437G) 6Bh Turkish MS-DOS 96h Russian Macintosh 97h Eastern European Macintosh 98h Greek Macintosh C8h Windows EE code page 1250 C9h Russian Windows CAh Turkish Windows CBh Greek Windows See the java equivalences inDbaseCodepage.dbfLdidandDbaseCodepage.ldidJavaobjects.Return the date this file was last updated.intReturn the number of fields in the records.intReturn the number of records in the fileintReturn the length of the records in bytes.mappingEncoding(String dbfEnconding) voidread(org.gvsig.utils.bigfile.BigByteBuffer2 in, String charsName, boolean allowDuplicatedFieldNames) Read the header data from the DBF file.intremoveColumn(String inFieldName) Remove a column from this DbaseFileHeader.voidsetNumRecords(int inNumRecords) Set the number of records in the fileorg.gvsig.fmap.dal.feature.EditableFeatureTypetoFeatureType(org.gvsig.fmap.dal.feature.EditableFeatureType featureType, boolean handleDatesAsStrings) voidwrite(FileChannel out) Write the header data to the DBF file.
-
Constructor Details
-
DbaseFileHeader
public DbaseFileHeader()DbaseFileHreader constructor comment.
-
-
Method Details
-
addColumn
public void addColumn(String fieldName, char fieldType, int fieldSize, int fieldPrecision, int fieldScale) throws org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeNotSuportedException Add a column to this DbaseFileHeader.The type is one of (C N L or D) character, number, logical(true/false), or date. The Field length is the total length in bytes reserved for this column. The decimal count only applies to numbers(N), and floating point values (F), and refers to the number of characters to reserve after the decimal point.- Throws:
org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeNotSuportedException
-
removeColumn
Remove a column from this DbaseFileHeader.- Returns:
- index of the removed column, -1 if no found
-
getFieldDescription
Return the Field Descriptor for the given field.- Parameters:
index- , the index of the requeted field description- Returns:
- the dbase field descriptor.
-
getFieldDescription
-
getFieldIndex
-
getLastUpdateDate
Return the date this file was last updated. -
getNumFields
public int getNumFields()Return the number of fields in the records. -
getNumRecords
public int getNumRecords()Return the number of records in the file -
getRecordLength
public int getRecordLength()Return the length of the records in bytes. -
getHeaderLength
public int getHeaderLength()Return the length of the header -
read
public void read(org.gvsig.utils.bigfile.BigByteBuffer2 in, String charsName, boolean allowDuplicatedFieldNames) throws org.gvsig.fmap.dal.exception.UnsupportedVersionException, org.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeNotSuportedException Read the header data from the DBF file.- Throws:
org.gvsig.fmap.dal.exception.UnsupportedVersionExceptionorg.gvsig.fmap.dal.feature.exception.AttributeFeatureTypeNotSuportedException
-
setNumRecords
public void setNumRecords(int inNumRecords) Set the number of records in the file -
getLanguageID
public int getLanguageID()Gets the Language driver IDs (code page) defined on the file header (or guessed from the provided charset) Some examples: 01h DOS USA code page 437 02h DOS Multilingual code page 850 03h Windows ANSI code page 1252 04h Standard Macintosh 64h EE MS-DOS code page 852 65h Nordic MS-DOS code page 865 66h Russian MS-DOS code page 866 67h Icelandic MS-DOS 68h Kamenicky (Czech) MS-DOS 69h Mazovia (Polish) MS-DOS 6Ah Greek MS-DOS (437G) 6Bh Turkish MS-DOS 96h Russian Macintosh 97h Eastern European Macintosh 98h Greek Macintosh C8h Windows EE code page 1250 C9h Russian Windows CAh Turkish Windows CBh Greek Windows See the java equivalences inDbaseCodepage.dbfLdidandDbaseCodepage.ldidJavaobjects. See some others here: https://github.com/infused/dbf/blob/master/docs/supported_encodings.csv -
write
Write the header data to the DBF file.- Parameters:
out- A channel to write to. If you have an OutputStream you can obtain the correct channel by using java.nio.Channels.newChannel(OutputStream out).- Throws:
IOException
-
getCharsetName
-
getCharsetName
-
getOriginalCharset
-
mappingEncoding
-
toFeatureType
public org.gvsig.fmap.dal.feature.EditableFeatureType toFeatureType(org.gvsig.fmap.dal.feature.EditableFeatureType featureType, boolean handleDatesAsStrings) throws org.gvsig.fmap.dal.exception.DataException - Throws:
org.gvsig.fmap.dal.exception.DataException
-
fromFeatureType
public static DbaseFileHeader fromFeatureType(org.gvsig.fmap.dal.feature.FeatureType featureType) throws org.gvsig.fmap.dal.exception.DataException - Throws:
org.gvsig.fmap.dal.exception.DataException
-
fromFeatureType
public static DbaseFileHeader fromFeatureType(org.gvsig.fmap.dal.feature.FeatureType featureType, String charsetName) throws org.gvsig.fmap.dal.exception.DataException - Throws:
org.gvsig.fmap.dal.exception.DataException
-