- java.lang.Object
-
- swim.codec.Binary
-
public final class Binary extends Object
ByteInput/Outputfactory.The
Binary.byteArrayOutput(...)family of functions return anOutputthat writes bytes to a growable array, andbindabyte[]array containing all written bytes.The
Binary.byteBufferOutput(...)family of functions return anOutputthat writes bytes to a growable array, andbindaByteBuffercontaining all written bytes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Output<byte[]>byteArrayOutput()Returns a newOutputthat appends bytes to a growable array.static Output<byte[]>byteArrayOutput(int initialCapacity)Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes.static Output<byte[]>byteArrayOutput(int initialCapacity, OutputSettings settings)Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes, using the givensettings.static Output<byte[]>byteArrayOutput(OutputSettings settings)Returns a newOutputthat 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 newOutputthat appends bytes to a growable array.static Output<ByteBuffer>byteBufferOutput(int initialCapacity)Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes.static Output<ByteBuffer>byteBufferOutput(int initialCapacity, OutputSettings settings)Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes, using the givensettings.static Output<ByteBuffer>byteBufferOutput(OutputSettings settings)Returns a newOutputthat 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(Decoder<O> decoder, InputStream input)static InputBufferinput(byte... bytes)static InputBufferinputBuffer(byte[] array)static InputBufferinputBuffer(byte[] array, int offset, int length)static InputBufferinputBuffer(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 newParserthat writes decoded bytes to the givenoutput.static <O> Parser<O>parseNull(Input input)static <O> Parser<O>parseOutput(Output<O> output, Input input)Writes the decoded bytes of theinputbuffer to the givenoutput, returning aParsercontinuation that knows how to decode subsequent input buffers.static <O> Oread(Decoder<O> decoder, InputStream input)static Writer<Object,Object>writeByteArray(byte[] input, Output<?> output)static Writer<Object,Object>writeByteBuffer(ByteBuffer input, Output<?> output)
-
-
-
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 newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes, using the givensettings. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindabyte[]array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(int initialCapacity)
Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindabyte[]array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput(OutputSettings settings)
Returns a newOutputthat appends bytes to a growable array, using the givensettings. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindabyte[]array with the current output state at any time.
-
byteArrayOutput
public static Output<byte[]> byteArrayOutput()
Returns a newOutputthat appends bytes to a growable array. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindabyte[]array with the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(int initialCapacity, OutputSettings settings)
Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes, using the givensettings. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindaByteBufferwith the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(int initialCapacity)
Returns a newOutputthat appends bytes to a growable array, pre-allocated with space forinitialCapacitybytes. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindaByteBufferwith the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput(OutputSettings settings)
Returns a newOutputthat appends bytes to a growable array, using the givensettings. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindaByteBufferwith the current output state at any time.
-
byteBufferOutput
public static Output<ByteBuffer> byteBufferOutput()
Returns a newOutputthat appends bytes to a growable array. The returnedOutputaccepts an unbounded number of bytes, remaining permanently in the cont state, and canbindaByteBufferwith the current output state at any time.
-
outputParser
public static <O> Parser<O> outputParser(Output<O> output)
Returns a newParserthat writes decoded bytes to the givenoutput.
-
parseOutput
public static <O> Parser<O> parseOutput(Output<O> output, Input input)
Writes the decoded bytes of theinputbuffer to the givenoutput, returning aParsercontinuation 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(ByteBuffer input, Output<?> output)
-
channelEncoder
public static Encoder<ReadableByteChannel,ReadableByteChannel> channelEncoder()
-
channelEncoder
public static Encoder<ReadableByteChannel,ReadableByteChannel> channelEncoder(ReadableByteChannel input)
-
decode
public static <O> Decoder<O> decode(Decoder<O> decoder, InputStream input) throws IOException
- Throws:
IOException
-
read
public static <O> O read(Decoder<O> decoder, InputStream input) throws IOException
- Throws:
IOException
-
-