public class CharArray
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) char[] |
buffer |
(package private) int |
size |
(package private) int |
subStrLen |
(package private) int |
subStrStart |
Constructor and Description |
---|
CharArray(int size)
Constructs a CharArray that is initialized to the specified size.
|
Modifier and Type | Method and Description |
---|---|
CharArray |
append(char c)
Appends a single character to the end of the character array.
|
CharArray |
append(char[] chars)
Appends the supplied characters to the end of the array.
|
CharArray |
append(char[] chars,
int position,
int length) |
CharArray |
append(CharArray chars)
Appends an existing CharArray on to this one.
|
CharArray |
append(java.lang.String str)
Appends the supplied string to the end of this character array.
|
char |
charAt(int pos)
Returns the character that is at the specified position in the array.
|
void |
clear()
Clear the contents.
|
boolean |
compareLower(java.lang.String lowerStr,
int offset)
Compares the supplied uppercase string with the contents of
the character array, starting at the offset specified.
|
boolean |
compareLowerSubstr(java.lang.String lowerStr)
This compares a substring of this character array (as specified
by the
setSubstr(int, int) method call) with the supplied
string. |
java.lang.String |
getLowerSubstr()
Returns the substring that was specified by the
setSubstr(int, int) call. |
private void |
grow(int minSize)
Grows the internal array by either ~100% or minSize (whichever is larger),
up to a maximum size of Integer.MAX_VALUE.
|
int |
length()
Returns the current length of the character array.
|
void |
setLength(int newSize)
Changes the size of the character array to the value specified.
|
void |
setSubstr(int begin,
int end)
Allows an arbitrary substring of this character array to be specified.
|
int |
substrHashCode()
Returns the hashcode for a lowercase version of the array's substring
(as set by the
setSubstr(int, int) method). |
java.lang.String |
substring(int begin,
int end)
Returns a substring from within this character array.
|
java.lang.String |
toString()
Returns a String represenation of the character array.
|
void |
writeTo(java.io.PrintWriter writer) |
public CharArray(int size)
public java.lang.String toString()
toString
in class java.lang.Object
public char charAt(int pos)
public void setLength(int newSize)
newSize
- the new size of the character arraypublic int length()
public CharArray append(CharArray chars)
public CharArray append(char[] chars)
public CharArray append(char[] chars, int position, int length)
public CharArray append(char c)
public CharArray append(java.lang.String str)
public java.lang.String substring(int begin, int end)
public void setSubstr(int begin, int end)
compareLowerSubstr(String)
to set the range of the substring comparison.begin
- the starting offset into the character array.end
- the ending offset into the character array.public java.lang.String getLowerSubstr()
setSubstr(int, int)
call.public boolean compareLowerSubstr(java.lang.String lowerStr)
setSubstr(int, int)
method call) with the supplied
string. The supplied string must be lowercase, otherwise
the comparison will fail.public int substrHashCode()
setSubstr(int, int)
method).
This uses the same calculation as the String.hashCode() method
so that it remains compatible with the hashcodes of normal strings.public boolean compareLower(java.lang.String lowerStr, int offset)
private final void grow(int minSize)
public final void clear()
public void writeTo(java.io.PrintWriter writer)