public class StringSegment extends Object implements CharSequence
| Constructor and Description |
|---|
StringSegment(String str,
boolean foldCase) |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustOffset(int delta)
Equivalent to
setOffset(getOffset()+delta). |
void |
adjustOffsetByCodePoint()
Adjusts the offset by the width of the current lead code point, either 1 or 2 chars.
|
String |
asString()
Returns a String that is equivalent to the CharSequence representation.
|
char |
charAt(int index) |
int |
codePointAt(int index)
Returns the code point at the given index relative to the current offset.
|
boolean |
contentEquals(CharSequence other)
Returns true if this segment contains the same characters as the other CharSequence.
|
int |
getCaseSensitivePrefixLength(CharSequence other)
Like
StringSegment.getCommonPrefixLength(java.lang.CharSequence), but never performs case folding, even if case folding was
enabled in the constructor. |
int |
getCodePoint()
Returns the first code point in the string segment.
|
int |
getCommonPrefixLength(CharSequence other)
Returns the length of the prefix shared by this StringSegment and the given CharSequence.
|
int |
getOffset() |
int |
length() |
void |
resetLength() |
void |
setLength(int length) |
void |
setOffset(int start) |
boolean |
startsWith(CharSequence other)
Returns true if there is at least one code point of overlap between this StringSegment and the
given CharSequence.
|
boolean |
startsWith(int otherCp)
Returns true if the first code point of this StringSegment equals the given code point.
|
boolean |
startsWith(UnicodeSet uniset)
Returns true if the first code point of this StringSegment is in the given UnicodeSet.
|
CharSequence |
subSequence(int start,
int end) |
String |
toString()
Returns a string representation useful for debugging.
|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitchars, codePoints, compare, isEmptypublic StringSegment(String str, boolean foldCase)
public int getOffset()
public void setOffset(int start)
public void adjustOffset(int delta)
setOffset(getOffset()+delta).
Number parsing note: This method is usually called by a Matcher to register that a char was consumed. If the char is strong (it usually is, except for things like whitespace), follow this with a call to ParsedNumber#setCharsConsumed(). For more information on strong chars, see that method.
public void adjustOffsetByCodePoint()
public void setLength(int length)
public void resetLength()
public int length()
length in interface CharSequencepublic char charAt(int index)
charAt in interface CharSequencepublic CharSequence subSequence(int start, int end)
subSequence in interface CharSequencepublic int getCodePoint()
Important: Most of the time, you should use StringSegment.startsWith(int), which handles
case folding logic, instead of this method.
public int codePointAt(int index)
public boolean startsWith(int otherCp)
This method will perform case folding if case folding is enabled for the parser.
public boolean startsWith(UnicodeSet uniset)
public boolean startsWith(CharSequence other)
public int getCommonPrefixLength(CharSequence other)
This method only returns offsets along code point boundaries.
This method will perform case folding if case folding was enabled in the constructor.
IMPORTANT: The given CharSequence must not be empty! It is the caller's responsibility to check.
public int getCaseSensitivePrefixLength(CharSequence other)
StringSegment.getCommonPrefixLength(java.lang.CharSequence), but never performs case folding, even if case folding was
enabled in the constructor.public boolean contentEquals(CharSequence other)
This method does not perform case folding; if you want case-insensitive equality, use
StringSegment.getCommonPrefixLength(java.lang.CharSequence).
public String toString()
toString in interface CharSequencetoString in class Objectpublic String asString()