Package org.apache.sis.storage

Examples of org.apache.sis.storage.DataStoreException


        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));
        }
        numrecs = input.readInt();
        /*
         * Read the dimension, attribute and variable declarations. We expect exactly 3 lists,
         * where any of them can be flagged as absent by a long (64 bits) 0.
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

            final String name = readName();
            int length = input.readInt();
            if (length == 0) {
                length = numrecs;
                if (length == STREAMING) {
                    throw new DataStoreException(errors().getString(Errors.Keys.MissingValueForProperty_1, "numrecs"));
                }
            }
            dimensions[i] = new Dimension(name, length);
        }
        return dimensions;
View Full Code Here

            try {
                for (int i=0; i<n; i++) {
                    varDims[i] = dimensions[input.readInt()];
                }
            } catch (IndexOutOfBoundsException cause) {
                final DataStoreException e = malformedHeader();
                e.initCause(cause);
                throw e;
            }
            /*
             * Following block is almost a copy-and-paste of similar block in the contructor,
             * but with less cases in the "switch" statements.
View Full Code Here

     */
    private <E> Map<String,E> toMap(final E[] elements, final Function<E,String> nameFunction) throws DataStoreException {
        try {
            return CollectionsExt.toCaseInsensitiveNameMap(Arrays.asList(elements), nameFunction, NAME_LOCALE);
        } catch (InvalidParameterCardinalityException e) {
            throw new DataStoreException(errors().getString(Errors.Keys.ValueAlreadyDefined_1, e.getParameterName()));
        }
    }
View Full Code Here

    public NetcdfStore(final StorageConnector storage) throws DataStoreException {
        ArgumentChecks.ensureNonNull("storage", storage);
        try {
            decoder = NetcdfStoreProvider.decoder(listeners, storage);
        } catch (IOException e) {
            throw new DataStoreException(e);
        }
    }
View Full Code Here

    public Metadata getMetadata() throws DataStoreException {
        if (metadata == null) try {
            final MetadataReader reader = new MetadataReader(decoder);
            metadata = reader.read(); // Umodifiable object.
        } catch (IOException e) {
            throw new DataStoreException(e);
        }
        return metadata;
    }
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.