|
J avolution v5.2 (J2SE 1.5+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavolution.text.CharArray
public final class CharArray
This class represents a character sequence backed up by a
char
array. Instances of this class are mutable and
are typically used/reused to hold temporary text (unlike
String
they do not forces object creation).
Instances of this classes have the following properties:
CharSequence
(e.g. String
).String
and can be
used to retrieve data from maps for which the keys are
String
instances.Boolean
, int
).
Constructor Summary | |
---|---|
CharArray()
Default constructor. |
|
CharArray(java.lang.CharSequence csq)
Creates a character array from the specified character sequence. |
|
CharArray(java.lang.String string)
Creates a character array from the specified String. |
Method Summary | |
---|---|
char[] |
array()
Returns the underlying array (read-only). |
char |
charAt(int index)
Returns the character at the specified 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. |
int |
hashCode()
Returns the hash code for this CharArray . |
int |
length()
Returns the length of this character sequence. |
int |
offset()
Returns the offset of the first character in the underlying array. |
int |
offsetOf(char c)
Returns the offset within this character array of the first occurrence of the specified character searching forward from this character array offset() to offset() + length() . |
int |
offsetOf(java.lang.CharSequence csq)
Returns the offset within this character array of the first occurrence of the specified characters sequence searching forward from this character array offset() to offset() + length() . |
CharArray |
setArray(char[] array,
int offset,
int length)
Sets the underlying array of this CharArray. |
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a new character sequence that is a subsequence of this sequence. |
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 |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CharArray()
public CharArray(java.lang.String string)
string
- the string source.public CharArray(java.lang.CharSequence csq)
csq
- the character sequence source.Method Detail |
---|
public char[] array()
public int length()
length
in interface java.lang.CharSequence
public int offset()
public CharArray setArray(char[] array, int offset, int length)
offset
- the new offset.array
- the new underlying array.length
- the new length.
this
public char charAt(int index)
charAt
in interface java.lang.CharSequence
index
- the index of the character starting at 0
.
java.lang.IndexOutOfBoundsException
- if ((index < 0) ||
(index >= length))
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
start
- the index of the first character inclusive.end
- the index of the last character exclusive.
start
position and ending just before the specified
end
position.
java.lang.IndexOutOfBoundsException
- if (start < 0) || (end < 0) ||
(start > end) || (end > this.length())
public final int offsetOf(java.lang.CharSequence csq)
offset()
to offset() + length()
.
csq
- a character sequence searched for.
[offset(), offset() + length()[
or -1
if the character sequence is not found.public final int offsetOf(char c)
offset()
to offset() + length()
.
c
- the character to search for.
[offset(), offset() + 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.
- Specified by:
toString
in interface java.lang.CharSequence
- Overrides:
toString
in class java.lang.Object
- Returns:
- the
java.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.Object
public boolean equals(java.lang.Object that)
String
or CharSequence
).
equals
in class java.lang.Object
that
- 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.Comparable
seq
- 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
.
/
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |