public final class CharArray extends Object implements CharSequence, Comparable<CharSequence>
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(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(CharSequence 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 |
public CharArray()
public CharArray(int capacity)
capacity - the backing array default capacity.public CharArray(String string)
string - the string source.public char[] array()
public int length()
length in interface 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(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.toString in interface CharSequencetoString in class 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))
public boolean equals(Object that)
String or CharSequence).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(CharSequence seq)
compareTo in interface Comparable<CharSequence>seq - the character sequence to be compared.Equalities.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 CharSequencepublic CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic void getChars(int start,
int end,
char[] dest,
int destPos)
Copyright © 2005-2013 Javolution. All Rights Reserved.