Package com.bbn.openmap.io

Examples of com.bbn.openmap.io.FormatException


        int totallen = tcount * tsize;
        vals = new float[totallen];
        try {
            input.readFloatArray(vals, 0, totallen);
        } catch (EOFException e) {
            throw new FormatException("CoordFloatString EOFException");
        }
    }
View Full Code Here


    public DcwCrossTileID(BinaryFile in) throws FormatException, EOFException {
        int format;
        try {
            format = in.read();
        } catch (IOException ioe) {
            throw new FormatException(ioe.getMessage());
        }
        if (format == -1) {
            throw new EOFException();
        }

        try {
            currentTileKey = readIntegerByKey(in, format >> 6);
            nextTileID = readIntegerByKey(in, format >> 4);
            nextTileKey = readIntegerByKey(in, format >> 2);
            /*int unusedDcwKey = */readIntegerByKey(in, format);
        } catch (EOFException e) {
            throw new FormatException("DcwCrossTileID: unexpected EOD "
                    + e.getMessage());
        }
    }
View Full Code Here

        case 1: {
            int byteval;
            try {
                byteval = in.read();
            } catch (IOException ioe) {
                throw new FormatException(ioe.getMessage());
            }
            if (byteval == -1) {
                throw new EOFException();
            }
            return byteval;
        }
        case 2:
            return MoreMath.signedToInt(in.readShort());
        case 3:
            return in.readInteger();
        }
        throw new FormatException("This can't happen");
    }
View Full Code Here

            case VPF_COLUMN_SHORT:
            case VPF_COLUMN_INT:
            case VPF_COLUMN_DATE:
            case VPF_COLUMN_NULL:
            case VPF_COLUMN_TRIPLET:
                throw new FormatException("Illegal array type: " + fieldType
                        + "for column " + columnName);
            default:
                //legal
                break;
            }
        }

        String tmpkeyType = readColumnText(inputFile);
        if (tmpkeyType == null) {
            throw new FormatException("keyType is required column info");
        }
        tmpkeyType = tmpkeyType.trim();
        if (tmpkeyType.length() == 1) {
            keyType = tmpkeyType.charAt(0);
        } else {
            throw new FormatException("keyType is supposed to be 1 character");
        }
        columnDescription = readColumnText(inputFile);
        if (columnDescription == null) {
            return;
        }
View Full Code Here

     */
    public void assertSchema(char type, int length, boolean strictlength)
            throws FormatException {
        if ((type != fieldType)
                && !((type == 'i') && ((fieldType == VPF_COLUMN_INT) || (fieldType == VPF_COLUMN_SHORT)))) {
            throw new FormatException("AssertSchema failed on fieldType!");
        }
        if ((strictlength && (length != numberOfElements))
                || (!strictlength && (length != -1) && (length != numberOfElements))) {
            throw new FormatException("AssertSchema failed on length!");
        }
    }
View Full Code Here

        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
    }
View Full Code Here

        }
        case VPF_COLUMN_TRIPLET: {
            return new DcwCrossTileID(inputFile);
        }
        default: {
            throw new FormatException("Unknown field type: " + fieldType);
        }
        }
        //unreached
    }
View Full Code Here

            vals = new double[tuplecount][tuplesize];
            for (int i = 0; i < tuplecount; i++)
                for (int j = 0; j < tuplesize; j++)
                    vals[i][j] = input.readDouble();
        } catch (EOFException e) {
            throw new FormatException("CoordDoubleString EOFException");
        }
    }
View Full Code Here

    public synchronized void finishInitialization() throws FormatException {
        internTableName();
        try {
            inputFile = new BinaryBufferedFile(filename);
        } catch (IOException e) {
            throw new FormatException(e.toString());
        }
        try {
            byte preHeaderLen[] = inputFile.readBytes(4, false);

            char delim = inputFile.readChar();
            switch (delim) {
            case 'L':
            case 'l':
                delim = inputFile.readChar();
            //Intentional fall through to set byteorder
            case ';': //default is LSB first
                byteorder = false;
                inputFile.byteOrder(byteorder);
                break;
            case 'M':
            case 'm': //alternatively, it can be MSB first
                byteorder = true;
                inputFile.byteOrder(byteorder);
                delim = inputFile.readChar();
                break;
            default:
                throw new FormatException("Invalid Byte Encoding Format");
            }
            headerLength += MoreMath.BuildInteger(preHeaderLen, byteorder);
            if (delim != ';') {//Sanity check the input
                throw new FormatException("Unexpected character in header");
            }
            tableDescription = inputFile.readToDelimiter(';');
            documentationFileName = inputFile.readToDelimiter(';');
            if ("-".equals(documentationFileName)) {
                documentationFileName = null;
            }

            ArrayList tmpcols = new ArrayList();
            try {
                while (true) {
                    DcwColumnInfo dci = new DcwColumnInfo(inputFile);
                    int collen = dci.fieldLength();
                    if ((collen == -1) || (recordLength == -1)) {
                        recordLength = -1;
                    } else {
                        recordLength += collen;
                    }
                    tmpcols.add(dci);
                }
            } catch (EOFException e) {
            }

            columnInfo = new DcwColumnInfo[tmpcols.size()];
            tmpcols.toArray(columnInfo);

            cursorRow = 1;
        } catch (EOFException e) {
            throw new FormatException("Caught EOFException: " + e.getMessage());
        } catch (NullPointerException npe) {
        }
    }
View Full Code Here

            throws FormatException {
        int retval[] = new int[names.length];
        for (int i = 0; i < retval.length; i++) {
            retval[i] = whatColumn(names[i]);
            if ((retval[i] == -1) && mustExist) {
                throw new FormatException("Column " + names[i]
                        + " doesn't exist");
            }
        }
        return retval;
    }
View Full Code Here

TOP

Related Classes of com.bbn.openmap.io.FormatException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.