Class DbaseFileHeader

java.lang.Object
org.gvsig.fmap.dal.store.dbf.utils.DbaseFileHeader

public class DbaseFileHeader extends Object
Class to represent the header of a Dbase III 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

      public int removeColumn(String inFieldName)
      Remove a column from this DbaseFileHeader.
      Returns:
      index of the removed column, -1 if no found
    • getFieldDescription

      public DbaseFieldDescriptor getFieldDescription(int index)
      Return the Field Descriptor for the given field.
      Parameters:
      index - , the index of the requeted field description
      Returns:
      the dbase field descriptor.
    • getFieldDescription

      public DbaseFieldDescriptor getFieldDescription(String name)
    • getFieldIndex

      public int getFieldIndex(String name)
    • getLastUpdateDate

      public Date 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.UnsupportedVersionException
      org.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 in DbaseCodepage.dbfLdid and DbaseCodepage.ldidJava objects. See some others here: https://github.com/infused/dbf/blob/master/docs/supported_encodings.csv
    • write

      public void write(FileChannel out) throws IOException
      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

      public String getCharsetName()
    • getCharsetName

      public String getCharsetName(int ldid)
    • getOriginalCharset

      public String getOriginalCharset()
    • mappingEncoding

      public String mappingEncoding(String dbfEnconding)
    • 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