|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.saxon.tinytree.CharSlice
This is an implementation of the JDK 1.4 CharSequence interface: it implements a CharSequence as a view of an array. The implementation relies on the array being immutable: as a minimum, the caller is required to ensure that the array contents will not change so long as the CharSlice remains in existence. This class should be more efficient than String because it avoids copying the characters unnecessarily. The methods in the class don't check their arguments. Incorrect arguments will generally result in exceptions from lower-level classes. Instances of this class are currently generated by the version of AElfred included in the schema-aware version of Saxon, and are handled specially by the tinytree builder, to avoid multiple copies of the character string.
Constructor Summary | |
CharSlice(char[] array,
int start,
int length)
|
Method Summary | |
char |
charAt(int index)
Returns the character at the specified index. |
void |
copyTo(char[] destination,
int destOffset)
Append the contents to another array at a given offset. |
boolean |
equals(java.lang.Object other)
Compare equality |
int |
hashCode()
Generate a hash code |
int |
indexOf(char c)
Get the index of a specific character in the sequence. |
int |
length()
Returns the length of this character sequence. |
java.lang.CharSequence |
subSequence(int start,
int end)
Returns a new character sequence that is a subsequence of this sequence. |
java.lang.String |
substring(int start,
int end)
Returns a new character sequence that is a subsequence of this sequence. |
java.lang.String |
toString()
Convert to a string |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public CharSlice(char[] array, int start, int length)
Method Detail |
public int length()
length
in interface java.lang.CharSequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
index
- the index of the character to be returned
java.lang.IndexOutOfBoundsException
- if the index argument is negative or not less than
length()public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
start
- the start index, inclusiveend
- the end index, exclusive
java.lang.IndexOutOfBoundsException
- if start or end are negative,
if end is greater than length(),
or if start is greater than endpublic java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int indexOf(char c)
String.indexOf(int)
c
- the character to be found
public java.lang.String substring(int start, int end)
public void copyTo(char[] destination, int destOffset)
destination
- the array to which the characters will be copieddestOffset
- the offset in the target array where the copy will start
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |