| java.lang.Object net.sf.saxon.tinytree.CharSlice
CharSlice | final public class CharSlice implements CharSequence,Serializable(Code) | | 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.
|
Constructor Summary | |
public | CharSlice(char[] array) | public | CharSlice(char[] array, int start, int length) |
Method Summary | |
public char | charAt(int index) Returns the character at the specified index. | public void | copyTo(char[] destination, int destOffset) Append the contents to another array at a given offset. | public boolean | equals(Object other) | public int | hashCode() | public int | indexOf(char c) Get the index of a specific character in the sequence. | public int | length() Returns the length of this character sequence. | public void | setLength(int length) | public CharSequence | subSequence(int start, int end) Returns a new character sequence that is a subsequence of this sequence.
The subsequence starts with the character at the specified index and
ends with the character at index end - 1. | public String | substring(int start, int end) Returns a new character sequence that is a subsequence of this sequence. | public String | toString() | public void | write(Writer writer) |
CharSlice | public CharSlice(char[] array)(Code) | | |
CharSlice | public CharSlice(char[] array, int start, int length)(Code) | | |
charAt | public char charAt(int index)(Code) | | Returns the character at the specified index. An index ranges from zero
to length() - 1. The first character of the sequence is at
index zero, the next at index one, and so on, as for array
indexing.
Parameters: index - the index of the character to be returned the specified character throws: java.lang.IndexOutOfBoundsException - if the index argument is negative or not less thanlength() |
copyTo | public void copyTo(char[] destination, int destOffset)(Code) | | Append the contents to another array at a given offset. The caller is responsible
for ensuring that sufficient space is available.
Parameters: destination - the array to which the characters will be copied Parameters: destOffset - the offset in the target array where the copy will start |
equals | public boolean equals(Object other)(Code) | | Compare equality
|
hashCode | public int hashCode()(Code) | | Generate a hash code
|
indexOf | public int indexOf(char c)(Code) | | Get the index of a specific character in the sequence. Returns -1 if not found.
This method mimics
String.indexOf Parameters: c - the character to be found the position of the first occurrence of that character, or -1 if not found. |
length | public int length()(Code) | | Returns the length of this character sequence. The length is the number
of 16-bit Unicode characters in the sequence.
the number of characters in this sequence |
setLength | public void setLength(int length)(Code) | | Set the length of this character sequence, without changing the array and start offset
to which it is bound
|
subSequence | public CharSequence subSequence(int start, int end)(Code) | | Returns a new character sequence that is a subsequence of this sequence.
The subsequence starts with the character at the specified index and
ends with the character at index end - 1. The length of the
returned sequence is end - start, so if start == end
then an empty sequence is returned.
Parameters: start - the start index, inclusive Parameters: end - the end index, exclusive the specified subsequence throws: java.lang.IndexOutOfBoundsException - if start or end are negative,if end is greater than length(),or if start is greater than end |
substring | public String substring(int start, int end)(Code) | | Returns a new character sequence that is a subsequence of this sequence.
Unlike subSequence, this is guaranteed to return a String.
|
|
|