Package com.google.crypto.tink.subtle
Class RewindableReadableByteChannel
- java.lang.Object
-
- com.google.crypto.tink.subtle.RewindableReadableByteChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel
public final class RewindableReadableByteChannel extends java.lang.Object implements java.nio.channels.ReadableByteChannelA wrapper aroundReadableByteChannelthat provides rewinding feature: it caches the read bytes so that after reading some initial part of the channel, one can "rewind" the channel and again read the bytes from the beginning. Once the rewinding feature is not needed any more, it can be disabled viadisableRewinding(): this frees the cache memory and forwadrds the subsequentread(java.nio.ByteBuffer)-calls directly to the wrapped channel.- Since:
- 1.1.0
-
-
Constructor Summary
Constructors Constructor Description RewindableReadableByteChannel(java.nio.channels.ReadableByteChannel baseChannel)Constructs a wrapper aroundbaseChannel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddisableRewinding()Disables the rewinding feature.booleanisOpen()intread(java.nio.ByteBuffer dst)voidrewind()Rewinds this buffer to the beginning (if rewinding is still enabled).
-
-
-
Method Detail
-
disableRewinding
public void disableRewinding()
Disables the rewinding feature. After calling this method the attempts to rewind this channel will fail, and the subsequent read()-calls will be forwarded directly to the wrapped channel (after the currently buffered bytes are read).
-
rewind
public void rewind() throws java.io.IOExceptionRewinds this buffer to the beginning (if rewinding is still enabled).- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
-