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 ChannelDataInputSource 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
ConstructorsModifierConstructorDescriptionprivateCreates a new channel which will reverse the bit order of bytes read from the given channel. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidclose()Do nothing.final booleanisOpen()Tells whether this channel is still open.longposition()Returns the current stream position.position(long p) Moves to the specified stream position.intread(ByteBuffer target) Reads a sequence of bytes from this channel into the given buffer.longsize()Implemented as a matter of principle, but not needed in the context of TIFF reader.truncate(long size) Unsupported operation (for now).private static IOExceptionunsupported(String operation) Creates the exception to throw for an unsupported operation.(package private) static ChannelDataInputwrap(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.intwrite(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:
sizein interfaceSeekableByteChannel- Throws:
IOException
-
position
public long position()Returns the current stream position.- Specified by:
positionin interfaceSeekableByteChannel
-
position
Moves to the specified stream position.- Specified by:
positionin 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:
readin interfaceReadableByteChannel- Specified by:
readin interfaceSeekableByteChannel- Throws:
IOException
-
write
Unsupported operation (for now).- Specified by:
writein interfaceSeekableByteChannel- Specified by:
writein interfaceWritableByteChannel- Throws:
IOException
-
truncate
Unsupported operation (for now).- Specified by:
truncatein 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.
-