/** * Returns the readable channel on the first invocation or * throws an exception on all subsequent invocations. */ @Override public ReadableByteChannel readable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel in = channel; if (in instanceof ReadableByteChannel) { channel = null; return (ReadableByteChannel) in; } String message = Resources.format(in != null ? Resources.Keys.StreamIsNotReadable_1 : Resources.Keys.StreamIsReadOnce_1, filename); if (in != null) { throw new IOException(message); // Stream is not readable. } else { throw new ForwardOnlyStorageException(message); // Stream has already been read. } }
/** * Returns the writable channel on the first invocation or * throws an exception on all subsequent invocations. */ @Override public WritableByteChannel writable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel out = channel; if (out instanceof WritableByteChannel) { channel = null; return (WritableByteChannel) out; } String message = Resources.format(out != null ? Resources.Keys.StreamIsNotWritable_1 : Resources.Keys.StreamIsWriteOnce_1, filename); if (out != null) { throw new IOException(message); // Stream is not writable. } else { throw new ForwardOnlyStorageException(message); // Stream has already been written. } } }
/** * Returns the readable channel on the first invocation or * throws an exception on all subsequent invocations. */ @Override public ReadableByteChannel readable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel in = channel; if (in instanceof ReadableByteChannel) { channel = null; return (ReadableByteChannel) in; } String message = Resources.format(in != null ? Resources.Keys.StreamIsNotReadable_1 : Resources.Keys.StreamIsReadOnce_1, filename); if (in != null) { throw new IOException(message); // Stream is not readable. } else { throw new ForwardOnlyStorageException(message); // Stream has already been read. } }
/** * Returns the writable channel on the first invocation or * throws an exception on all subsequent invocations. */ @Override public WritableByteChannel writable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel out = channel; if (out instanceof WritableByteChannel) { channel = null; return (WritableByteChannel) out; } String message = Resources.format(out != null ? Resources.Keys.StreamIsNotWritable_1 : Resources.Keys.StreamIsWriteOnce_1, filename); if (out != null) { throw new IOException(message); // Stream is not writable. } else { throw new ForwardOnlyStorageException(message); // Stream has already been written. } } }
/** * Resets the root {@link #storage} object. * * @throws DataStoreException if the storage can not be reseted. */ private void reset() throws DataStoreException { if (views != null && !reset(views.get(null))) { throw new ForwardOnlyStorageException(Resources.format( Resources.Keys.StreamIsReadOnce_1, getStorageName())); } }
/** * Resets the root {@link #storage} object. * * @throws DataStoreException if the storage can not be reseted. */ private void reset() throws DataStoreException { if (views != null && !reset(views.get(null))) { throw new ForwardOnlyStorageException(Resources.format( Resources.Keys.StreamIsReadOnce_1, getStorageName())); } }
done = c.reset(); } catch (IOException e) { throw new ForwardOnlyStorageException(Resources.format( Resources.Keys.StreamIsReadOnce_1, getStorageName()), e);
done = c.reset(); } catch (IOException e) { throw new ForwardOnlyStorageException(Resources.format( Resources.Keys.StreamIsReadOnce_1, getStorageName()), e);
final String name = getDisplayName(); if (channelFactory == null) { throw new ForwardOnlyStorageException(getLocale(), name, StandardOpenOption.READ);
case FINISHED: { if (reset()) break; throw new ForwardOnlyStorageException(getLocale(), getDisplayName(), StandardOpenOption.WRITE);