コード例 #1
0
ファイル: DBFFileIO.java プロジェクト: ameltzer/mapapplet
  /**
   * This helper method loads just the .dbf file header portion into the mapTable argument using the
   * dis stream.
   *
   * @param dis The stream reading from the .dbf file.
   * @param mapTable The dbf table being loadd.
   * @throws IOException Thrown when the stream fails.
   */
  private void loadHeader(DataInputStream dis, DBFTable mapTable) throws IOException {
    // DBF file type (0)
    byte dbfFileType = dis.readByte();
    mapTable.setFileType(dbfFileType);

    // LAST UPDATE (1-3)
    int year = 1900 + dis.readByte();
    int month = dis.readByte();
    int day = dis.readByte();
    mapTable.setLastModifiedDate(year, month, day);

    // NUMBER OF RECORDS IN FILE (4-7)
    int numberOfRecordsInFile = readLittleEndianInt(dis);
    mapTable.setNumberOfRecords(numberOfRecordsInFile);

    // POSITION OF FIRST DATA RECORDED (8-9)
    short positionOfFirstDataRecorded = readLittleEndianShort(dis);
    mapTable.setPositionOfFirstDataRecorded(positionOfFirstDataRecorded);

    // LENGTH OF ONE DATA RECORD, INCLUDING DELETE FLAG (10-11)
    short dataRecordLength = readLittleEndianShort(dis);
    mapTable.setDataRecordLength(dataRecordLength);

    // ZEROES (12-13)
    short zeroes = readLittleEndianShort(dis);
    mapTable.setZeroes(zeroes);

    // DBASE IV Transaction Flag (14)
    byte dbaseTransactionFlag = dis.readByte();
    mapTable.setDbaseTransactionFlag(dbaseTransactionFlag);

    // DBASE IV Encryption Flag (15)
    byte dbaseEncryptionFlag = dis.readByte();
    mapTable.setDbaseEncryptionFlag(dbaseEncryptionFlag);

    // Multiuser Processing 12 Bytes (16-27)
    int[] mup = new int[3];
    mup[0] = readLittleEndianInt(dis);
    mup[1] = readLittleEndianInt(dis);
    mup[2] = readLittleEndianInt(dis);
    mapTable.setMup(mup);

    // TABLE FLAGS (28)
    byte tableFlags = dis.readByte();
    mapTable.setFlags(tableFlags);

    // CODE PAGE MARK/LANGUAGE DRIVER ID (29)
    byte pageMark = dis.readByte();
    mapTable.setCodePageMark(pageMark);

    // RESERVED, CONTAINS 0x00 (30-31)
    short reserved = readLittleEndianShort(dis);
    mapTable.setReserved(reserved);
  }