Class CompressionChannel
java.lang.Object
org.apache.sis.internal.storage.inflater.PixelChannel
org.apache.sis.internal.storage.inflater.CompressionChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
Inflater writing all decompressed values in a temporary buffer.
This class does not need to care about subsampling.
The close()
method shall be invoked when this channel is no longer used.
- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
Desired size of the buffer where to temporarily copy decompressed data.private long
Stream position after the last byte to read.protected final ChannelDataInput
The source of data to decompress.protected final StoreListeners
Objects where to report warnings. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CompressionChannel
(ChannelDataInput input, StoreListeners listeners) Creates a new channel which will decompress data from the given input. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Releases resources used by this channel, but without closing the input channel.(package private) final ChannelDataInput
createDataInput
(PixelChannel channel, int scanlineStride) Creates the data input stream to use for getting uncompressed data.protected final boolean
finished()
Returnstrue
if the stream position reached the end of tile.final boolean
isOpen()
Tells whether this channel is still open.(package private) static void
repeat
(ByteBuffer target, byte b, int n) Copies the given byte n times in the given buffer.(package private) final Resources
Returns the resources for error messages.void
setInputRegion
(long start, long byteCount) Prepares this inflater for reading a new tile or a new band of a tile.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.nio.channels.ReadableByteChannel
read
-
Field Details
-
BUFFER_SIZE
private static final int BUFFER_SIZEDesired size of the buffer where to temporarily copy decompressed data. The actual buffer size may be larger, but should not be smaller.- See Also:
-
input
The source of data to decompress. -
endPosition
private long endPositionStream position after the last byte to read. -
listeners
Objects where to report warnings.
-
-
Constructor Details
-
CompressionChannel
Creates a new channel which will decompress data from the given input. ThesetInputRegion(long, long)
method must be invoked after construction before a reading process can start.- Parameters:
input
- the source of data to decompress.listeners
- object where to report warnings.
-
-
Method Details
-
setInputRegion
Prepares this inflater for reading a new tile or a new band of a tile.- Specified by:
setInputRegion
in classPixelChannel
- Parameters:
start
- stream position where to start reading.byteCount
- number of bytes to read from the input.- Throws:
IOException
- if the stream cannot be seek to the given start position.
-
finished
protected final boolean finished()Returnstrue
if the stream position reached the end of tile.- Returns:
- whether the stream reached end of tile.
-
createDataInput
Creates the data input stream to use for getting uncompressed data. The input stream must be on the start position before to invoke this method.This method tries to create a buffer of the size of scanline stride, or a multiple of that size, for performance reasons. A well adjusted buffer size reduces calls to
ByteBuffer.compact()
, which in turn reduces the amount of copy operations between different regions of the buffer.- Parameters:
channel
- the channel to wrap. This isthis
unless ainvalid reference
Predictor
scanlineStride
- the scanline stride of the image to read. Used for choosing a buffer size.- Returns:
- the data input for uncompressed data.
- Throws:
IOException
- if an error occurred while filling the buffer with initial data.
-
repeat
Copies the given byte n times in the given buffer. -
isOpen
public final boolean isOpen()Tells whether this channel is still open. -
close
public void close() -
resources
Returns the resources for error messages.
-