public final class CharArray
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Comparable
This class represents a CharSequence
backed up by a char array. Instances of this class are
typically used/reused to provide CharSequence views
over existing character buffers.
Instances of this classes have the following properties:
| Constructor and Description |
|---|
CharArray()
Default constructor (empty character array).
|
CharArray(int capacity)
Creates a character array of specified default capacity.
|
CharArray(java.lang.String string)
Creates a character array from the specified String.
|
| Modifier and Type | Method and Description |
|---|---|
char[] |
array()
Returns the underlying array.
|
char |
charAt(int index) |
int |
compareTo(java.lang.Object seq)
Compares this character array with the specified character
sequence lexicographically.
|
boolean |
equals(CharArray that)
Compares this character array against the specified
CharArray. |
boolean |
equals(java.lang.Object that)
Compares this character sequence against the specified object
(
String or CharSequence). |
boolean |
equals(java.lang.String str)
Compares this character array against the specified String.
|
void |
getChars(int start,
int end,
char[] dest,
int destPos) |
int |
hashCode()
Returns the hash code for this
CharArray. |
int |
indexOf(char c)
Returns the index within this character sequence of the first occurrence
of the specified character searching forward.
|
int |
indexOf(java.lang.CharSequence csq)
Returns the index within this character sequence of the first occurrence
of the specified characters sequence searching forward.
|
int |
length()
Returns the length of this character sequence.
|
int |
offset()
Returns the offset of the first character in the underlying array.
|
CharArray |
setArray(char[] array,
int offset,
int length)
Sets the underlying array of this CharArray.
|
java.lang.CharSequence |
subSequence(int start,
int end) |
boolean |
toBoolean()
Returns the
boolean represented by this character array. |
double |
toDouble()
Returns the
double represented by this character array. |
float |
toFloat()
Returns the
float represented by this character array. |
int |
toInt()
Returns the decimal
int represented by this character array. |
int |
toInt(int radix)
Returns the
int represented by this character array
in the specified radix. |
long |
toLong()
Returns the decimal
long represented by this character
array. |
long |
toLong(int radix)
Returns the decimal
long represented by this character
array in the specified radix. |
java.lang.String |
toString()
Returns the
String |
public CharArray()
public CharArray(int capacity)
capacity - the backing array default capacity.public CharArray(java.lang.String string)
string - the string source.public char[] array()
public int length()
length in interface java.lang.CharSequencepublic int offset()
public CharArray setArray(char[] array, int offset, int length)
offset - the new offset.array - the new underlying array.length - the new length.thispublic final int indexOf(java.lang.CharSequence csq)
csq - a character sequence searched for.[0, length()[
or -1 if the character sequence is not found.public final int indexOf(char c)
c - the character to search for.[0, length()[
or -1 if the character is not found.public java.lang.String toString()
String corresponding to this character
sequence. The String returned is always allocated on the
heap and can safely be referenced elsewhere.toString in interface java.lang.CharSequencetoString in class java.lang.Objectjava.lang.String for this character sequence.public int hashCode()
CharArray.
Note: Returns the same hashCode as java.lang.String
(consistent with equals(java.lang.Object))
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object that)
String or CharSequence).equals in class java.lang.Objectthat - the object to compare with.true if both objects represent the same sequence;
false otherwise.public boolean equals(CharArray that)
CharArray.that - the character array to compare with.true if both objects represent the same sequence;
false otherwise.public boolean equals(java.lang.String str)
str - the string to compare with.true if both objects represent the same sequence;
false otherwise.public int compareTo(java.lang.Object seq)
compareTo in interface java.lang.Comparableseq - the character sequence to be compared.FastComparator.LEXICAL.compare(this, seq)java.lang.ClassCastException - if the specifed object is not a
CharSequence.public boolean toBoolean()
boolean represented by this character array.boolean value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable boolean.public int toInt()
int represented by this character array.toInt(10)java.lang.NumberFormatException - if this character sequence
does not contain a parsable int.public int toInt(int radix)
int represented by this character array
in the specified radix.radix - the radix (e.g. 16 for hexadecimal).int value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable int.public long toLong()
long represented by this character
array.long value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable long.public long toLong(int radix)
long represented by this character
array in the specified radix.radix - the radix (e.g. 16 for hexadecimal).long value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable long.public float toFloat()
float represented by this character array.float value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable float.public double toDouble()
double represented by this character array.double value.java.lang.NumberFormatException - if this character sequence
does not contain a parsable double.public char charAt(int index)
charAt in interface java.lang.CharSequencepublic java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequencepublic void getChars(int start,
int end,
char[] dest,
int destPos)
Copyright © 2005 - 2007 Javolution.