public class CharBufferCharSequence extends java.lang.Object implements PointedCharSequence
| Constructor and Description |
|---|
CharBufferCharSequence(java.nio.CharBuffer cb) |
CharBufferCharSequence(java.nio.CharBuffer cb,
long position) |
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index) |
int |
compareTo(java.lang.String anotherString)
Compares the sequence and the string lexicographically.
|
long |
getLastBytePosition()
Position of the last byte of this sequence in the file (exclusive).
|
int |
indexOf(java.lang.String str)
Returns the index within this sequence of the first occurrence of the specified substring.
|
int |
length() |
java.lang.CharSequence |
subSequence(int start,
int end) |
java.lang.String |
toString() |
public CharBufferCharSequence(java.nio.CharBuffer cb)
public CharBufferCharSequence(java.nio.CharBuffer cb,
long position)
public int length()
length in interface java.lang.CharSequencepublic char charAt(int index)
charAt in interface java.lang.CharSequencepublic java.lang.CharSequence subSequence(int start,
int end)
subSequence in interface java.lang.CharSequencepublic long getLastBytePosition()
PointedCharSequencegetLastBytePosition in interface PointedCharSequencepublic java.lang.String toString()
toString in interface java.lang.CharSequencetoString in class java.lang.Objectpublic int indexOf(java.lang.String str)
PointedCharSequenceThe returned index is the smallest value k for which:
If no such value of k exists, thenthis.startsWith(str, k)
-1 is returned.indexOf in interface PointedCharSequencestr - the substring to search for.-1 if there is no such occurrence.public int compareTo(java.lang.String anotherString)
PointedCharSequencecompareTo returns 0 exactly when
the equals(Object) method would return true.
This is the definition of lexicographic ordering. If two strings are
different, then either they have different characters at some index
that is a valid index for both strings, or their lengths are different,
or both. If they have different characters at one or more index
positions, let k be the smallest such index; then the string
whose character at position k has the smaller value, as
determined by using the < operator, lexicographically precedes the
other string. In this case, compareTo returns the
difference of the two character values at position k in
the two string -- that is, the value:
If there is no index position at which they differ, then the shorter string lexicographically precedes the longer string. In this case,this.charAt(k)-anotherString.charAt(k)
compareTo returns the difference of the lengths of the
strings -- that is, the value:
this.length()-anotherString.length()
compareTo in interface PointedCharSequenceanotherString - the String to be compared.0 if the argument string is equal to
this string; a value less than 0 if this string
is lexicographically less than the string argument; and a
value greater than 0 if this string is
lexicographically greater than the string argument.