public class CharBuf
extends Writer
implements CharSequence
Growable character buffer used by the JSON internals.
| Constructor and description |
|---|
CharBuf(char[] buffer)Wraps an existing character buffer. |
CharBuf(byte[] bytes)Decodes UTF-8 bytes into the backing character buffer. |
protected CharBuf(int capacity)Creates a growable buffer with the supplied initial capacity. |
protected CharBuf()Creates a growable buffer with the default capacity. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public void |
_len(int location)Sets the current logical buffer length. |
|
public final CharBuf |
add(String str)Appends a string. |
|
public final CharBuf |
add(int i)Appends an int value. |
|
public final CharBuf |
add(boolean b)Appends a boolean value using cached JSON literals. |
|
public final CharBuf |
add(byte i)Appends a byte value. |
|
public final CharBuf |
add(short i)Appends a short value. |
|
public final CharBuf |
add(long l)Appends a long value. |
|
public final CharBuf |
add(double d)Appends a double value. |
|
public final CharBuf |
add(float d)Appends a float value. |
|
public CharBuf |
add(char[] chars)Appends a character array. |
|
public CharBuf |
add(char[] chars, int length)Appends a fixed-length prefix of a character array. |
|
public CharBuf |
add(byte[] chars)Appends a byte array as characters. |
|
public CharBuf |
add(byte[] bytes, int start, int end)Appends a byte subrange as characters. |
|
public final CharBuf |
add(char ch)Appends a single character. |
|
public CharBuf |
addBigDecimal(BigDecimal key)Appends a BigDecimal using cached character data. |
|
public CharBuf |
addBigInteger(BigInteger key)Appends a BigInteger using cached character data. |
|
public final CharBuf |
addBoolean(boolean b)Appends a boolean value. |
|
public final CharBuf |
addByte(byte i)Appends a byte value as a character digit sequence. |
|
public final CharBuf |
addChar(byte i)Appends a byte as a single character. |
|
public final CharBuf |
addChar(int i)Appends an int as a single character. |
|
public final CharBuf |
addChar(short i)Appends a short as a single character. |
|
public final CharBuf |
addChar(char ch)Appends a character. |
|
public final CharBuf |
addChars(char[] chars)Appends a character array using System.arraycopy. |
|
public final CharBuf |
addDouble(double d)Appends a double value using cached character data when available. |
|
public final CharBuf |
addDouble(Double key)Appends a Double using cached character data. |
|
public final CharBuf |
addFloat(float d)Appends a float value using cached character data when available. |
|
public final CharBuf |
addFloat(Float key)Appends a Float using cached character data. |
|
public final CharBuf |
addInt(int i)Appends an int value using cached character data when available. |
|
public final CharBuf |
addInt(Integer key)Appends an Integer using cached character data. |
|
public final CharBuf |
addJsonEscapedString(String jsonString)Appends a quoted JSON string with escaping enabled. |
|
public final CharBuf |
addJsonEscapedString(String jsonString, boolean disableUnicodeEscaping)Appends a quoted JSON string. |
|
public final CharBuf |
addJsonEscapedString(char[] charArray)Appends a quoted JSON string with escaping enabled. |
|
public final CharBuf |
addJsonEscapedString(char[] charArray, boolean disableUnicodeEscaping)Appends a quoted JSON string from a character array. |
|
public final CharBuf |
addJsonFieldName(String str)Appends a quoted JSON field name followed by a colon. |
|
public final CharBuf |
addJsonFieldName(String str, boolean disableUnicodeEscaping)Appends a quoted JSON field name followed by a colon. |
|
public final CharBuf |
addJsonFieldName(char[] chars)Appends a quoted JSON field name followed by a colon. |
|
public final CharBuf |
addJsonFieldName(char[] chars, boolean disableUnicodeEscaping)Appends a quoted JSON field name followed by a colon. |
|
public CharBuf |
addLine(String str)Appends a line followed by a newline character. |
|
public CharBuf |
addLine(CharSequence str)Appends a character sequence followed by a newline character. |
|
public final CharBuf |
addLong(long l)Appends a long value using cached character data when available. |
|
public final CharBuf |
addLong(Long key)Appends a Long using cached character data. |
|
public final void |
addNull()Appends the JSON literal null. |
|
public final CharBuf |
addQuoted(char[] chars)Appends a quoted character array without escaping. |
|
public final CharBuf |
addQuoted(String str)Appends a quoted string without escaping. |
|
public final CharBuf |
addShort(short i)Appends a short value as a character digit sequence. |
|
public final CharBuf |
addString(String str)Appends a string. |
|
public byte |
byteValue()Parses the buffered characters as a byte. |
|
public char |
charAt(int index){@inheritDoc} |
|
public void |
close()No-op for this in-memory buffer. |
|
public static CharBuf |
create(int capacity)Creates a growable buffer with the supplied capacity. |
|
public static CharBuf |
create(char[] buffer)Wraps the supplied character buffer. |
|
public static CharBuf |
createExact(int capacity)Creates a buffer sized exactly for the requested capacity. |
|
public final CharBuf |
decodeJsonString(char[] chars)Decodes a JSON string fragment into this buffer. |
|
public final CharBuf |
decodeJsonString(char[] chars, int start, int to)Decodes a JSON string subrange into this buffer. |
|
public double |
doubleValue()Parses the buffered characters as a double. |
|
public float |
floatValue()Parses the buffered characters as a float. |
|
public void |
flush()No-op for this in-memory buffer. |
|
public void |
init()Allocates the backing array from the current capacity. |
|
public int |
intValue()Parses the buffered characters as an int. |
|
public int |
len()Returns the current buffer length. |
|
public int |
length(){@inheritDoc} |
|
public long |
longValue()Parses the buffered characters as a long. |
|
public char[] |
readForRecycle()Returns the backing array and resets the write position. |
|
public void |
recycle()Resets the write position without clearing the backing array. |
|
public void |
removeLastChar()Removes the last character when the buffer is not empty. |
|
public void |
removeLastChar(char expect)Removes the last character when it matches the expected value. |
|
public short |
shortValue()Parses the buffered characters as a short. |
|
public CharSequence |
subSequence(int start, int end){@inheritDoc} |
|
public char[] |
toCharArray()Returns the backing character array. |
|
public String |
toDebugString()Returns a debug view of the current buffer state. |
|
public Number |
toIntegerWrapper()Parses the buffered characters as either an Integer or Long. |
|
public String |
toString()Returns the buffered characters as a string. |
|
public String |
toStringAndRecycle()Returns the buffered text and resets the write position. |
|
public void |
write(char[] cbuf, int off, int len){@inheritDoc} |
Backing storage for buffered characters.
Current backing-array capacity.
Next write position in buffer.
Wraps an existing character buffer.
Decodes UTF-8 bytes into the backing character buffer.
Creates a growable buffer with the supplied initial capacity.
Creates a growable buffer with the default capacity.
Sets the current logical buffer length.
Appends an int value.
Appends a boolean value using cached JSON literals.
Appends a byte value.
Appends a short value.
Appends a long value.
Appends a double value.
Appends a float value.
Appends a character array.
Appends a fixed-length prefix of a character array.
Appends a byte array as characters.
Appends a byte subrange as characters.
Appends a single character.
Appends a BigDecimal using cached character data.
Appends a BigInteger using cached character data.
Appends a boolean value.
Appends a byte value as a character digit sequence.
Appends a byte as a single character.
Appends an int as a single character.
Appends a short as a single character.
Appends a character.
Appends a character array using System.arraycopy.
Appends a double value using cached character data when available.
Appends a float value using cached character data when available.
Appends an int value using cached character data when available.
Appends a quoted JSON string with escaping enabled.
Appends a quoted JSON string.
Appends a quoted JSON string with escaping enabled.
Appends a quoted JSON string from a character array.
Appends a quoted JSON field name followed by a colon.
Appends a quoted JSON field name followed by a colon.
Appends a quoted JSON field name followed by a colon.
Appends a quoted JSON field name followed by a colon.
Appends a character sequence followed by a newline character.
Appends a long value using cached character data when available.
Appends the JSON literal null.
Appends a quoted character array without escaping.
Appends a short value as a character digit sequence.
Parses the buffered characters as a byte.
{@inheritDoc}
No-op for this in-memory buffer.
Creates a growable buffer with the supplied capacity.
Wraps the supplied character buffer.
Creates a buffer sized exactly for the requested capacity.
Decodes a JSON string fragment into this buffer.
Decodes a JSON string subrange into this buffer.
Parses the buffered characters as a double.
Parses the buffered characters as a float.
No-op for this in-memory buffer.
Allocates the backing array from the current capacity.
Parses the buffered characters as an int.
Returns the current buffer length.
{@inheritDoc}
Parses the buffered characters as a long.
Returns the backing array and resets the write position.
Resets the write position without clearing the backing array.
Removes the last character when the buffer is not empty.
Removes the last character when it matches the expected value.
Parses the buffered characters as a short.
{@inheritDoc}
Returns the backing character array.
Returns a debug view of the current buffer state.
Parses the buffered characters as either an Integer or Long.
Returns the buffered characters as a string.
Returns the buffered text and resets the write position.
{@inheritDoc}
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.