- java.lang.Object
-
- swim.codec.Utf8
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <O> Decoder<O>decode(Parser<O> parser, InputStream input)static InputdecodedInput(Input input)static InputdecodedInput(Input input, UtfErrorMode errorMode)static <T> Output<T>decodedOutput(Output<T> output)Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy.static <T> Output<T>decodedOutput(Output<T> output, UtfErrorMode errorMode)Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput, handling invalid code unit sequences according to theerrorModepolicy.static <O> Parser<O>decodedParser(Parser<O> parser)static <O> Parser<O>decodedParser(Parser<O> parser, UtfErrorMode errorMode)static Output<String>decodedString()Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to a growableString, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy.static <O> Decoder<O>decodeOutput(Output<O> output, Input input)Writes the decoded Unicode code points of theinputbuffer to the givenoutput, returning aDecodercontinuation that knows how to decode subsequent input buffers.static <O> Decoder<O>decodeOutput(Output<O> output, InputBuffer input, UtfErrorMode errorMode)Writes the decoded Unicode code points of theinputbuffer to the givenoutput, returning aDecodercontinuation that knows how to decode subsequent input buffers.static <T> Output<T>encodedOutput(Output<T> output)static <T> Output<T>encodedOutput(Output<T> output, UtfErrorMode errorMode)static <I,O>
Writer<I,O>encodedWriter(Writer<I,O> writer)static <I,O>
Writer<I,O>encodedWriter(Writer<I,O> writer, UtfErrorMode errorMode)static <O> Decoder<O>outputDecoder(Output<O> output)Returns a newDecoderthat writes decoded Unicode code points to the givenoutput, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy.static <O> Decoder<O>outputDecoder(Output<O> output, UtfErrorMode errorMode)Returns a newDecoderthat writes decoded Unicode code points to the givenoutput, handling invalid code unit sequences according to theerrorModepolicy.static <O> Parser<O>parseDecoded(Parser<O> parser, Input input)static <O> Parser<O>parseDecoded(Parser<O> parser, Input input, UtfErrorMode errorMode)static Parser<String>parseString(Input input)static Parser<String>parseString(Input input, StringBuilder builder)static Parser<String>parseString(Input input, StringBuilder builder, UtfErrorMode errorMode)static Parser<String>parseString(Input input, UtfErrorMode errorMode)static <O> Oread(Parser<O> parser, InputStream input)static intsizeOf(int c)Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc; returns the size of the Unicode replacement character (U+FFFD) for surrogates and invalid code points.static intsizeOf(int c, UtfErrorMode errorMode)Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc, handling invalid code unit sequences according to theerrorModepolicy.static intsizeOf(String string)Returns the number of bytes in the UTF-8 encoding the givenstring, assuming the Unicode replacement character (U+FFFD) replaces unpaired surrogates and invalid code points.static intsizeOf(String string, UtfErrorMode errorMode)Returns the number of bytes in the UTF-8 encoding the givenstring, handling invalid code unit sequences according to theerrorModepolicy.static Parser<String>stringParser()static Parser<String>stringParser(StringBuilder builder)static Parser<String>stringParser(StringBuilder builder, UtfErrorMode errorMode)static Parser<String>stringParser(UtfErrorMode errorMode)static <I,O>
Writer<I,O>stringWriter(O input)static <I,O>
Writer<I,O>stringWriter(O input, UtfErrorMode errorMode)static <I,O>
Writer<I,O>writeEncoded(Writer<I,O> writer, Output<?> output)static <I,O>
Writer<I,O>writeEncoded(Writer<I,O> writer, Output<?> output, UtfErrorMode errorMode)static <O> Writer<?,O>writeString(O input, Output<?> output)static <O> Writer<?,O>writeString(O input, Output<?> output, UtfErrorMode errorMode)
-
-
-
Method Detail
-
decodedInput
public static Input decodedInput(Input input, UtfErrorMode errorMode)
-
decodedOutput
public static <T> Output<T> decodedOutput(Output<T> output, UtfErrorMode errorMode)
Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput, handling invalid code unit sequences according to theerrorModepolicy.
-
decodedOutput
public static <T> Output<T> decodedOutput(Output<T> output)
Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to the composedoutput, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy.
-
decodedString
public static Output<String> decodedString()
Returns a newOutputthat accepts UTF-8 code unit sequences, and writes decoded Unicode code points to a growableString, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy. The returnedOutputaccepts an unbounded number of UTF-8 code units, remaining permanently in the cont state, andbindsaStringcontaining all decoded code points.
-
encodedOutput
public static <T> Output<T> encodedOutput(Output<T> output, UtfErrorMode errorMode)
-
stringParser
public static Parser<String> stringParser(StringBuilder builder, UtfErrorMode errorMode)
-
stringParser
public static Parser<String> stringParser(StringBuilder builder)
-
stringParser
public static Parser<String> stringParser(UtfErrorMode errorMode)
-
parseString
public static Parser<String> parseString(Input input, StringBuilder builder, UtfErrorMode errorMode)
-
parseString
public static Parser<String> parseString(Input input, StringBuilder builder)
-
parseString
public static Parser<String> parseString(Input input, UtfErrorMode errorMode)
-
stringWriter
public static <I,O> Writer<I,O> stringWriter(O input, UtfErrorMode errorMode)
-
stringWriter
public static <I,O> Writer<I,O> stringWriter(O input)
-
writeString
public static <O> Writer<?,O> writeString(O input, Output<?> output, UtfErrorMode errorMode)
-
outputDecoder
public static <O> Decoder<O> outputDecoder(Output<O> output, UtfErrorMode errorMode)
Returns a newDecoderthat writes decoded Unicode code points to the givenoutput, handling invalid code unit sequences according to theerrorModepolicy.
-
outputDecoder
public static <O> Decoder<O> outputDecoder(Output<O> output)
Returns a newDecoderthat writes decoded Unicode code points to the givenoutput, handling invalid code unit sequences according to theUtfErrorMode.fatal()policy.
-
decodeOutput
public static <O> Decoder<O> decodeOutput(Output<O> output, InputBuffer input, UtfErrorMode errorMode)
Writes the decoded Unicode code points of theinputbuffer to the givenoutput, returning aDecodercontinuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to theerrorModepolicy.
-
decodeOutput
public static <O> Decoder<O> decodeOutput(Output<O> output, Input input)
Writes the decoded Unicode code points of theinputbuffer to the givenoutput, returning aDecodercontinuation that knows how to decode subsequent input buffers. Handles invalid code unit sequences according to theUtfErrorMode.fatal()policy.
-
decodedParser
public static <O> Parser<O> decodedParser(Parser<O> parser, UtfErrorMode errorMode)
-
parseDecoded
public static <O> Parser<O> parseDecoded(Parser<O> parser, Input input, UtfErrorMode errorMode)
-
encodedWriter
public static <I,O> Writer<I,O> encodedWriter(Writer<I,O> writer, UtfErrorMode errorMode)
-
writeEncoded
public static <I,O> Writer<I,O> writeEncoded(Writer<I,O> writer, Output<?> output, UtfErrorMode errorMode)
-
decode
public static <O> Decoder<O> decode(Parser<O> parser, InputStream input) throws IOException
- Throws:
IOException
-
read
public static <O> O read(Parser<O> parser, InputStream input) throws IOException
- Throws:
IOException
-
sizeOf
public static int sizeOf(int c, UtfErrorMode errorMode)Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc, handling invalid code unit sequences according to theerrorModepolicy. Returns the size of theUtfErrorMode.replacementChar()for surrogates and invalid code points, ifUtfErrorMode.isReplacement()is `true`; otherwise returns `0` for surrogates and invalid code points. Uses the two byte modified UTF-8 encoding of the NUL character (U+0000), ifUtfErrorMode.isNonZero()is `true`.
-
sizeOf
public static int sizeOf(int c)
Returns the number of bytes in the UTF-8 encoding of the Unicode code pointc; returns the size of the Unicode replacement character (U+FFFD) for surrogates and invalid code points.
-
sizeOf
public static int sizeOf(String string, UtfErrorMode errorMode)
Returns the number of bytes in the UTF-8 encoding the givenstring, handling invalid code unit sequences according to theerrorModepolicy.
-
sizeOf
public static int sizeOf(String string)
Returns the number of bytes in the UTF-8 encoding the givenstring, assuming the Unicode replacement character (U+FFFD) replaces unpaired surrogates and invalid code points.
-
-