Build a string from a sequence of bytes and/or characters.
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.
Charsets with control over CodingErrorAction.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static class | |
| public static class | CharsetStringBuilder.ReportingUtf8StringBuilder
Extended Utf8StringBuilder that mimics |
| public static class |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public default void | |
| public default void | append(byte[]
Array of encoded bytes b, int offset into the array offset, int the number of bytes to append from the array. length)
|
| public default void | append(CharSequence
sequence of decoded characters chars, int offset into the array offset, int the number of character to append from the sequence. length)
|
| public default void | |
| public String | Returns: The decoded built string which must be complete in regard to any multibyte sequences.Build the completed string and reset the buffer. |
| public static CharsetStringBuilder | |
| public int | |
| public void |
| append | back to summary |
|---|---|
public void append(byte b)
| |
| append | back to summary |
|---|---|
public void append(char c)
| |
| append | back to summary |
|---|---|
public default void append(byte[] bytes)
| |
| append | back to summary |
|---|---|
public default void append(byte[] b, int offset, int length)
| |
| append | back to summary |
|---|---|
public default void append(CharSequence chars, int offset, int length)
| |
| append | back to summary |
|---|---|
public default void append(ByteBuffer buf)
| |
| build | back to summary |
|---|---|
| public String build() throws CharacterCodingException Build the completed string and reset the buffer.
| |
| forCharset | back to summary |
|---|---|
public static CharsetStringBuilder forCharset(Charset charset)
| |
| length | back to summary |
|---|---|
public int length()
| |
| reset | back to summary |
|---|---|
| public void reset() Resets this sequence to be empty. | |
| Modifier and Type | Field and Description |
|---|---|
| private ByteBuffer | |
| private final CharsetDecoder | |
| private final StringBuilder |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | append(byte
An encoded byte to append b)Implements org. |
| public void | append(char
A decoded character to append c)Implements org. |
| public void | append(CharSequence
sequence of decoded characters chars, int offset into the array offset, int the number of character to append from the sequence. length)Overrides default org. |
| public void | append(byte[]
Array of encoded bytes b, int offset into the array offset, int the number of bytes to append from the array. length)Overrides default org. |
| public void | append(ByteBuffer
Buffer of encoded bytes to append. The bytes are consumed from the buffer. buf)Overrides default org. |
| public String | build()
Implements org. Build the completed string and reset the buffer. |
| private void | |
| public int | |
| public void | reset()
Implements org. Resets this sequence to be empty. |
| _buffer | back to summary |
|---|---|
| private ByteBuffer _buffer | |
| _decoder | back to summary |
|---|---|
| private final CharsetDecoder _decoder | |
| _stringBuilder | back to summary |
|---|---|
| private final StringBuilder _stringBuilder | |
| DecoderStringBuilder | back to summary |
|---|---|
| public DecoderStringBuilder(CharsetDecoder charsetDecoder) | |
| append | back to summary |
|---|---|
| public void append(byte b) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(char c) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(CharSequence chars, int offset, int length) Overrides default org.
| |
| append | back to summary |
|---|---|
| public void append(byte[] b, int offset, int length) Overrides default org.
| |
| append | back to summary |
|---|---|
| public void append(ByteBuffer buf) Overrides default org.
| |
| build | back to summary |
|---|---|
| public String build() throws CharacterCodingException Implements org. Doc from org. Build the completed string and reset the buffer.
| |
| ensureSpace | back to summary |
|---|---|
| private void ensureSpace(int needed) | |
| length | back to summary |
|---|---|
| public int length() Implements org.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Resets this sequence to be empty.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final StringBuilder |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | append(byte
An encoded byte to append b)Implements org. |
| public void | append(char
A decoded character to append c)Implements org. |
| public void | append(CharSequence
sequence of decoded characters chars, int offset into the array offset, int the number of character to append from the sequence. length)Overrides default org. |
| public String | build()
Implements org. Build the completed string and reset the buffer. |
| public int | |
| public void | reset()
Implements org. Resets this sequence to be empty. |
| _builder | back to summary |
|---|---|
| private final StringBuilder _builder | |
| Iso88591StringBuilder | back to summary |
|---|---|
| public Iso88591StringBuilder() | |
| append | back to summary |
|---|---|
| public void append(byte b) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(char c) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(CharSequence chars, int offset, int length) Overrides default org.
| |
| build | back to summary |
|---|---|
| public String build() Implements org. Doc from org. Build the completed string and reset the buffer. | |
| length | back to summary |
|---|---|
| public int length() Implements org.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Resets this sequence to be empty.
| |
CodingErrorAction#REPORT behaviour
for CharsetStringBuilder methods.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | build()
Overrides org. Implements org. Build the completed string and reset the buffer. |
| public String | toCompleteString()
Overrides org. complete() then toString().
|
| ReportingUtf8StringBuilder | back to summary |
|---|---|
| public ReportingUtf8StringBuilder() | |
| build | back to summary |
|---|---|
| public String build() throws CharacterCodingException Overrides org. Implements org. Doc from org. Build the completed string and reset the buffer.
| |
| toCompleteString | back to summary |
|---|---|
| public String toCompleteString() Overrides org. Doc from org. Get the completely decoded string, which is equivalent to calling | |
| Modifier and Type | Field and Description |
|---|---|
| private final StringBuilder |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | append(byte
An encoded byte to append b)Implements org. |
| public void | append(char
A decoded character to append c)Implements org. |
| public void | append(CharSequence
sequence of decoded characters chars, int offset into the array offset, int the number of character to append from the sequence. length)Overrides default org. |
| public String | build()
Implements org. Build the completed string and reset the buffer. |
| public int | |
| public void | reset()
Implements org. Resets this sequence to be empty. |
| _builder | back to summary |
|---|---|
| private final StringBuilder _builder | |
| UsAsciiStringBuilder | back to summary |
|---|---|
| public UsAsciiStringBuilder() | |
| append | back to summary |
|---|---|
| public void append(byte b) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(char c) Implements org.
| |
| append | back to summary |
|---|---|
| public void append(CharSequence chars, int offset, int length) Overrides default org.
| |
| build | back to summary |
|---|---|
| public String build() Implements org. Doc from org. Build the completed string and reset the buffer. | |
| length | back to summary |
|---|---|
| public int length() Implements org.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Resets this sequence to be empty.
| |