- java.lang.Object
-
- swim.codec.Base16
-
-
Method Summary
Modifier and Type Method Description Stringalphabet()Returns a 16 character string, where the character at indexiis the encoding of the base-16 digiti.Writer<byte[],?>byteArrayWriter()Returns aWriterthat, when fed an inputbyte[]array, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte array.Writer<?,byte[]>byteArrayWriter(byte[] input)Returns aWritercontinuation that writes the base-16 (hexadecimal) encoding of theinputbyte array.Writer<ByteBuffer,?>byteBufferWriter()Returns aWriterthat, when fed an inputByteBuffer, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.Writer<?,ByteBuffer>byteBufferWriter(ByteBuffer input)Returns aWritercontinuation that writes the base-16 (hexadecimal) encoding of theinputbyte buffer.static intdecodeDigit(int c)Returns the 4-bit quantity represented by the base-16 digitc.charencodeDigit(int b)Returns the Unicode code point of the base-16 digit that encodes the given 4-bit quantity.static booleanisDigit(int c)Returnstrueif the Unicode code pointcis a valid base-16 digit.static Base16lowercase()Returns theBase16encoding with lowercase alphanumeric digits.static <O> Parser<O>parse(Input input, Output<O> output)Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes tooutput, returning aParsercontinuation that knows how to parse any additional input.static Parser<byte[]>parseByteArray(Input input)Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes to a growable array, returning aParsercontinuation that knows how to parse any additional input.static Parser<ByteBuffer>parseByteBuffer(Input input)Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes to a growable buffer, returning aParsercontinuation that knows how to parse any additional input.static <O> Parser<O>parser(Output<O> output)Returns aParserthat decodes base-16 (hexadecimal) encoded input, and writes the decoded bytes tooutput.static Base16uppercase()Returns theBase16encoding with uppercase alphanumeric digits.Writer<?,?>writeByteArray(byte[] input, Output<?> output)Writes the base-16 (hexadecimal) encoding of theinputbyte array to theoutput, returning aWritercontinuation that knows how to write any remaining output that couldn't be immediately generated.Writer<?,?>writeByteBuffer(ByteBuffer input, Output<?> output)Writes the base-16 (hexadecimal) encoding of theinputbyte buffer to theoutput, returning aWritercontinuation that knows how to write any remaining output that couldn't be immediately generated.Writer<?,?>writeInt(int input, Output<?> output)Writer<?,?>writeInt(int input, Output<?> output, int width)Writer<?,?>writeIntLiteral(int input, Output<?> output)Writer<?,?>writeIntLiteral(int input, Output<?> output, int width)Writer<?,?>writeLong(long input, Output<?> output)Writer<?,?>writeLong(long input, Output<?> output, int width)Writer<?,?>writeLongLiteral(long input, Output<?> output)Writer<?,?>writeLongLiteral(long input, Output<?> output, int width)static voidwriteQuantum(int c1, int c2, Output<?> output)Decodes the base-16 digitsc1andc2, and writes the 8-bit quantity they represent to the givenoutput.
-
-
-
Method Detail
-
lowercase
public static Base16 lowercase()
Returns theBase16encoding with lowercase alphanumeric digits.
-
uppercase
public static Base16 uppercase()
Returns theBase16encoding with uppercase alphanumeric digits.
-
isDigit
public static boolean isDigit(int c)
Returnstrueif the Unicode code pointcis a valid base-16 digit.
-
decodeDigit
public static int decodeDigit(int c)
Returns the 4-bit quantity represented by the base-16 digitc.- Throws:
IllegalArgumentException- ifcis not a valid base-16 digit.
-
writeQuantum
public static void writeQuantum(int c1, int c2, Output<?> output)Decodes the base-16 digitsc1andc2, and writes the 8-bit quantity they represent to the givenoutput.
-
parser
public static <O> Parser<O> parser(Output<O> output)
Returns aParserthat decodes base-16 (hexadecimal) encoded input, and writes the decoded bytes tooutput.
-
parse
public static <O> Parser<O> parse(Input input, Output<O> output)
Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes tooutput, returning aParsercontinuation that knows how to parse any additional input.
-
parseByteArray
public static Parser<byte[]> parseByteArray(Input input)
Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes to a growable array, returning aParsercontinuation that knows how to parse any additional input. The returnedParserbindsabyte[]array containing all parsed base-16 data.
-
parseByteBuffer
public static Parser<ByteBuffer> parseByteBuffer(Input input)
Parses the base-16 (hexadecimal) encodedinput, and writes the decoded bytes to a growable buffer, returning aParsercontinuation that knows how to parse any additional input. The returnedParserbindsaByteBuffercontaining all parsed base-16 data.
-
alphabet
public String alphabet()
Returns a 16 character string, where the character at indexiis the encoding of the base-16 digiti.
-
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 aWriterthat, when fed an inputbyte[]array, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte array.
-
byteArrayWriter
public Writer<?,byte[]> byteArrayWriter(byte[] input)
Returns aWritercontinuation that writes the base-16 (hexadecimal) encoding of theinputbyte array.
-
byteBufferWriter
public Writer<ByteBuffer,?> byteBufferWriter()
Returns aWriterthat, when fed an inputByteBuffer, returns a continuation that writes the base-16 (hexadecimal) encoding of the input byte buffer.
-
byteBufferWriter
public Writer<?,ByteBuffer> byteBufferWriter(ByteBuffer input)
Returns aWritercontinuation that writes the base-16 (hexadecimal) encoding of theinputbyte buffer.
-
writeByteArray
public Writer<?,?> writeByteArray(byte[] input, Output<?> output)
Writes the base-16 (hexadecimal) encoding of theinputbyte array to theoutput, returning aWritercontinuation that knows how to write any remaining output that couldn't be immediately generated.
-
writeByteBuffer
public Writer<?,?> writeByteBuffer(ByteBuffer input, Output<?> output)
Writes the base-16 (hexadecimal) encoding of theinputbyte buffer to theoutput, returning aWritercontinuation that knows how to write any remaining output that couldn't be immediately generated.
-
-