|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectCharArray
public final class CharArray
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:
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 (empty character array). |
|
CharArray(int capacity)
Creates a character array of specified default capacity. |
|
CharArray(String string)
Creates a character array from the specified String. |
Method Summary | |
---|---|
char[] |
array()
Returns the underlying array. |
char |
charAt(int index)
|
int |
compareTo(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(Object that)
Compares this character sequence against the specified object ( String or CharSequence ). |
boolean |
equals(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(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. |
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. |
String |
toString()
Returns the String |
Methods inherited from class Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CharArray()
public CharArray(int capacity)
capacity
- the backing array default capacity.public CharArray(String string)
string
- the string source.Method Detail |
---|
public char[] array()
public int length()
length
in interface 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 final int indexOf(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 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 CharSequence
- Overrides:
toString
in class 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 Object
public boolean equals(Object that)
String
or CharSequence
).
equals
in class 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(String str)
str
- the string to compare with.
true
if both objects represent the same sequence;
false
otherwise.public int compareTo(Object seq)
compareTo
in interface Comparable
seq
- the character sequence to be compared.
FastComparator.LEXICAL
.compare(this, seq)
ClassCastException
- if the specifed object is not a
CharSequence
.public boolean toBoolean()
boolean
represented by this character array.
boolean
value.
NumberFormatException
- if this character sequence
does not contain a parsable boolean
.public int toInt()
int
represented by this character array.
toInt(10)
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.
NumberFormatException
- if this character sequence
does not contain a parsable int
.public long toLong()
long
represented by this character
array.
long
value.
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.
NumberFormatException
- if this character sequence
does not contain a parsable long
.public float toFloat()
float
represented by this character array.
float
value.
NumberFormatException
- if this character sequence
does not contain a parsable float
.public double toDouble()
double
represented by this character array.
double
value.
NumberFormatException
- if this character sequence
does not contain a parsable double
.public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public void getChars(int start, int end, char[] dest, int destPos)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |