- java.lang.Object
-
- swim.codec.Base64
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract String
alphabet()
Returns a 64 character string, where the character at indexi
is the encoding of the base-64 digiti
.Writer<byte[],?>
byteArrayWriter()
Returns aWriter
that, when fed an inputbyte[]
array, returns a continuation that writes the base-64 (7-bit ASCII) encoding of the input byte array.Writer<?,byte[]>
byteArrayWriter(byte[] input)
Returns aWriter
continuation that writes the base-64 (7-bit ASCII) encoding of theinput
byte array.Writer<ByteBuffer,?>
byteBufferWriter()
Returns aWriter
that, when fed an inputByteBuffer
, returns a continuation that writes the base-64 (7-bit ASCII) encoding of the input byte buffer.Writer<?,ByteBuffer>
byteBufferWriter(ByteBuffer input)
Returns aWriter
continuation that writes the base-64 (7-bit ASCII) encoding of theinput
byte buffer.int
decodeDigit(int c)
Returns the 7-bit quantity represented by the base-64 digitc
.char
encodeDigit(int b)
Returns the Unicode code point of the base-64 digit that encodes the given 7-bit quantity.abstract boolean
isDigit(int c)
Returnstrue
if the Unicode code pointc
is a valid base-64 digit.abstract boolean
isPadded()
Returnstrue
if this base-64 encoding requires padding.abstract Base64
isPadded(boolean isPadded)
Returns thisBase64
encoding with required padding, ifisPadded
istrue
.<O> Parser<O>
parse(Input input, Output<O> output)
Parses the base-64 (7-bit ASCII) encodedinput
, and writes the decoded bytes tooutput
, returning aParser
continuation that knows how to parse any additional input.Parser<byte[]>
parseByteArray(Input input)
Parses the base-64 (7-bit ASCII) encodedinput
, and writes the decoded bytes to a growable array, returning aParser
continuation that knows how to parse any additional input.Parser<ByteBuffer>
parseByteBuffer(Input input)
Parses the base-64 (t-bit ASCII) encodedinput
, and writes the decoded bytes to a growable buffer, returning aParser
continuation that knows how to parse any additional input.<O> Parser<O>
parser(Output<O> output)
Returns aParser
that decodes base-64 (7-bit ASCII) encoded input, and writes the decoded bytes tooutput
.static Base64
standard()
Returns theBase64
encoding with the standard alphabet.static Base64
standard(boolean isPadded)
Returns theBase64
encoding with the standard alphabet, and required padding, ifisPadded
istrue
.static Base64
url()
Returns theBase64
encoding with the url and filename safe alphabet.static Base64
url(boolean isPadded)
Returns theBase64
encoding with the url and filename safe alphabet, and required padding, ifisPadded
istrue
.static Base64
urlUnpadded()
Writer<?,?>
writeByteArray(Output<?> output, byte[] input)
Writes the base-64 (7-bit ASCII) encoding of theinput
byte array to theoutput
, returning aWriter
continuation that knows how to write any remaining output that couldn't be immediately generated.Writer<?,?>
writeByteBuffer(Output<?> output, ByteBuffer input)
Writes the base-64 (7-bit ASCII) encoding of theinput
byte buffer to theoutput
, returning aWriter
continuation that knows how to write any remaining output that couldn't be immediately generated.<T> Output<T>
writeQuantum(Output<T> output, int c1, int c2, int c3, int c4)
Decodes the base-64 digitsc1
,c2
,c3
, andc4
, and writes the 8 to 24 bit quantity they represent to the givenoutput
.
-
-
-
Method Detail
-
alphabet
public abstract String alphabet()
Returns a 64 character string, where the character at indexi
is the encoding of the base-64 digiti
.
-
isPadded
public abstract boolean isPadded()
Returnstrue
if this base-64 encoding requires padding.
-
isPadded
public abstract Base64 isPadded(boolean isPadded)
Returns thisBase64
encoding with required padding, ifisPadded
istrue
.
-
isDigit
public abstract boolean isDigit(int c)
Returnstrue
if the Unicode code pointc
is a valid base-64 digit.
-
decodeDigit
public int decodeDigit(int c)
Returns the 7-bit quantity represented by the base-64 digitc
.- Throws:
IllegalArgumentException
- ifc
is not a valid base-64 digit.
-
encodeDigit
public char encodeDigit(int b)
Returns the Unicode code point of the base-64 digit that encodes the given 7-bit quantity.
-
writeQuantum
public <T> Output<T> writeQuantum(Output<T> output, int c1, int c2, int c3, int c4)
Decodes the base-64 digitsc1
,c2
,c3
, andc4
, and writes the 8 to 24 bit quantity they represent to the givenoutput
.- Returns:
- the continuation of the
output
.
-
parser
public <O> Parser<O> parser(Output<O> output)
Returns aParser
that decodes base-64 (7-bit ASCII) encoded input, and writes the decoded bytes tooutput
.
-
parse
public <O> Parser<O> parse(Input input, Output<O> output)
Parses the base-64 (7-bit ASCII) encodedinput
, and writes the decoded bytes tooutput
, returning aParser
continuation that knows how to parse any additional input.
-
parseByteArray
public Parser<byte[]> parseByteArray(Input input)
Parses the base-64 (7-bit ASCII) encodedinput
, and writes the decoded bytes to a growable array, returning aParser
continuation that knows how to parse any additional input. The returnedParser
binds
abyte[]
array containing all parsed base-64 data.
-
parseByteBuffer
public Parser<ByteBuffer> parseByteBuffer(Input input)
Parses the base-64 (t-bit ASCII) encodedinput
, and writes the decoded bytes to a growable buffer, returning aParser
continuation that knows how to parse any additional input. The returnedParser
binds
aByteBuffer
containing all parsed base-64 data.
-
byteArrayWriter
public Writer<byte[],?> byteArrayWriter()
Returns aWriter
that, when fed an inputbyte[]
array, returns a continuation that writes the base-64 (7-bit ASCII) encoding of the input byte array.
-
byteArrayWriter
public Writer<?,byte[]> byteArrayWriter(byte[] input)
Returns aWriter
continuation that writes the base-64 (7-bit ASCII) encoding of theinput
byte array.
-
byteBufferWriter
public Writer<ByteBuffer,?> byteBufferWriter()
Returns aWriter
that, when fed an inputByteBuffer
, returns a continuation that writes the base-64 (7-bit ASCII) encoding of the input byte buffer.
-
byteBufferWriter
public Writer<?,ByteBuffer> byteBufferWriter(ByteBuffer input)
Returns aWriter
continuation that writes the base-64 (7-bit ASCII) encoding of theinput
byte buffer.
-
writeByteArray
public Writer<?,?> writeByteArray(Output<?> output, byte[] input)
Writes the base-64 (7-bit ASCII) encoding of theinput
byte array to theoutput
, returning aWriter
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-64 (7-bit ASCII) encoding of theinput
byte buffer to theoutput
, returning aWriter
continuation that knows how to write any remaining output that couldn't be immediately generated.
-
standard
public static Base64 standard()
Returns theBase64
encoding with the standard alphabet.
-
standard
public static Base64 standard(boolean isPadded)
Returns theBase64
encoding with the standard alphabet, and required padding, ifisPadded
istrue
.
-
url
public static Base64 url()
Returns theBase64
encoding with the url and filename safe alphabet.
-
urlUnpadded
public static Base64 urlUnpadded()
-
url
public static Base64 url(boolean isPadded)
Returns theBase64
encoding with the url and filename safe alphabet, and required padding, ifisPadded
istrue
.
-
-