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

📄 dcwcolumninfo.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        case VPF_COLUMN_TEXT:        case VPF_COLUMN_TEXTL1:        case VPF_COLUMN_TEXTL3:        case VPF_COLUMN_TEXTL2: //various text string types            return numberOfElements;        case VPF_COLUMN_FLOAT: //floats            return 4;        case VPF_COLUMN_DOUBLE: //doubles            return 8;        case VPF_COLUMN_SHORT: //shorts            return 2;        case VPF_COLUMN_INT: //ints            return 4;        case VPF_COLUMN_FLOAT_2COORD: //2-coord floats            return numberOfElements * 8;        case VPF_COLUMN_DOUBLE_2COORD: //2-coord doubles            return numberOfElements * 16;        case VPF_COLUMN_FLOAT_3COORD: //3-coord floats            return numberOfElements * 12;        case VPF_COLUMN_DOUBLE_3COORD: //3-coord doubles            return numberOfElements * 24;        case VPF_COLUMN_DATE: //dates            return 20;        case VPF_COLUMN_NULL: //nulls            return 0;        case VPF_COLUMN_TRIPLET: //cross-tile identifiers            return -1; //variable length        default: {            throw new FormatException("Unknown field type: " + fieldType);        }        }        //unreached    }    /**     * get the name of the column     *      * @return the name of the column     */    public String getColumnName() {        return columnName;    }    /**     * get the VPF datatype of the column     *      * @return the VPF datatype     */    public char getFieldType() {        return fieldType;    }    /**     * get the number of elements     *      * @return the number of elements     */    public int getNumberOfElements() {        return numberOfElements;    }    /**     * get the VPF key type (one of VPF_COLUMN_PRIMARY_KEY,     * VPF_COLUMN_FOREIGN_KEY, or VPF_COLUMN_NON_KEY)     *      * @return the vpf key type     */    public char getKeyType() {        return keyType;    }    /**     * Return <code>true</code> if this column is a primary key. For     * any valid column, exactly one of isPrimaryKey, isForeignKey and     * isNonKey will be <code>true</code>.     *      * @return true for a primary key, false otherwise.     * @see #isForeignKey()     * @see #isNonKey()     */    public boolean isPrimaryKey() {        return (keyType == VPF_COLUMN_PRIMARY_KEY);    }    /**     * Return <code>true</code> if this column is a foreign key. For     * any valid column, exactly one of isPrimaryKey, isForeignKey and     * isNonKey will be <code>true</code>.     *      * @return true for a foreign key, false otherwise.     * @see #isPrimaryKey()     * @see #isNonKey()     */    public boolean isForeignKey() {        return (keyType == VPF_COLUMN_FOREIGN_KEY);    }    /**     * Return <code>true</code> if this column is not a key column.     * For any valid column, exactly one of isPrimaryKey, isForeignKey     * and isNonKey will be <code>true</code>.     *      * @return false for a primary or foreign key, true otherwise.     * @see #isForeignKey()     * @see #isPrimaryKey()     */    public boolean isNonKey() {        return (keyType == VPF_COLUMN_NON_KEY);    }    /**     * Get the column description     *      * @return the column description (possibly <code>null</code>)     */    public String getColumnDescription() {        return columnDescription;    }    /**     * Get the name of the value description table     *      * @return the name of the value description table (possibly     *         <code>null</code>). The same as getVDT()     * @see #getVDT()     */    public String getValueDescriptionTable() {        return valueDescriptionTable;    }    /**     * Get the name of the value description table     *      * @return the name of the value description table (possibly     *         <code>null</code>). The same as     *         getValueDescriptionTable     * @see #getValueDescriptionTable()     */    public String getVDT() {        return valueDescriptionTable;    }    /**     * get the name of the thematic index     *      * @return the thematic index name (possibly <code>null</code>)     */    public String getThematicIndexName() {        return thematicIndexName;    }    /**     * get the name of the narrative table     *      * @return the name of the narrative table (possibly     *         <code>null</code>)     */    public String getNarrativeTable() {        return narrativeTable;    }    /**     * Read an element of the type specified by the column     *      * @return the value read from the input file     * @exception EOFException an end-of-file was encountered before     *            reading any of the field     * @exception FormatException some data-consistency check failed     *            while reading the data, or an end-of-file condition     *            popped up in the middle of reading a field (partial     *            read)     */    public Object parseField(BinaryFile inputFile) throws EOFException,            FormatException {        // See table 56, p 79 of MIL-STD-600006 (1992 VPF Standard)        // See table 10, p 51 of MIL-STD-2407 (1996 VPF Standard        // supercedes 600006)        boolean haveElements = (numberOfElements != -1);        int numels = numberOfElements;        switch (fieldType) {        case VPF_COLUMN_TEXT: {            if (!haveElements) {//Variable length string                numels = inputFile.readInteger();            }            if (numels == 0) {                return "";            }            String s = inputFile.readFixedLengthString(numels);            if (haveElements) {//Fixed Length Strings loose trailing                               // whitespace                s = s.trim();            }            return s;        }        case VPF_COLUMN_TEXTL1: {            if (!haveElements) {//Variable length string                numels = inputFile.readInteger();            }            if (numels == 0) {                return "";            }            byte[] str = inputFile.readBytes(numels, false);            try {                String s = new String(str, "ISO8859_1");                if (haveElements) {//Fixed Length Strings loose                                   // trailing whitespace                    s = s.trim();                }                return s;            } catch (java.io.UnsupportedEncodingException uee) {                return str;            }        }        case VPF_COLUMN_TEXTL2:        case VPF_COLUMN_TEXTL3: {            if (!haveElements) {//Variable length string                numels = inputFile.readInteger();            }            if (numels == 0) {                return new byte[0];            }            return inputFile.readBytes(numels, false);        }        case VPF_COLUMN_FLOAT: {            return new Float(inputFile.readFloat());        }        case VPF_COLUMN_DOUBLE: {            return new Double(inputFile.readDouble());        }        case VPF_COLUMN_SHORT: {            return new Short(inputFile.readShort());        }        case VPF_COLUMN_INT: {            return new Integer(inputFile.readInteger());        }        case VPF_COLUMN_FLOAT_2COORD: { //2-coord floats            if (!haveElements) {                numels = inputFile.readInteger();            }            return new CoordFloatString(numels, 2, inputFile);        }        case VPF_COLUMN_DOUBLE_2COORD: { //2-coord doubles            if (!haveElements) {                numels = inputFile.readInteger();            }            return new CoordDoubleString(numels, 2, inputFile);        }        case VPF_COLUMN_FLOAT_3COORD: { //3-coord floats            if (!haveElements) {                numels = inputFile.readInteger();            }            return new CoordFloatString(numels, 3, inputFile);        }        case VPF_COLUMN_DOUBLE_3COORD: { //3-coord doubles            if (!haveElements) {                numels = inputFile.readInteger();            }            return new CoordDoubleString(numels, 3, inputFile);        }        case VPF_COLUMN_DATE: {            inputFile.readBytes(20, false);            return "[skipped date]";        }        case VPF_COLUMN_NULL: {            return "[Null Field Type]";        }        case VPF_COLUMN_TRIPLET: {            return new DcwCrossTileID(inputFile);        }        default: {            throw new FormatException("Unknown field type: " + fieldType);        }        }        //unreached    }    /**     * produce a nice printed version of all our contained information     *      * @return a nice little string     */    public String toString() {        StringBuffer output = new StringBuffer();        output.append(columnName + " " + fieldType + " ");        output.append(numberOfElements).append(" ");        output.append(keyType).append(" ");        output.append(columnDescription + " " + valueDescriptionTable + " ");        output.append(thematicIndexName + " " + narrativeTable);        return output.toString();    }}

⌨️ 快捷键说明

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