This class provides a more flexible and powerful API than StringBuffer and StringBuilder, the main differences
being:
| Modifier and Type | Class and Description |
|---|---|
| pack-priv class | |
| pack-priv class |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final char[] | |
| private static final int | |
| private static final int | |
| public char[] | |
| private static final int | MAX_BUFFER_SIZE
The maximum buffer size to allocate. |
| private static final String | |
| public boolean | |
| public int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | CharArray(boolean
If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy. ordered, int Any elements added beyond this will cause the backing array to be grown. capacity)
|
| public | |
| public | |
| public | CharArray(boolean
If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy. ordered, char[] array, int start, int count)Creates a new array containing the elements in the specified array. |
| public | CharArray(CharSequence seq)
Constructs an instance from a character sequence, allocating 16 extra characters for growth. |
| public | |
| public | CharArray(StringBuilder str)
Constructs an instance from a string builder, allocating 16 extra characters for growth. |
| private | CharArray(char[] initialBuffer, int length)
Constructs an instance that uses the specified array directly, until reallocation is needed. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | append(char[] ch, int
the start index, inclusive start, int length)Appends a char array to this CharArray. |
| public CharArray | |
| public CharArray | append(CharBuffer buf, int
the start index, inclusive start, int the end index, exclusive end)Appends the contents of a char buffer to this CharArray. |
| public CharArray | append(CharSequence seq)
Implements java. Appends a CharSequence to this CharArray. |
| public CharArray | append(CharSequence seq, int
the start index, inclusive start, int the end index, exclusive end)Implements java. Appends part of a CharSequence to this CharArray. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | append(int value, int
the minimum number of characters to add minLength)Appends the string representation of the specified |
| public CharArray | append(int value, final int
the minimum number of characters to add minLength, final char the character to use as prefix prefix)Appends the string representation of the specified |
| public CharArray | |
| public CharArray | append(long value, int
the minimum number of characters to add minLength)Appends the string representation of the specified |
| public CharArray | append(long value, int
the minimum number of characters to add minLength, char the character to use as prefix prefix)Appends the string representation of the specified |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | append(StringBuffer str, int
the start index, inclusive start, int the end index, exclusive end)Appends part of a string buffer to this CharArray. |
| public CharArray | |
| public CharArray | append(StringBuilder str, int
the start index, inclusive start, int the end index, exclusive end)Appends part of a StringBuilder to this CharArray. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public final <T> CharArray | |
| public CharArray | |
| private void | |
| public CharArray | appendFixedWidthPadLeft(int value, int
the fixed field width, zero or negative has no effect width, char padChar)Appends an object to this CharArray padding on the left to a fixed width. |
| public CharArray | appendFixedWidthPadLeft(Object
the object to append, null uses "" obj, int the fixed field width, zero or negative has no effect width, char padChar)Appends an object to this CharArray padding on the left to a fixed width. |
| public CharArray | appendFixedWidthPadRight(int value, int
the fixed field width, zero or negative has no effect width, char padChar)Appends an object to this CharArray padding on the right to a fixed length. |
| public CharArray | appendFixedWidthPadRight(Object
the object to append, null uses obj, int "null"the fixed field width, zero or negative has no effect width, char padChar)Appends an object to this CharArray padding on the right to a fixed length. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | appendln(char[] ch, int
the start index, inclusive start, int length)Appends a char array followed by a new line to this CharArray. |
| public CharArray | appendln(double value)
Appends a double value followed by a new line to this CharArray using |
| public CharArray | appendln(float value)
Appends a float value followed by a new line to this CharArray using |
| public CharArray | appendln(int value)
Appends an int value followed by a new line to this CharArray using |
| public CharArray | appendln(long value)
Appends a long value followed by a new line to this CharArray using |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | appendln(StringBuffer str, int
the start index, inclusive start, int the end index, exclusive end)Appends part of a string buffer followed by a new line to this CharArray. |
| public CharArray | |
| public CharArray | appendln(StringBuilder str, int
the start index, inclusive start, int the end index, exclusive end)Appends part of a string builder followed by a new line to this CharArray. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | appendPadding(int
negative means no append padCount, char padChar)Appends the pad character to this CharArray the specified number of times. |
| public CharArray | |
| public CharArray | appendSeparator(char
the separator if this CharArray is not empty standard, char the separator if this CharArray is empty defaultIfEmpty)Appends one of both separators to this CharArray If this CharArray is currently empty it will append the
defaultIfEmpty-separator Otherwise it will append the standard-separator The separator is appended using
|
| public CharArray | appendSeparator(char separator, int loopIndex)
Appends a separator to this CharArray if the loop index is greater than zero. |
| public CharArray | appendSeparator(String
the separator to use, null means no separator separator)Appends a separator if this CharArray is currently non-empty. |
| public CharArray | appendSeparator(String
the separator to use, null means no separator separator, int loopIndex)Appends a separator to this CharArray if the loop index is greater than zero. |
| public CharArray | appendSeparator(String
the separator if this CharArray is not empty, null means no separator standard, String the separator if this CharArray is empty, null means no separator defaultIfEmpty)Appends one of both separators to this CharArray. |
| public void | appendTo(Appendable appendable)
Appends current contents of this |
| private void | |
| public CharArray | appendWithSeparators(Iterable<?> iterable, String
the separator to use, null means no separator separator)Appends an iterable placing separators between each value, but not before the first or after the last. |
| public CharArray | appendWithSeparators(Iterator<?> it, String
the separator to use, null means no separator separator)Appends an iterator placing separators between each value, but not before the first or after the last. |
| public CharArray | appendWithSeparators(Object[] array, String
the separator to use, null means no separator separator)Appends an array placing separators between each value, but not before the first or after the last. |
| public int | |
| public char | Returns: The character at the indexImplements java. Gets the character at the specified index. |
| public void | |
| public int | Returns: the Unicode code point value.the index to the index)char code unit.Retrieves the Unicode code point value at the |
| public int | Returns: the Unicode code point value.the index to the index)char code unit within this object.Retrieves the Unicode code point value that precedes the |
| public int | Returns: the number of Unicode code points in the subsequence.the inclusive beginning index of the subsequence. begin, int the exclusive end index of the subsequence. end)Calculates the number of Unicode code points between |
| public boolean | |
| public boolean | |
| public boolean | |
| public CharArray | delete(int
the start index, inclusive start, int the end index, exclusive end)Deletes the characters between the two specified indices. |
| private void | delete(int
the start index start, int the end index (exclusive) end, int the length length)Internal method to delete a range without validation. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public char | Returns: The character at the indexGets the character at the specified index before deleting it. |
| public int | Returns: How many characters were copied (then deleted). If this CharArray is empty, return0.first index to copy, inclusive. start, int last index to copy, exclusive. end, char[] the target array. target, int the index to start copying in the target. targetIndex)Drains (copies, then deletes) this character sequence into the specified array. |
| public boolean | |
| public char[] | Returns: itemsIncreases the size of the backing array to accommodate at least the specified number of additional items. |
| public boolean | Returns: true if the CharArrays contain the same characters in the same orderthe object to check, null returns false object)Overrides java. Tests the contents of this CharArray against another to see if they contain the same character content. |
| public boolean | |
| public boolean | Returns: true if the CharArrays contain the same characters in the same orderthe object to check, null returns false other)Tests the contents of this CharArray against another to see if they contain the same character content ignoring case. |
| public boolean | |
| public boolean | |
| public char | |
| public char | |
| public char[] | Returns: The input array, unless that was null or too smallthe target array, null will cause an array to be created target)Copies this character array into the specified array. |
| public void | getChars(int
first index to copy, inclusive. start, int last index to copy, exclusive. end, char[] the target array, must not too small. target, int the index to start copying in target. targetIndex)Overrides default java. Copies this character array into the specified array. |
| public int | |
| public void | |
| public void | |
| public int | |
| public int | Returns: The first index of the character, or -1 if not foundthe index to start at, invalid index rounded to edge start)Searches this CharArray to find the first reference to the specified char. |
| public int | |
| public int | |
| public int | |
| public CharArray | |
| public void | |
| public CharArray | |
| public CharArray | insert(int index, char[] ch, int
the offset into the character array to start at offset, int the length of the character array part to copy length)Inserts part of the character array into this CharArray. |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public CharArray | |
| public void | |
| public boolean | |
| public int | |
| public int | Returns: The last index of the character, or -1 if not foundthe index to start at, invalid index rounded to edge start)Searches this CharArray to find the last reference to the specified char. |
| public int | Returns: The last index of the string, or -1 if not foundSearches this CharArray to find the last reference to the specified string. |
| public int | Returns: The last index of the string, or -1 if not foundthe index to start at, invalid index rounded to edge start)Searches this CharArray to find the last reference to the specified string starting searching from the given index. |
| public String | Returns: The new stringthe number of characters to extract, negative returns empty string length)Extracts the leftmost characters from this CharArray without throwing an exception. |
| public int | Returns: The lengthImplements java. Gets the length of this CharArray. |
| public String | Returns: The new stringthe index to start at, negative means zero index, int the number of characters to extract, negative returns empty string length)Extracts some characters from the middle of this CharArray without throwing an exception. |
| public void | |
| public void | |
| public boolean | |
| public static int | numChars(int value, int radix)
Returns: the number of characters required to represent the value with the specified radix |
| public static int | numChars(long value, int radix)
Returns: the number of characters required to represent the value with the specified radix |
| public int | Returns: the index that iscodePointOffset code points away from index.the index to calculate the offset from. index, int the number of code points to count. codePointOffset)Returns the index that is offset |
| public char | |
| public char | |
| public char | |
| public Reader | Returns: a reader that reads from this CharArrayGets the contents of this CharArray as a Reader. |
| public int | Returns: The number of characters read.If possible, reads chars from the provided |
| public int | |
| public int | |
| public int | Returns: The number of characters read. If less thancount, then we've reached the end-of-stream, or -1 if we reached
the end of stream.The maximum characters to read, a value <= 0 returns 0. count)If possible, reads |
| public boolean | |
| public char | |
| public void | |
| public boolean | |
| public CharArray | |
| public CharArray | |
| private void | |
| public int | Returns: the number of replacements donethe char to be replaced value, char all occurrences of value will be replaced by this replacement replacement)Returns the number of replacements done. |
| public CharArray | replaceAll(String searchStr, String replaceStr)
Replaces the search string with the replace string throughout this CharArray. |
| public boolean | Returns: if value was found and replacedthe char to be replaced value, char the first value will be replaced by this replacement if found replacement)Returns true if the specified value was replaced successfully with the replacement |
| public CharArray | replaceFirst(String searchStr, String
the replace string, null is equivalent to an empty string replaceStr)Replaces the first instance of the search string with the replace string. |
| private void | |
| protected char[] | |
| private void | |
| public void | |
| public CharArray | |
| public String | Returns: The new stringthe number of characters to extract, negative returns empty string length)Extracts the rightmost characters from this CharArray without throwing an exception. |
| public void | |
| public CharArray | |
| public CharArray | |
| public CharArray | setLength(int
the length to set to, must be zero or positive length)Updates the length of this CharArray by either dropping the last characters or adding filler of Unicode zero. |
| public char[] | |
| public char[] | |
| public void | |
| public void | |
| public boolean | Returns: true if this CharArray starts with the stringthe string to search for, null returns false str)Checks whether this CharArray starts with the specified string. |
| public CharSequence | subSequence(int start, int end)
Implements java. Returns a |
| public String | Returns: The new stringthe start index, inclusive start)Extracts a portion of this CharArray as a string. |
| public String | Returns: The new stringthe start index, inclusive start, int the end index, exclusive end)Extracts a portion of this CharArray as a string. |
| public void | |
| public char[] | |
| public char[] | Returns: a new array that represents the contents of this CharArrayCopies this CharArray's character array into a new character array. |
| public char[] | Returns: a new array that holds part of the contents of this CharArraythe start index, inclusive start, int the end index, exclusive end)Copies part of this CharArray's character array into a new character array. |
| public String | toString()
Overrides java. Implements java. Returns a String version of this CharArray, creating a new instance each time the method is called. |
| public String | |
| public String | Returns: a String containing the characters in this instance.Returns the current String representation and clears this CharArray. |
| public CharArray | trim()
Trims this CharArray by removing characters less than or equal to a space from the beginning and end. |
| public void | |
| public void | |
| protected void | |
| protected int | Returns: A valid end index.the start index, inclusive start, int the end index, exclusive end)Validates parameters defining a range of this CharArray. |
| public static CharArray | |
| public static CharArray | Returns: A new instance.The initial array that will back the new CharArray. initialBuffer)Constructs an instance from a reference to a character array. |
| public static CharArray | Returns: A new instance.The initial array that will back the new CharArray. initialBuffer, int The length of the subarray to be used; must be non-negative and no larger than length)initialBuffer.length.
The new CharArray's size will be set to length.Constructs an instance from a reference to a character array. |
| public Writer | Returns: a writer that populates this CharArrayGets this CharArray as a Writer that can be written to. |