Package org.apache.sis.internal.storage

Examples of org.apache.sis.internal.storage.ChannelDataInput$ArrayReader


     * @param  asImageInputStream If the {@code ChannelDataInput} needs to be {@link ChannelImageInputStream} subclass.
     * @throws IOException If an error occurred while opening a channel for the input.
     */
    private void createChannelDataInput(final boolean asImageInputStream) throws IOException {
        final ReadableByteChannel channel = IOUtilities.open(storage, getOption(OptionKey.URL_ENCODING));
        ChannelDataInput asDataInput = null;
        if (channel != null) {
            ByteBuffer buffer = getOption(OptionKey.BYTE_BUFFER);
            if (buffer == null) {
                buffer = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
                // TODO: we do not create direct buffer yet, but this is something
                // we may want to consider in a future SIS version.
            }
            final String name = getStorageName();
            if (asImageInputStream) {
                asDataInput = new ChannelImageInputStream(name, channel, buffer, false);
            } else {
                asDataInput = new ChannelDataInput(name, channel, buffer, false);
            }
        }
        addView(ChannelDataInput.class, asDataInput);
    }
View Full Code Here


             * on the ImageIO.createImageInputStream(Object) method only in last resort.
             */
            if (!views.containsKey(ChannelDataInput.class)) {
                createChannelDataInput(true);
            }
            final ChannelDataInput c = getView(ChannelDataInput.class);
            if (c == null) {
                asDataInput = ImageIO.createImageInputStream(storage);
            } else if (c instanceof DataInput) {
                asDataInput = (DataInput) c;
            } else {
View Full Code Here

    private void createByteBuffer() throws IOException, DataStoreException {
        if (!views.containsKey(ChannelDataInput.class)) {
            createChannelDataInput(false);
        }
        ByteBuffer asByteBuffer = null;
        final ChannelDataInput c = getView(ChannelDataInput.class);
        if (c != null) {
            asByteBuffer = c.buffer.asReadOnlyBuffer();
        } else {
            final ImageInputStream in = getStorageAs(ImageInputStream.class);
            if (in != null) {
View Full Code Here

     * @throws IOException If an error occurred while reading the test file.
     */
    @Test
    public void testGetAsChannelDataInput() throws DataStoreException, IOException {
        final StorageConnector connection = create(true);
        final ChannelDataInput input = connection.getStorageAs(ChannelDataInput.class);
        assertFalse(input instanceof ChannelImageInputStream);
        assertEquals(MAGIC_NUMBER, input.buffer.getInt());
        /*
         * Get as an image input stream and ensure that the cached value has been replaced.
         */
 
View Full Code Here

    static Decoder decoder(final WarningListeners<?> listeners, final StorageConnector storage)
            throws IOException, DataStoreException
    {
        Decoder decoder;
        Object keepOpen;
        final ChannelDataInput input = storage.getStorageAs(ChannelDataInput.class);
        if (input != null) try {
            decoder = new ChannelDecoder(listeners, input);
            keepOpen = input;
        } catch (DataStoreException e) {
            final String path = storage.getStorageAs(String.class);
View Full Code Here

     * @throws IOException If an error occurred while opening the file.
     */
    public static Decoder createChannelDecoder(final String name) throws IOException {
        final InputStream in = IOTestCase.class.getResourceAsStream(name);
        assumeNotNull(name, in);
        final ChannelDataInput input = new ChannelDataInput(name,
                Channels.newChannel(in), ByteBuffer.allocate(4096), false);
        try {
            return new ChannelDecoder(LISTENERS, input);
        } catch (DataStoreException e) {
            throw new AssertionError(e);
View Full Code Here

    static Decoder decoder(final WarningListeners<?> listeners, final StorageConnector storage)
            throws IOException, DataStoreException
    {
        Decoder decoder;
        Object keepOpen;
        final ChannelDataInput input = storage.getStorageAs(ChannelDataInput.class);
        if (input != null) try {
            decoder = new ChannelDecoder(listeners, input);
            keepOpen = input;
        } catch (DataStoreException e) {
            final String path = storage.getStorageAs(String.class);
View Full Code Here

     * @throws IOException If an error occurred while reading the test file.
     */
    @Test
    public void testGetAsChannelDataInput() throws DataStoreException, IOException {
        final StorageConnector connection = create(true);
        final ChannelDataInput input = connection.getStorageAs(ChannelDataInput.class);
        assertFalse(input instanceof ChannelImageInputStream);
        assertEquals(MAGIC_NUMBER, input.buffer.getInt());
        /*
         * Get as an image input stream and ensure that the cached value has been replaced.
         */
 
View Full Code Here

     * @throws IOException If an error occurred while opening a channel for the input.
     */
    private void createChannelDataInput(final boolean asImageInputStream) throws IOException {
        final ReadableByteChannel channel = IOUtilities.open(storage,
                getOption(OptionKey.URL_ENCODING), getOption(OptionKey.OPEN_OPTIONS));
        ChannelDataInput asDataInput = null;
        if (channel != null) {
            addViewToClose(channel, storage);
            ByteBuffer buffer = getOption(OptionKey.BYTE_BUFFER);
            if (buffer == null) {
                buffer = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
                // TODO: we do not create direct buffer yet, but this is something
                // we may want to consider in a future SIS version.
            }
            final String name = getStorageName();
            if (asImageInputStream) {
                asDataInput = new ChannelImageInputStream(name, channel, buffer, false);
            } else {
                asDataInput = new ChannelDataInput(name, channel, buffer, false);
            }
            addViewToClose(asDataInput, channel);
        }
        addView(ChannelDataInput.class, asDataInput);
    }
View Full Code Here

             * on the ImageIO.createImageInputStream(Object) method only in last resort.
             */
            if (!views.containsKey(ChannelDataInput.class)) {
                createChannelDataInput(true);
            }
            final ChannelDataInput c = getView(ChannelDataInput.class);
            if (c == null) {
                asDataInput = ImageIO.createImageInputStream(storage);
                addViewToClose(asDataInput, storage);
            } else if (c instanceof DataInput) {
                asDataInput = (DataInput) c;
View Full Code Here

TOP

Related Classes of org.apache.sis.internal.storage.ChannelDataInput$ArrayReader

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.