Package org.apache.sis.storage

Examples of org.apache.sis.storage.DataStoreException


    public void close() throws DataStoreException {
        metadata = null;
        try {
            decoder.close();
        } catch (IOException e) {
            throw new DataStoreException(e);
        }
    }
View Full Code Here


            } catch (InvocationTargetException e) {
                final Throwable cause = e.getCause();
                if (cause instanceof DataStoreException) throw (DataStoreException) cause;
                if (cause instanceof RuntimeException)   throw (RuntimeException)   cause;
                if (cause instanceof Error)              throw (Error)              cause;
                throw new DataStoreException(e); // The cause may be IOException.
            }
        }
        /*
         * Check if the given input is itself an instance of the UCAR oject.
         * We check classnames instead of netcdfFileClass.isInstance(storage)
View Full Code Here

            }
        }
        final Closeable c = input(source);
        connector.closeAllExcept(c);
        if (c == null) {
            throw new DataStoreException(Errors.format(Errors.Keys.CanNotOpen_1, name));
        }
    }
View Full Code Here

                object = XML.unmarshal(s, properties());
            } finally {
                in.close();
            }
        } catch (Exception e) { // (JAXBException | IOException) on the JDK7 branch.
            throw new DataStoreException(Errors.format(Errors.Keys.CanNotRead_1, name), e);
        }
    }
View Full Code Here

        final Closeable in = input(source);
        source = null; // Cleared first in case of failure.
        if (in != null) try {
            in.close();
        } catch (IOException e) {
            throw new DataStoreException(e);
        }
    }
View Full Code Here

        long length = 1;
        for (final Dimension dimension : dimensions) {
            length *= dimension.length;
        }
        if (length > Integer.MAX_VALUE) {
            throw new DataStoreException(Errors.format(Errors.Keys.ExcessiveListSize_2, name, length));
        }
        input.seek(offset);
        switch (datatype) {
            case BYTE:   return input.readBytes  ((int) length);
            case SHORT:  return input.readShorts ((int) length);
            case INT:    return input.readInts   ((int) length);
            case FLOAT:  return input.readFloats ((int) length);
            case DOUBLE: return input.readDoubles((int) length);
            default: throw new DataStoreException(Errors.format(Errors.Keys.UnknownType_1, datatype));
        }
    }
View Full Code Here

         * Check the magic number, which is expected to be exactly 3 bytes forming the "CDF" string.
         * The 4th byte is the version number, which we opportunistically use after the magic number check.
         */
        int version = input.readInt();
        if ((version & 0xFFFFFF00) != MAGIC_NUMBER) {
            throw new DataStoreException(errors().getString(Errors.Keys.UnexpectedFileFormat_2, "NetCDF", input.filename));
        }
        /*
         * Check the version number.
         */
        version &= 0xFF;
        switch (version) {
            case 1:  is64bits = false; break;
            case 2:  is64bits = truebreak;
            default: throw new DataStoreException(errors().getString(Errors.Keys.UnsupportedVersion_1, version));
            // If more cases are added, remember to increment the MAX_VERSION constant.
        }
        numrecs = input.readInt();
        /*
         * Read the dimension, attribute and variable declarations. We expect exactly 3 lists,
View Full Code Here

    /**
     * Returns an exception for a malformed header. This is used only after we have determined
     * that the file should be a NetCDF one, but we found some inconsistency or unknown tags.
     */
    private DataStoreException malformedHeader() {
        return new DataStoreException(errors().getString(Errors.Keys.CanNotParseFile_2, "NetCDF", input.filename));
    }
View Full Code Here

    /**
     * Ensures that {@code nelems} is not a negative value.
     */
    private void ensureNonNegative(final int nelems, final int tag) throws DataStoreException {
        if (nelems < 0) {
            throw new DataStoreException(errors().getString(Errors.Keys.NegativeArrayLength_1,
                    input.filename + DefaultNameSpace.DEFAULT_SEPARATOR + tagName(tag)));
        }
    }
View Full Code Here

        // (n+3) & ~3  is a trick for rounding 'n' to the next multiple of 4.
        final long size = ((n & 0xFFFFFFFFL) * dataSize + 3) & ~3;
        if (size > input.buffer.capacity()) {
            name = input.filename + DefaultNameSpace.DEFAULT_SEPARATOR + name;
            final Errors errors = errors();
            throw new DataStoreException(n < 0 ?
                    errors.getString(Errors.Keys.NegativeArrayLength_1, name) :
                    errors.getString(Errors.Keys.ExcessiveListSize_2, name, n));
        }
        input.ensureBufferContains((int) size);
        return (int) size;
View Full Code Here

TOP

Related Classes of org.apache.sis.storage.DataStoreException

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.