Module swim.codec
Package swim.codec

Class Binary


  • public final class Binary
    extends Object
    Byte Input/Output factory.

    The Binary.byteArrayOutput(...) family of functions return an Output that writes bytes to a growable array, and bind a byte[] array containing all written bytes.

    The Binary.byteBufferOutput(...) family of functions return an Output that writes bytes to a growable array, and bind a ByteBuffer containing all written bytes.

    • 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)
      • outputBuffer

        public static OutputBuffer<ByteBuffer> outputBuffer​(byte[] array,
                                                            int offset,
                                                            int length)
      • byteArrayOutput

        public static Output<byte[]> byteArrayOutput​(int initialCapacity,
                                                     OutputSettings settings)
        Returns a new Output that appends bytes to a growable array, pre-allocated with space for initialCapacity bytes, using the given settings. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a byte[] array with the current output state at any time.
      • byteArrayOutput

        public static Output<byte[]> byteArrayOutput​(int initialCapacity)
        Returns a new Output that appends bytes to a growable array, pre-allocated with space for initialCapacity bytes. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a byte[] array with the current output state at any time.
      • byteArrayOutput

        public static Output<byte[]> byteArrayOutput​(OutputSettings settings)
        Returns a new Output that appends bytes to a growable array, using the given settings. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a byte[] array with the current output state at any time.
      • byteArrayOutput

        public static Output<byte[]> byteArrayOutput()
        Returns a new Output that appends bytes to a growable array. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a byte[] array with the current output state at any time.
      • byteBufferOutput

        public static Output<ByteBuffer> byteBufferOutput​(int initialCapacity,
                                                          OutputSettings settings)
        Returns a new Output that appends bytes to a growable array, pre-allocated with space for initialCapacity bytes, using the given settings. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a ByteBuffer with the current output state at any time.
      • byteBufferOutput

        public static Output<ByteBuffer> byteBufferOutput​(int initialCapacity)
        Returns a new Output that appends bytes to a growable array, pre-allocated with space for initialCapacity bytes. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a ByteBuffer with the current output state at any time.
      • byteBufferOutput

        public static Output<ByteBuffer> byteBufferOutput​(OutputSettings settings)
        Returns a new Output that appends bytes to a growable array, using the given settings. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a ByteBuffer with the current output state at any time.
      • byteBufferOutput

        public static Output<ByteBuffer> byteBufferOutput()
        Returns a new Output that appends bytes to a growable array. The returned Output accepts an unbounded number of bytes, remaining permanently in the cont state, and can bind a ByteBuffer with the current output state at any time.
      • outputParser

        public static <O> Parser<O> outputParser​(Output<O> output)
        Returns a new Parser that writes decoded bytes to the given output.
      • parseOutput

        public static <O> Parser<O> parseOutput​(Output<O> output,
                                                Input input)
        Writes the decoded bytes of the input buffer to the given output, returning a Parser continuation that knows how to decode subsequent input buffers.
      • nullParser

        public static <O> Parser<O> nullParser()
      • parseNull

        public static <O> Parser<O> parseNull​(Input input)
      • byteArrayWriter

        public static Writer<byte[],​?> byteArrayWriter()
      • byteArrayWriter

        public static Writer<Object,​byte[]> byteArrayWriter​(byte[] input)
      • byteArrayWriter

        public static <O> Writer<Object,​O> byteArrayWriter​(O value,
                                                                 byte[] input)
      • byteBufferEWriter

        public static <O> Writer<Object,​O> byteBufferEWriter​(O value,
                                                                   ByteBuffer input)