Top Description Inners Methods
org.eclipse.jetty.util

public Interface CharsetStringBuilder

Known Direct Implementers
org.eclipse.jetty.util.CharsetStringBuilder.Iso88591StringBuilder, org.eclipse.jetty.util.CharsetStringBuilder.UsAsciiStringBuilder, org.eclipse.jetty.util.CharsetStringBuilder.DecoderStringBuilder, org.eclipse.jetty.util.Utf8StringBuilder
Imports
java.nio.ByteBuffer, java.nio.charset.CharacterCodingException, .Charset, .CharsetDecoder, .CodingErrorAction, .StandardCharsets, java.util.Arrays, .Objects

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.

See Also
{@link Utf8StringBuilder} for UTF-8 decoding with replacement of coding errors and/or fast fail behaviour., {@link CharsetDecoder} for decoding arbitrary Charsets with control over CodingErrorAction.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
CharsetStringBuilder.ReportingUtf8StringBuilder

Extended Utf8StringBuilder that mimics CodingErrorAction#REPORT behaviour for CharsetStringBuilder methods.

public static class

Method Summary

Modifier and TypeMethod and Description
public void
append(byte
An encoded byte to append
b
)

public void
append(char
A decoded character to append
c
)

public default void
append(byte[]
Array of encoded bytes to append
bytes
)

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
append(ByteBuffer
Buffer of encoded bytes to append. The bytes are consumed from the buffer.
buf
)

public String

Returns:

The decoded built string which must be complete in regard to any multibyte sequences.
build
()

Build the completed string and reset the buffer.

public static CharsetStringBuilder

Returns:

A CharsetStringBuilder suitable for the charset.
forCharset
(Charset
The charset
charset
)

public int

Returns:

the length in characters
length
()

public void
reset()

Resets this sequence to be empty.

Method Detail

appendback to summary
public void append(byte b)
Parameters
b:byte

An encoded byte to append

appendback to summary
public void append(char c)
Parameters
c:char

A decoded character to append

appendback to summary
public default void append(byte[] bytes)
Parameters
bytes:byte[]

Array of encoded bytes to append

appendback to summary
public default void append(byte[] b, int offset, int length)
Parameters
b:byte[]

Array of encoded bytes

offset:int

offset into the array

length:int

the number of bytes to append from the array.

appendback to summary
public default void append(CharSequence chars, int offset, int length)
Parameters
chars:CharSequence

sequence of decoded characters

offset:int

offset into the array

length:int

the number of character to append from the sequence.

appendback to summary
public default void append(ByteBuffer buf)
Parameters
buf:ByteBuffer

Buffer of encoded bytes to append. The bytes are consumed from the buffer.

buildback to summary
public String build() throws CharacterCodingException

Build the completed string and reset the buffer.

Returns:String

The decoded built string which must be complete in regard to any multibyte sequences.

Exceptions
CharacterCodingException:
If the bytes cannot be correctly decoded or a multibyte sequence is incomplete.
forCharsetback to summary
public static CharsetStringBuilder forCharset(Charset charset)
Parameters
charset:Charset

The charset

Returns:CharsetStringBuilder

A CharsetStringBuilder suitable for the charset.

lengthback to summary
public int length()
Returns:int

the length in characters

resetback to summary
public void reset()

Resets this sequence to be empty.

org.eclipse.jetty.util back to summary

public Class CharsetStringBuilder.DecoderStringBuilder

extends Object
implements CharsetStringBuilder
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.util.CharsetStringBuilder.DecoderStringBuilder
All Implemented Interfaces
org.eclipse.jetty.util.CharsetStringBuilder

Field Summary

