⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddfmodule.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                    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;    }    /**     * Write out module info to debugging file.     *      * A variety of information about the module is written to the     * debugging file. This includes all the field and subfield     * definitions read from the header.     */    public String toString() {        StringBuffer buf = new StringBuffer("DDFModule:\n");        buf.append("    _recLength = " + _recLength + "\n");        buf.append("    _interchangeLevel = " + _interchangeLevel + "\n");        buf.append("    _leaderIden = " + (char) _leaderIden + "\n");        buf.append("    _inlineCodeExtensionIndicator = "                + _inlineCodeExtensionIndicator + "\n");        buf.append("    _versionNumber = " + _versionNumber + "\n");        buf.append("    _appIndicator = " + _appIndicator + "\n");        buf.append("    _extendedCharSet = " + _extendedCharSet + "\n");        buf.append("    _fieldControlLength = " + _fieldControlLength + "\n");        buf.append("    _fieldAreaStart = " + _fieldAreaStart + "\n");        buf.append("    _sizeFieldLength = " + _sizeFieldLength + "\n");        buf.append("    _sizeFieldPos = " + _sizeFieldPos + "\n");        buf.append("    _sizeFieldTag = " + _sizeFieldTag + "\n");        return buf.toString();    }    public String dump() {        StringBuffer buf = new StringBuffer(toString());        DDFRecord poRecord;        int iRecord = 0;        while ((poRecord = readRecord()) != null) {            buf.append("  Record " + (iRecord++) + "(" + poRecord.getDataSize()                    + " bytes)\n");            for (Iterator it = poRecord.iterator(); it.hasNext(); buf.append(((DDFField) it.next()).toString())) {            }        }        return buf.toString();    }    /**     * Fetch the definition of the named field.     *      * This function will scan the DDFFieldDefn's on this module, to     * find one with the indicated field name.     *      * @param pszFieldName The name of the field to search for. The     *        comparison is case insensitive.     *      * @return A pointer to the request DDFFieldDefn object is     *         returned, or null if none matching the name are found.     *         The return object remains owned by the DDFModule, and     *         should not be deleted by application code.     */    public DDFFieldDefinition findFieldDefn(String pszFieldName) {        for (Iterator it = paoFieldDefns.iterator(); it.hasNext();) {            DDFFieldDefinition ddffd = (DDFFieldDefinition) it.next();            String pszThisName = ddffd.getName();            if (Debug.debugging("iso8211detail")) {                Debug.output("DDFModule.findFieldDefn(" + pszFieldName + ":"                        + pszFieldName.length() + ") checking against ["                        + pszThisName + ":" + pszThisName.length() + "]");            }            if (pszFieldName.equalsIgnoreCase(pszThisName)) {                return ddffd;            }        }        return null;    }    /**     * Read one record from the file, and return to the application.     * The returned record is owned by the module, and is reused from     * call to call in order to preserve headers when they aren't     * being re-read from record to record.     *      * @return A pointer to a DDFRecord object is returned, or null if     *         a read error, or end of file occurs. The returned     *         record is owned by the module, and should not be     *         deleted by the application. The record is only valid     *         untill the next ReadRecord() at which point it is     *         overwritten.     */    public DDFRecord readRecord() {        if (poRecord == null) {            poRecord = new DDFRecord(this);        }        if (poRecord.read()) {            return poRecord;        } else {            return null;        }    }    /**     * Method for other components to call to get the DDFModule to     * read bytes into the provided array.     *      * @param toData the bytes to put data into.     * @param offset the byte offset to start reading from, whereever     *        the pointer currently is.     * @param length the number of bytes to read.     * @return the number of bytes read.     */    public int read(byte[] toData, int offset, int length) {        if (fpDDF == null) {            reopen();        }        if (fpDDF != null) {            try {                return fpDDF.read(toData, offset, length);            } catch (IOException ioe) {                Debug.error("DDFModule.read(): IOException caught");            } catch (ArrayIndexOutOfBoundsException aioobe) {                Debug.error("DDFModule.read(): "                        + aioobe.getMessage()                        + " reading from "                        + offset                        + " to "                        + length                        + " into "                        + (toData == null ? "null byte[]" : "byte["                                + toData.length + "]"));                aioobe.printStackTrace();            }        }        return 0;    }    /**     * Convenience method to read a byte from the data file. Assumes     * that you know what you are doing based on the parameters read     * in the data file. For DDFFields that haven't loaded their     * subfields.     */    public int read() {        if (fpDDF == null) {            reopen();        }        if (fpDDF != null) {            try {                return fpDDF.read();            } catch (IOException ioe) {                Debug.error("DDFModule.read(): IOException caught");            }        }        return 0;    }    /**     * Convenience method to seek to a location in the data file.     * Assumes that you know what you are doing based on the     * parameters read in the data file. For DDFFields that haven't     * loaded their subfields.     *      * @param pos the byte position to reposition the file pointer to.     */    public void seek(long pos) throws IOException {        if (fpDDF == null) {            reopen();        }        if (fpDDF != null) {            fpDDF.seek(pos);        } else {            throw new IOException("DDFModule doesn't have a pointer to a file");        }    }    /**     * Fetch a field definition by index.     *      * @param i (from 0 to GetFieldCount() - 1.     * @return the returned field pointer or null if the index is out     *         of range.     */    public DDFFieldDefinition getField(int i) {        if (i >= 0 || i < paoFieldDefns.size()) {            return (DDFFieldDefinition) paoFieldDefns.elementAt(i);        }        return null;    }    /**     * Return to first record.     *      * The next call to ReadRecord() will read the first data record     * in the file.     *      * @param nOffset the offset in the file to return to. By default     *        this is -1, a special value indicating that reading     *        should return to the first data record. Otherwise it is     *        an absolute byte offset in the file.     */    public void rewind(long nOffset) throws IOException {        if (nOffset == -1) {            nOffset = nFirstRecordOffset;        }        if (fpDDF != null) {            fpDDF.seek(nOffset);            // Don't know what this has to do with anything...            if (nOffset == nFirstRecordOffset && poRecord != null) {                poRecord.clear();            }        }    }    public void reopen() {        try {            if (fpDDF == null) {                fpDDF = new BinaryBufferedFile(fileName);            }        } catch (IOException ioe) {        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -