* @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);
}