Module swim.codec
Package swim.codec

Class Base16

java.lang.Object
swim.codec.Base16

public final class Base16 extends Object
Base-16 (hexadecimal) encoding Parser/Writer factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a 16 character string, where the character at index i is the encoding of the base-16 digit i.
    Writer<byte[],?>
    Returns a Writer that, when fed an input byte[] array, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte array.
    Writer<?,byte[]>
    byteArrayWriter(byte[] input)
    Returns a Writer continuation that writes the base-16 (hexadecimal) encoding of the input byte array.
    Returns a Writer that, when fed an input ByteBuffer, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.
    Returns a Writer continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.
    static int
    decodeDigit(int c)
    Returns the 4-bit quantity represented by the base-16 digit c.
    char
    encodeDigit(int b)
    Returns the Unicode code point of the base-16 digit that encodes the given 4-bit quantity.
    static boolean
    isDigit(int c)
    Returns true if the Unicode code point c is a valid base-16 digit.
    static Base16
    Returns the Base16 encoding with lowercase alphanumeric digits.
    static <O> Parser<O>
    parse(Input input, Output<O> output)
    Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to output, returning a Parser continuation that knows how to parse any additional input.
    static Parser<byte[]>
    Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to a growable array, returning a Parser continuation that knows how to parse any additional input.
    Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to a growable buffer, returning a Parser continuation that knows how to parse any additional input.
    static <O> Parser<O>
    parser(Output<O> output)
    Returns a Parser that decodes base-16 (hexadecimal) encoded input, and writes the decoded bytes to output.
    static Base16
    Returns the Base16 encoding with uppercase alphanumeric digits.
    Writer<?,?>
    writeByteArray(Output<?> output, byte[] input)
    Writes the base-16 (hexadecimal) encoding of the input byte array to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
    Writer<?,?>
    writeByteBuffer(Output<?> output, ByteBuffer input)
    Writes the base-16 (hexadecimal) encoding of the input byte buffer to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
    Writer<?,?>
    writeInt(Output<?> output, int input)
     
    Writer<?,?>
    writeInt(Output<?> output, int input, int width)
     
    Writer<?,?>
    writeIntLiteral(Output<?> output, int input)
     
    Writer<?,?>
    writeIntLiteral(Output<?> output, int input, int width)
     
    Writer<?,?>
    writeLong(Output<?> output, long input)
     
    Writer<?,?>
    writeLong(Output<?> output, long input, int width)
     
    Writer<?,?>
    writeLongLiteral(Output<?> output, long input)
     
    Writer<?,?>
    writeLongLiteral(Output<?> output, long input, int width)
     
    static <T> Output<T>
    writeQuantum(Output<T> output, int c1, int c2)
    s Decodes the base-16 digits c1 and c2, and writes the 8-bit quantity they represent to the given output.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • alphabet

      public String alphabet()
      Returns a 16 character string, where the character at index i is the encoding of the base-16 digit i.
    • encodeDigit

      public char encodeDigit(int b)
      Returns the Unicode code point of the base-16 digit that encodes the given 4-bit quantity.
    • byteArrayWriter

      public Writer<byte[],?> byteArrayWriter()
      Returns a Writer that, when fed an input byte[] array, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte array.
    • byteArrayWriter

      public Writer<?,byte[]> byteArrayWriter(byte[] input)
      Returns a Writer continuation that writes the base-16 (hexadecimal) encoding of the input byte array.
    • byteBufferWriter

      public Writer<ByteBuffer,?> byteBufferWriter()
      Returns a Writer that, when fed an input ByteBuffer, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.
    • byteBufferWriter

      public Writer<?,ByteBuffer> byteBufferWriter(ByteBuffer input)
      Returns a Writer continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.
    • writeByteArray

      public Writer<?,?> writeByteArray(Output<?> output, byte[] input)
      Writes the base-16 (hexadecimal) encoding of the input byte array to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
    • writeByteBuffer

      public Writer<?,?> writeByteBuffer(Output<?> output, ByteBuffer input)
      Writes the base-16 (hexadecimal) encoding of the input byte buffer to the output, returning a Writer continuation that knows how to write any remaining output that couldn't be immediately generated.
    • writeInt

      public Writer<?,?> writeInt(Output<?> output, int input, int width)
    • writeInt

      public Writer<?,?> writeInt(Output<?> output, int input)
    • writeLong

      public Writer<?,?> writeLong(Output<?> output, long input, int width)
    • writeLong

      public Writer<?,?> writeLong(Output<?> output, long input)
    • writeIntLiteral

      public Writer<?,?> writeIntLiteral(Output<?> output, int input, int width)
    • writeIntLiteral

      public Writer<?,?> writeIntLiteral(Output<?> output, int input)
    • writeLongLiteral

      public Writer<?,?> writeLongLiteral(Output<?> output, long input, int width)
    • writeLongLiteral

      public Writer<?,?> writeLongLiteral(Output<?> output, long input)
    • lowercase

      public static Base16 lowercase()
      Returns the Base16 encoding with lowercase alphanumeric digits.
    • uppercase

      public static Base16 uppercase()
      Returns the Base16 encoding with uppercase alphanumeric digits.
    • parser

      public static <O> Parser<O> parser(Output<O> output)
      Returns a Parser that decodes base-16 (hexadecimal) encoded input, and writes the decoded bytes to output.
    • parse

      public static <O> Parser<O> parse(Input input, Output<O> output)
      Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to output, returning a Parser continuation that knows how to parse any additional input.
    • parseByteArray

      public static Parser<byte[]> parseByteArray(Input input)
      Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to a growable array, returning a Parser continuation that knows how to parse any additional input. The returned Parser binds a byte[] array containing all parsed base-16 data.
    • parseByteBuffer

      public static Parser<ByteBuffer> parseByteBuffer(Input input)
      Parses the base-16 (hexadecimal) encoded input, and writes the decoded bytes to a growable buffer, returning a Parser continuation that knows how to parse any additional input. The returned Parser binds a ByteBuffer containing all parsed base-16 data.
    • isDigit

      public static boolean isDigit(int c)
      Returns true if the Unicode code point c is a valid base-16 digit.
    • decodeDigit

      public static int decodeDigit(int c)
      Returns the 4-bit quantity represented by the base-16 digit c.
      Throws:
      IllegalArgumentException - if c is not a valid base-16 digit.
    • writeQuantum

      public static <T> Output<T> writeQuantum(Output<T> output, int c1, int c2)
      s Decodes the base-16 digits c1 and c2, and writes the 8-bit quantity they represent to the given output.
      Returns:
      the continuation of the output.