java.lang.Object
org.xbib.rpm.io.ChannelWrapper
- Direct Known Subclasses:
ReadableChannelWrapper,WritableChannelWrapper
Wraps an IO channel so that bytes may be observed during transmission. Wrappers around IO channels are
used for a variety of purposes, including counting byte output for use in generating headers, calculating
a signature across output bytes, and digesting output bytes using a one-way secure hash.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface describing an object that consumes data from a byte buffer.static class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidempty(WritableByteChannel out, ByteBuffer buffer) Empties the contents of the given buffer into the writable channel provided.static ByteBufferfill(ReadableByteChannel in, int size) Creates a new buffer and fills it with bytes from the provided channel.static ByteBufferfill(ReadableByteChannel in, ByteBuffer buffer) Fills the provided buffer it with bytes from the provided channel.<T> Tfinish(ChannelWrapper.Key<T> object) Initializes a byte counter on this channel.ChannelWrapper.Key<byte[]>startCount(ChannelWrapper.Consumer<byte[]> consumer) Add a new consumer to this channel.
-
Constructor Details
-
ChannelWrapper
public ChannelWrapper()
-
-
Method Details
-
startCount
Initializes a byte counter on this channel.- Returns:
- reference to the new key added to the consumers
-
startCount
Add a new consumer to this channel.- Parameters:
consumer- the channel consumer- Returns:
- reference to the new key added to the consumers
-
finish
-
close
- Throws:
IOException
-
fill
Creates a new buffer and fills it with bytes from the provided channel. The amount of data to read is specified in the arguments.- Parameters:
in- the channel to read fromsize- the number of bytes to read into a new buffer- Returns:
- a new buffer containing the bytes read
- Throws:
IOException- if an IO error occurs
-
fill
Fills the provided buffer it with bytes from the provided channel. The amount of data to read is dependant on the available space in the provided buffer.- Parameters:
in- the channel to read frombuffer- the buffer to read into- Returns:
- the provided buffer
- Throws:
IOException- if an IO error occurs
-
empty
Empties the contents of the given buffer into the writable channel provided. The buffer will be copied to the channel in it's entirety.- Parameters:
out- the channel to write tobuffer- the buffer to write out to the channel- Throws:
IOException- if an IO error occurs
-