- java.lang.Object
-
- swim.codec.Binary
-
public final class Binary extends Object
ByteInput
/Output
factory.The
Binary.byteArrayOutput(...)
family of functions return anOutput
that writes bytes to a growable array, andbind
abyte[]
array containing all written bytes.The
Binary.byteBufferOutput(...)
family of functions return anOutput
that writes bytes to a growable array, andbind
aByteBuffer
containing all written bytes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Output<byte[]>
byteArrayOutput()
Returns a newOutput
that appends bytes to a growable array.static Output<byte[]>
byteArrayOutput(byte[] array)
static Output<byte[]>
byteArrayOutput(int initialCapacity)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes.static Output<byte[]>
byteArrayOutput(int initialCapacity, OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes, using the givensettings
.static Output<byte[]>
byteArrayOutput(OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, using the givensettings
.static Writer<byte[],?>
byteArrayWriter()
static Writer<Object,byte[]>
byteArrayWriter(byte[] input)
static <O> Writer<Object,O>
byteArrayWriter(O value, byte[] input)
static <O> Writer<Object,O>
byteBufferEWriter(O value, ByteBuffer input)
static Output<ByteBuffer>
byteBufferOutput()
Returns a newOutput
that appends bytes to a growable array.static Output<ByteBuffer>
byteBufferOutput(byte[] array)
static Output<ByteBuffer>
byteBufferOutput(int initialCapacity)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes.static Output<ByteBuffer>
byteBufferOutput(int initialCapacity, OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes, using the givensettings
.static Output<ByteBuffer>
byteBufferOutput(OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, using the givensettings
.static Writer<ByteBuffer,Object>
byteBufferWriter()
static Writer<Object,ByteBuffer>
byteBufferWriter(ByteBuffer input)
static Encoder<ReadableByteChannel,ReadableByteChannel>
channelEncoder()
static Encoder<ReadableByteChannel,ReadableByteChannel>
channelEncoder(ReadableByteChannel input)
static <O> Decoder<O>
decode(InputStream input, Decoder<O> decoder)
static InputBuffer
input(byte... bytes)
static InputBuffer
inputBuffer(byte[] array)
static InputBuffer
inputBuffer(byte[] array, int offset, int length)
static InputBuffer
inputBuffer(ByteBuffer buffer)
static <O> Parser<O>
nullParser()
static OutputBuffer<ByteBuffer>
outputBuffer(byte[] array)
static OutputBuffer<ByteBuffer>
outputBuffer(byte[] array, int offset, int length)
static OutputBuffer<ByteBuffer>
outputBuffer(ByteBuffer buffer)
static <O> Parser<O>
outputParser(Output<O> output)
Returns a newParser
that writes decoded bytes to the givenoutput
.static <O> Parser<O>
parseNull(Input input)
static <O> Parser<O>
parseOutput(Input input, Output<O> output)
Writes the decoded bytes of theinput
buffer to the givenoutput
, returning aParser
continuation that knows how to decode subsequent input buffers.static <O> O
read(InputStream input, Decoder<O> decoder)
static Writer<Object,Object>
writeByteArray(Output<?> output, byte[] input)
static Writer<Object,Object>
writeByteBuffer(Output<?> output, ByteBuffer input)
-
-
-
Method Detail
-
input
public static InputBuffer input(byte... bytes)
-
inputBuffer
public static InputBuffer inputBuffer(byte[] array, int offset, int length)
-
inputBuffer
public static InputBuffer inputBuffer(byte[] array)
-
inputBuffer
public static InputBuffer inputBuffer(ByteBuffer buffer)
-
outputBuffer
public static OutputBuffer<ByteBuffer> outputBuffer(byte[] array, int offset, int length)
-
outputBuffer
public static OutputBuffer<ByteBuffer> outputBuffer(byte[] array)
-
outputBuffer
public static OutputBuffer<ByteBuffer> outputBuffer(ByteBuffer buffer)
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(int initialCapacity, OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes, using the givensettings
. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
abyte[]
array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(int initialCapacity)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
abyte[]
array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, using the givensettings
. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
abyte[]
array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(byte[] array)
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput()
Returns a newOutput
that appends bytes to a growable array. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
abyte[]
array with the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(int initialCapacity, OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes, using the givensettings
. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
aByteBuffer
with the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(int initialCapacity)
Returns a newOutput
that appends bytes to a growable array, pre-allocated with space forinitialCapacity
bytes. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
aByteBuffer
with the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(OutputSettings settings)
Returns a newOutput
that appends bytes to a growable array, using the givensettings
. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
aByteBuffer
with the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(byte[] array)
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput()
Returns a newOutput
that appends bytes to a growable array. The returnedOutput
accepts an unbounded number of bytes, remaining permanently in the cont state, and canbind
aByteBuffer
with the current output state at any time.
-
outputParser
public static <O> Parser<O> outputParser(Output<O> output)
Returns a newParser
that writes decoded bytes to the givenoutput
.
-
parseOutput
public static <O> Parser<O> parseOutput(Input input, Output<O> output)
Writes the decoded bytes of theinput
buffer to the givenoutput
, returning aParser
continuation that knows how to decode subsequent input buffers.
-
nullParser
public static <O> Parser<O> nullParser()
-
byteArrayWriter
public static Writer<byte[],?> byteArrayWriter()
-
byteBufferWriter
public static Writer<ByteBuffer,Object> byteBufferWriter()
-
byteBufferWriter
public static Writer<Object,ByteBuffer> byteBufferWriter(ByteBuffer input)
-
byteBufferEWriter
public static <O> Writer<Object,O> byteBufferEWriter(O value, ByteBuffer input)
-
writeByteBuffer
public static Writer<Object,Object> writeByteBuffer(Output<?> output, ByteBuffer input)
-
channelEncoder
public static Encoder<ReadableByteChannel,ReadableByteChannel> channelEncoder()
-
channelEncoder
public static Encoder<ReadableByteChannel,ReadableByteChannel> channelEncoder(ReadableByteChannel input)
-
decode
public static <O> Decoder<O> decode(InputStream input, Decoder<O> decoder) throws IOException
- Throws:
IOException
-
read
public static <O> O read(InputStream input, Decoder<O> decoder) throws IOException
- Throws:
IOException
-
-