Class PredictorChannel
java.lang.Object
org.apache.sis.internal.storage.inflater.PixelChannel
org.apache.sis.internal.storage.inflater.PredictorChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,ReadableByteChannel
- Direct Known Subclasses:
HorizontalPredictor
Implementation of a
Predictor
to be executed after decompression.- Since:
- 1.1
- Version:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate byte[]
Ifread(ByteBuffer)
could not process some trailing bytes, a copy of those bytes for processing in the next method invocation.private int
Number of values in thedeferred
array.private final CompressionChannel
The channel from which to read data. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a predictor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract int
apply
(ByteBuffer buffer, int start) Applies the predictor on data in the given buffer, from the given start position until current buffer position.final void
close()
Closesinput
.final boolean
isOpen()
Tells whether this channel is still open.int
read
(ByteBuffer target) Decompresses some bytes from the input into the given destination buffer.void
setInputRegion
(long start, long byteCount) Prepares this predictor for reading a new tile or a new band of a planar image.
-
Field Details
-
input
The channel from which to read data. -
deferred
private byte[] deferredIfread(ByteBuffer)
could not process some trailing bytes, a copy of those bytes for processing in the next method invocation. -
deferredCount
private int deferredCountNumber of values in thedeferred
array.
-
-
Constructor Details
-
PredictorChannel
Creates a predictor. ThesetInputRegion(long, long)
method must be invoked after construction before a reading process can start.- Parameters:
input
- the channel that decompress data.
-
-
Method Details
-
setInputRegion
Prepares this predictor for reading a new tile or a new band of a planar image.- 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.
-
apply
Applies the predictor on data in the given buffer, from the given start position until current buffer position.- Parameters:
buffer
- the buffer on which to apply the predictor.start
- position of first sample value to process.- Returns:
- position after the last sample value processed. Should be
Buffer.position()
, unless the predictor needs more data for processing the last bytes.
-
read
Decompresses some bytes from the input into the given destination buffer.- Parameters:
target
- the buffer into which bytes are to be transferred.- Returns:
- the number of bytes read, or -1 if end-of-stream.
- Throws:
IOException
- if some other I/O error occurs.
-
isOpen
public final boolean isOpen()Tells whether this channel is still open. -
close
public final void close()
-