- All Known Implementing Classes:
CharsetStringBuilder.DecoderStringBuilder,CharsetStringBuilder.Iso88591StringBuilder,CharsetStringBuilder.ReportingUtf8StringBuilder,CharsetStringBuilder.UsAsciiStringBuilder,Utf8StringBuilder
public interface CharsetStringBuilder
Build a string from a sequence of bytes.
Implementations of this interface are optimized for processing a mix of calls to already decoded
character based appends (e.g. append(char) and calls to undecoded byte methods (e.g. append(byte).
This is particularly useful for decoding % encoded strings that are mostly already decoded but may contain
escaped byte sequences that are not decoded. The standard CharsetDecoder API is not well suited for this
use-case.
Any coding errors in the string will be reported by a CharacterCodingException thrown
from the build() method.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classstatic classstatic classExtended Utf8StringBuilder that mimicsCodingErrorAction.REPORTbehaviour forCharsetStringBuildermethods.static class -
Method Summary
Modifier and TypeMethodDescriptionvoidappend(byte b) default voidappend(byte[] bytes) default voidappend(byte[] b, int offset, int length) voidappend(char c) default voidappend(CharSequence chars, int offset, int length) default voidappend(ByteBuffer buf) build()Build the completed string and reset the buffer.static CharsetStringBuilderforCharset(Charset charset) voidreset()
-
Method Details
-
append
void append(byte b) -
append
void append(char c) -
append
default void append(byte[] bytes) -
append
default void append(byte[] b, int offset, int length) -
append
-
append
-
build
Build the completed string and reset the buffer.
- Returns:
- The decoded built string which must be complete in regard to any multibyte sequences.
- Throws:
CharacterCodingException- If the bytes cannot be correctly decoded or a multibyte sequence is incomplete.
-
reset
void reset() -
forCharset
-