public class ByteArrayCharSequence extends java.lang.Object implements PointedCharSequence
Constructor and Description |
---|
ByteArrayCharSequence(byte[] bytes,
int start,
int end)
Creates a char sequence backed by bytes,
starting from start (inclusive) and ending at end (exclusive).
|
ByteArrayCharSequence(byte[] bytes,
int start,
int end,
long position)
Creates a char sequence backed by bytes,
starting from start (inclusive) and ending at end (exclusive).
|
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 ByteArrayCharSequence(byte[] bytes, int start, int end)
bytes
- backing byte arraystart
- start index (inclusive)end
- end index (exclusive)public ByteArrayCharSequence(byte[] bytes, int start, int end, long position)
bytes
- backing byte arraystart
- start index (inclusive)end
- end index (exclusive)position
- last byte position (exclusive)public long getLastBytePosition()
PointedCharSequence
getLastBytePosition
in interface PointedCharSequence
public int length()
length
in interface java.lang.CharSequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public int indexOf(java.lang.String str)
PointedCharSequence
The 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 PointedCharSequence
str
- the substring to search for.-1
if there is no such occurrence.public int compareTo(java.lang.String anotherString)
PointedCharSequence
compareTo
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 PointedCharSequence
anotherString
- 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.