nFieldPos = Integer.parseInt(new String(pachRecord, nEntryOffset, _sizeFieldLength));
nFieldPos = Integer.parseInt(new String(pachRecord, nEntryOffset, _sizeFieldPos));
    public BinaryFile open(String pszFilename) throws IOException {        fileName = pszFilename;        fpDDF = new BinaryBufferedFile(pszFilename);        // Read the 24 byte leader.        byte[] achLeader = new byte[DDF_LEADER_SIZE];        if (fpDDF.read(achLeader) != DDF_LEADER_SIZE) {            destroy();            if (Debug.debugging("iso8211")) {                Debug.output("DDFModule: Leader is short on DDF file "                        + pszFilename);            }            return null;        }        // Verify that this appears to be a valid DDF file.        int i;        boolean bValid = true;        for (i = 0; i < (int) DDF_LEADER_SIZE; i++) {            if (achLeader[i] < 32 || achLeader[i] > 126) {                bValid = false;            }        }        if (achLeader[5] != '1' && achLeader[5] != '2' && achLeader[5] != '3') {            bValid = false;        }        if (achLeader[6] != 'L') {            bValid = false;        }        if (achLeader[8] != '1' && achLeader[8] != ' ') {            bValid = false;        }        // Extract information from leader.        if (bValid) {            _recLength = Integer.parseInt(new String(achLeader, 0, 5));            _interchangeLevel = achLeader[5];            _leaderIden = achLeader[6];            _inlineCodeExtensionIndicator = achLeader[7];            _versionNumber = achLeader[8];            _appIndicator = achLeader[9];            _fieldControlLength = Integer.parseInt(new String(achLeader, 10, 2));            _fieldAreaStart = Integer.parseInt(new String(achLeader, 12, 5));            _extendedCharSet = new String((char) achLeader[17] + ""                    + (char) achLeader[18] + "" + (char) achLeader[19]);            _sizeFieldLength = Integer.parseInt(new String(achLeader, 20, 1));            _sizeFieldPos = Integer.parseInt(new String(achLeader, 21, 1));            _sizeFieldTag = Integer.parseInt(new String(achLeader, 23, 1));            if (_recLength < 12 || _fieldControlLength == 0                    || _fieldAreaStart < 24 || _sizeFieldLength == 0                    || _sizeFieldPos == 0 || _sizeFieldTag == 0) {                bValid = false;            }            if (Debug.debugging("iso8211")) {                Debug.output("bValid = " + bValid + ", from "                        + new String(achLeader));                Debug.output(toString());            }        }        // If the header is invalid, then clean up, report the error        // and return.        if (!bValid) {            destroy();            if (Debug.debugging("iso8211")) {                Debug.error("DDFModule: File " + pszFilename                        + " does not appear to have a valid ISO 8211 header.");            }            return null;        }        if (Debug.debugging("iso8211")) {            Debug.output("DDFModule:  header parsed successfully");        }        /* -------------------------------------------------------------------- */        /* Read the whole record into memory. */        /* -------------------------------------------------------------------- */        byte[] pachRecord = new byte[_recLength];        System.arraycopy(achLeader, 0, pachRecord, 0, achLeader.length);        int numNewRead = pachRecord.length - achLeader.length;        if (fpDDF.read(pachRecord, achLeader.length, numNewRead) != numNewRead) {            if (Debug.debugging("iso8211")) {                Debug.error("DDFModule: Header record is short on DDF file "                        + pszFilename);            }            return null;        }        /* First make a pass counting the directory entries. */        int nFieldEntryWidth = _sizeFieldLength + _sizeFieldPos + _sizeFieldTag;        int nFieldDefnCount = 0;        for (i = DDF_LEADER_SIZE; i < _recLength; i += nFieldEntryWidth) {            if (pachRecord[i] == DDF_FIELD_TERMINATOR)                break;            nFieldDefnCount++;        }        /* Allocate, and read field definitions. */        paoFieldDefns = new Vector();        for (i = 0; i < nFieldDefnCount; i++) {            if (Debug.debugging("iso8211")) {                Debug.output("DDFModule.open: Reading field " + i);            }            byte[] szTag = new byte[128];            int nEntryOffset = DDF_LEADER_SIZE + i * nFieldEntryWidth;            int nFieldLength, nFieldPos;            System.arraycopy(pachRecord, nEntryOffset, szTag, 0, _sizeFieldTag);            nEntryOffset += _sizeFieldTag;            nFieldLength = Integer.parseInt(new String(pachRecord, nEntryOffset, _sizeFieldLength));            nEntryOffset += _sizeFieldLength;            nFieldPos = Integer.parseInt(new String(pachRecord, nEntryOffset, _sizeFieldLength));            byte[] subPachRecord = new byte[nFieldLength];            System.arraycopy(pachRecord,                    _fieldAreaStart + nFieldPos,                    subPachRecord,                    0,                    nFieldLength);            paoFieldDefns.add(new DDFFieldDefinition(this, new String(szTag, 0, _sizeFieldTag), subPachRecord));        }        // Free the memory...        achLeader = null;        pachRecord = null;        // Record the current file offset, the beginning of the first        // data record.        nFirstRecordOffset = fpDDF.getFilePointer();        return fpDDF;    }