public class CharBuffer
extends java.lang.Object
High performance char buffer.
Constructor and Description |
---|
CharBuffer()
See CharBuffer(int).
|
CharBuffer(int capacity)
Construct a new buffer with a
CharBuffer.length of zero and specified initial capacity . |
Modifier and Type | Method and Description |
---|---|
void |
add(char value)
Add a character value to the end of this buffer.
|
void |
append(java.lang.String text)
Append a string value to the end of this buffer.
|
void |
clear()
Set
CharBuffer.length to zero. |
char |
get(int index)
Return the character of this buffer at
index . |
int |
getLength()
Length of the buffer (the number of characters that will appear in
this.toString() . |
java.lang.String |
getRange(int start,
int end)
Return a range of characters from this buffer.
|
char[] |
internalArray() |
static java.lang.String |
join2(java.lang.String text1,
java.lang.String text2)
Return the concatenation of 2 string values, using
append . |
static java.lang.String |
join3(java.lang.String text1,
java.lang.String text2,
java.lang.String text3)
Return the concatenation of 3 string values, using
append . |
static java.lang.String |
join4(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4)
Return the concatenation of 4 string values, using
append . |
static java.lang.String |
join5(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4,
java.lang.String text5)
Return the concatenation of 5 string values, using
append . |
static java.lang.String |
join6(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4,
java.lang.String text5,
java.lang.String text6)
Return the concatenation of 6 string values, using
append . |
static java.lang.String |
join7(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4,
java.lang.String text5,
java.lang.String text6,
java.lang.String text7)
Return the concatenation of 7 string values, using
append . |
static java.lang.String |
join8(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4,
java.lang.String text5,
java.lang.String text6,
java.lang.String text7,
java.lang.String text8)
Return the concatenation of 8 string values, using
append . |
static java.lang.String |
join9(java.lang.String text1,
java.lang.String text2,
java.lang.String text3,
java.lang.String text4,
java.lang.String text5,
java.lang.String text6,
java.lang.String text7,
java.lang.String text8,
java.lang.String text9)
Return the concatenation of 9 string values, using
append . |
void |
reverse()
Reverse the characters of this buffer.
|
void |
set(int index,
char value)
Set the character of this buffer at
index . |
void |
setLength(int value)
Length of the buffer (the number of characters that will appear in
this.toString() . |
void |
setRange(int index,
java.lang.String value)
Copy a range of characters from a string value into this buffer, starting at
index . |
java.lang.String |
toString()
Return a string value with the
CharBuffer.length characters of this buffer. |
static CharBuffer |
withArray(char[] chars) |
static CharBuffer |
withArray(char[] chars,
int length) |
public CharBuffer()
public CharBuffer(int capacity)
Construct a new buffer with a CharBuffer.length
of zero and specified initial capacity
.
A buffer can expand in length beyond its initial capacity, but best performance
will be obtained if the initial capacity is close to the buffer's maximum length.
capacity
- Initial capacity. Defaults to 16.public static CharBuffer withArray(char[] chars)
public static CharBuffer withArray(char[] chars, int length)
public char[] internalArray()
public void add(char value)
Add a character value to the end of this buffer.
value
- Character value to be added.public void append(java.lang.String text)
Append a string value to the end of this buffer.
text
- (nullable) String value. If null
, then "null" is appended to the buffer.public void clear()
Set CharBuffer.length
to zero.
public char get(int index)
Return the character of this buffer at index
.
An exception if index
is out of range 0 .. this.length - 1
.
index
- Zero-based index.public int getLength()
Length of the buffer (the number of characters that will appear in this.toString()
.
public java.lang.String getRange(int start, int end)
Return a range of characters from this buffer.
An exception if start
or end
is out of range 0 .. this.length
.
start
- Zero-based starting index (inclusive).end
- Zero-based ending index (exclusive).public static java.lang.String join2(java.lang.String text1, java.lang.String text2)
Return the concatenation of 2 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.append
.public static java.lang.String join3(java.lang.String text1, java.lang.String text2, java.lang.String text3)
Return the concatenation of 3 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.append
.public static java.lang.String join4(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4)
Return the concatenation of 4 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.append
.public static java.lang.String join5(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4, java.lang.String text5)
Return the concatenation of 5 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.text5
- (nullable) Fifth string value.append
.public static java.lang.String join6(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4, java.lang.String text5, java.lang.String text6)
Return the concatenation of 6 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.text5
- (nullable) Fifth string value.text6
- (nullable) Sixth string value.append
.public static java.lang.String join7(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4, java.lang.String text5, java.lang.String text6, java.lang.String text7)
Return the concatenation of 7 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.text5
- (nullable) Fifth string value.text6
- (nullable) Sixth string value.text7
- (nullable) Seventh string value.append
.public static java.lang.String join8(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4, java.lang.String text5, java.lang.String text6, java.lang.String text7, java.lang.String text8)
Return the concatenation of 8 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.text5
- (nullable) Fifth string value.text6
- (nullable) Sixth string value.text7
- (nullable) Seventh string value.text8
- (nullable) Eighth string value.append
.public static java.lang.String join9(java.lang.String text1, java.lang.String text2, java.lang.String text3, java.lang.String text4, java.lang.String text5, java.lang.String text6, java.lang.String text7, java.lang.String text8, java.lang.String text9)
Return the concatenation of 9 string values, using append
.
text1
- (nullable) First string value.text2
- (nullable) Second string value.text3
- (nullable) Third string value.text4
- (nullable) Fourth string value.text5
- (nullable) Fifth string value.text6
- (nullable) Sixth string value.text7
- (nullable) Seventh string value.text8
- (nullable) Eighth string value.text9
- (nullable) Ninth string value.append
.public void reverse()
Reverse the characters of this buffer.
public void set(int index, char value)
Set the character of this buffer at index
.
An exception if index
is out of range 0 .. this.length - 1
.
index
- Zero-based index.value
- Byte value.public void setLength(int value)
Length of the buffer (the number of characters that will appear in this.toString()
.
public void setRange(int index, java.lang.String value)
Copy a range of characters from a string value into this buffer, starting at index
.
An exception if index
is out of range 0 .. this.length - 1
or index + value.length
is out of range 0 .. this.length
.
index
- Zero-based starting index.value
- String value.public java.lang.String toString()
Return a string value with the CharBuffer.length
characters of this buffer.
toString
in class java.lang.Object
CharBuffer.length
characters of this buffer.