Modifier and TypeField and Description
private ByteBuffer
private final CharsetDecoder
private final StringBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
append(byte
An encoded byte to append
b
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

public void
append(char
A decoded character to append
c
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

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.eclipse.jetty.util.CharsetStringBuilder.append.

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.eclipse.jetty.util.CharsetStringBuilder.append.

public void
append(ByteBuffer
Buffer of encoded bytes to append. The bytes are consumed from the buffer.
buf
)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

public String
build()

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

private void
ensureSpace(int needed)

public int
public void
reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_bufferback to summary
private ByteBuffer _buffer
_decoderback to summary
private final CharsetDecoder _decoder
_stringBuilderback to summary
private final StringBuilder _stringBuilder

Constructor Detail

DecoderStringBuilderback to summary
public DecoderStringBuilder(CharsetDecoder charsetDecoder)

Method Detail

appendback to summary
public void append(byte b)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
b:byte

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

An encoded byte to append

Annotations
@Override
appendback to summary
public void append(char c)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
c:char

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

A decoded character to append

Annotations
@Override
appendback to summary
public void append(CharSequence chars, int offset, int length)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
chars:CharSequence

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

sequence of decoded characters

offset:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

offset into the array

length:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

the number of character to append from the sequence.

Annotations
@Override
appendback to summary
public void append(byte[] b, int offset, int length)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
b:byte[]

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

Array of encoded bytes

offset:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

offset into the array

length:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

the number of bytes to append from the array.

Annotations
@Override
appendback to summary
public void append(ByteBuffer buf)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
buf:ByteBuffer

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

Buffer of encoded bytes to append. The bytes are consumed from the buffer.

Annotations
@Override
buildback to summary
public String build() throws CharacterCodingException

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

Returns:String

The decoded built string which must be complete in regard to any multibyte sequences.

Annotations
@Override
Exceptions
CharacterCodingException:
If the bytes cannot be correctly decoded or a multibyte sequence is incomplete.
ensureSpaceback to summary
private void ensureSpace(int needed)
lengthback to summary
public int length()

Implements org.eclipse.jetty.util.CharsetStringBuilder.length.

Returns:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.length.

the length in characters

Annotations
@Override
resetback to summary
public void reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Annotations
@Override
org.eclipse.jetty.util back to summary

public Class CharsetStringBuilder.Iso88591StringBuilder

extends Object
implements CharsetStringBuilder
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.util.CharsetStringBuilder.Iso88591StringBuilder
All Implemented Interfaces
org.eclipse.jetty.util.CharsetStringBuilder

Field Summary

Modifier and TypeField and Description
private final StringBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
append(byte
An encoded byte to append
b
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

public void
append(char
A decoded character to append
c
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

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.eclipse.jetty.util.CharsetStringBuilder.append.

public String
build()

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

public int
public void
reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_builderback to summary
private final StringBuilder _builder

Constructor Detail

Iso88591StringBuilderback to summary
public Iso88591StringBuilder()

Method Detail

appendback to summary
public void append(byte b)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
b:byte

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

An encoded byte to append

Annotations
@Override
appendback to summary
public void append(char c)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
c:char

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

A decoded character to append

Annotations
@Override
appendback to summary
public void append(CharSequence chars, int offset, int length)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
chars:CharSequence

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

sequence of decoded characters

offset:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

offset into the array

length:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

the number of character to append from the sequence.

Annotations
@Override
buildback to summary
public String build()

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

Returns:String

The decoded built string which must be complete in regard to any multibyte sequences.

Annotations
@Override
lengthback to summary
public int length()

Implements org.eclipse.jetty.util.CharsetStringBuilder.length.

Returns:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.length.

the length in characters

Annotations
@Override
resetback to summary
public void reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Annotations
@Override
org.eclipse.jetty.util back to summary

public Class CharsetStringBuilder.ReportingUtf8StringBuilder

extends Utf8StringBuilder
Class Inheritance

Extended Utf8StringBuilder that mimics CodingErrorAction#REPORT behaviour for CharsetStringBuilder methods.

Field Summary

Inherited from org.eclipse.jetty.util.Utf8StringBuilder:
_buffer_stateLOGREPLACEMENT

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
build()

Overrides org.eclipse.jetty.util.Utf8StringBuilder.build.

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

public String
toCompleteString()

Overrides org.eclipse.jetty.util.Utf8StringBuilder.toCompleteString.

Get the completely decoded string, which is equivalent to calling complete() then toString().
Inherited from org.eclipse.jetty.util.Utf8StringBuilder:
appendappendappendappendappendappendappendappendappendBytebufferAppendbufferResetcheckCharAppendcompletehasCodingErrorsisCompletelengthpartialResetresettakeCompleteStringtakePartialStringtoPartialStringtoString

Constructor Detail

ReportingUtf8StringBuilderback to summary
public ReportingUtf8StringBuilder()

Method Detail

buildback to summary
public String build() throws CharacterCodingException

Overrides org.eclipse.jetty.util.Utf8StringBuilder.build.

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

Returns:String

The decoded built string which must be complete in regard to any multibyte sequences.

Annotations
@Override
Exceptions
CharacterCodingException:
If the bytes cannot be correctly decoded or a multibyte sequence is incomplete.
toCompleteStringback to summary
public String toCompleteString()

Overrides org.eclipse.jetty.util.Utf8StringBuilder.toCompleteString.

Doc from org.eclipse.jetty.util.Utf8StringBuilder.toCompleteString.

Get the completely decoded string, which is equivalent to calling complete() then toString().

Returns:String

The completely decoded string.

Annotations
@Override
org.eclipse.jetty.util back to summary

public Class CharsetStringBuilder.UsAsciiStringBuilder

extends Object
implements CharsetStringBuilder
Class Inheritance
  • java.lang.Object
  • org.eclipse.jetty.util.CharsetStringBuilder.UsAsciiStringBuilder
All Implemented Interfaces
org.eclipse.jetty.util.CharsetStringBuilder

Field Summary

Modifier and TypeField and Description
private final StringBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
append(byte
An encoded byte to append
b
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

public void
append(char
A decoded character to append
c
)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

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.eclipse.jetty.util.CharsetStringBuilder.append.

public String
build()

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

public int
public void
reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_builderback to summary
private final StringBuilder _builder

Constructor Detail

UsAsciiStringBuilderback to summary
public UsAsciiStringBuilder()

Method Detail

appendback to summary
public void append(byte b)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
b:byte

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

An encoded byte to append

Annotations
@Override
appendback to summary
public void append(char c)

Implements org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
c:char

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

A decoded character to append

Annotations
@Override
appendback to summary
public void append(CharSequence chars, int offset, int length)

Overrides default org.eclipse.jetty.util.CharsetStringBuilder.append.

Parameters
chars:CharSequence

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

sequence of decoded characters

offset:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

offset into the array

length:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.append.

the number of character to append from the sequence.

Annotations
@Override
buildback to summary
public String build()

Implements org.eclipse.jetty.util.CharsetStringBuilder.build.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.build.

Build the completed string and reset the buffer.

Returns:String

The decoded built string which must be complete in regard to any multibyte sequences.

Annotations
@Override
lengthback to summary
public int length()

Implements org.eclipse.jetty.util.CharsetStringBuilder.length.

Returns:int

Doc from org.eclipse.jetty.util.CharsetStringBuilder.length.

the length in characters

Annotations
@Override
resetback to summary
public void reset()

Implements org.eclipse.jetty.util.CharsetStringBuilder.reset.

Doc from org.eclipse.jetty.util.CharsetStringBuilder.reset.

Resets this sequence to be empty.

Annotations
@Override