Package org.apache.sis.storage.geotiff
Class ReversedBitsChannel
java.lang.Object
org.apache.sis.storage.geotiff.ReversedBitsChannel
- All Implemented Interfaces:
Closeable
,AutoCloseable
,ByteChannel
,Channel
,ReadableByteChannel
,SeekableByteChannel
,WritableByteChannel
A channel with a
read(…)
method fetching all bytes with theirs bits in reverse order.
For example, byte 11010100
will become 00101011
.
The use of this class should be very rare.- Since:
- 1.1
- Version:
- 1.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelDataInput
Source channel where to read bytes before bit order reversal.private static final byte[]
Lookup table for reversing the order of bits in a byte. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Creates a new channel which will reverse the bit order of bytes read from the given channel. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
Do nothing.final boolean
isOpen()
Tells whether this channel is still open.long
position()
Returns the current stream position.position
(long p) Moves to the specified stream position.int
read
(ByteBuffer target) Reads a sequence of bytes from this channel into the given buffer.long
size()
Implemented as a matter of principle, but not needed in the context of TIFF reader.truncate
(long size) Unsupported operation (for now).private static IOException
unsupported
(String operation) Creates the exception to throw for an unsupported operation.(package private) static ChannelDataInput
wrap
(ChannelDataInput input) Creates a new input channel at the same position and with the same content than the given channel, but with bits order reversed in every byte.int
write
(ByteBuffer source) Unsupported operation (for now).
-
Field Details
-
REVERSE
private static final byte[] REVERSELookup table for reversing the order of bits in a byte. -
input
Source channel where to read bytes before bit order reversal.
-
-
Constructor Details
-
ReversedBitsChannel
Creates a new channel which will reverse the bit order of bytes read from the given channel.
-
-
Method Details
-
wrap
Creates a new input channel at the same position and with the same content than the given channel, but with bits order reversed in every byte. The new channel uses a temporary buffer of relatively small size because invokingread(ByteBuffer)
is presumed not too costly for this class, and because a new buffer is created for each strip or tile to read.- Throws:
IOException
-
size
Implemented as a matter of principle, but not needed in the context of TIFF reader.- Specified by:
size
in interfaceSeekableByteChannel
- Throws:
IOException
-
position
public long position()Returns the current stream position.- Specified by:
position
in interfaceSeekableByteChannel
-
position
Moves to the specified stream position.- Specified by:
position
in interfaceSeekableByteChannel
- Throws:
IOException
-
read
Reads a sequence of bytes from this channel into the given buffer. For each byte, bits order will be reversed.- Specified by:
read
in interfaceReadableByteChannel
- Specified by:
read
in interfaceSeekableByteChannel
- Throws:
IOException
-
write
Unsupported operation (for now).- Specified by:
write
in interfaceSeekableByteChannel
- Specified by:
write
in interfaceWritableByteChannel
- Throws:
IOException
-
truncate
Unsupported operation (for now).- Specified by:
truncate
in interfaceSeekableByteChannel
- Throws:
IOException
-
unsupported
Creates the exception to throw for an unsupported operation. -
isOpen
public final boolean isOpen()Tells whether this channel is still open. -
close
public final void close()Do nothing. The input channel is not closed by this operation because it will typically be needed again for decompressing other tiles.
-