public interface ParseText
extends java.lang.CharSequence
This interface is normally only of interest to users who wish to create custom tag types.
The parse text is defined as the entire text of the source document in lower case, with all ignored segments replaced by space characters.
The text is stored in lower case to make case insensitive parsing as efficient as possible.
This interface provides many methods which are also provided by the java.lang.String class,
but adds an extra parameter called breakAtIndex to the various indexOf methods.
This parameter allows a search on only a specified segment of the text, which is not possible using the normal String class.
ParseText instances are obtained using the Source.getParseText() method.
| Modifier and Type | Field and Description |
|---|---|
static int |
NO_BREAK
A value to use as the
breakAtIndex argument in certain methods to indicate that the search should continue to the start or end of the parse text. |
| Modifier and Type | Method and Description |
|---|---|
char |
charAt(int index)
Returns the character at the specified index.
|
boolean |
containsAt(java.lang.String str,
int pos)
Indicates whether this parse text contains the specified string at the specified position.
|
int |
indexOf(char searchChar,
int fromIndex)
Returns the index within this parse text of the first occurrence of the specified character,
starting the search at the position specified by
fromIndex. |
int |
indexOf(char searchChar,
int fromIndex,
int breakAtIndex)
Returns the index within this parse text of the first occurrence of the specified character,
starting the search at the position specified by
fromIndex,
and breaking the search at the index specified by breakAtIndex. |
int |
indexOf(java.lang.String searchString,
int fromIndex)
Returns the index within this parse text of the first occurrence of the specified string,
starting the search at the position specified by
fromIndex. |
int |
indexOf(java.lang.String searchString,
int fromIndex,
int breakAtIndex)
Returns the index within this parse text of the first occurrence of the specified string,
starting the search at the position specified by
fromIndex,
and breaking the search at the index specified by breakAtIndex. |
int |
lastIndexOf(char searchChar,
int fromIndex)
Returns the index within this parse text of the last occurrence of the specified character,
searching backwards starting at the position specified by
fromIndex. |
int |
lastIndexOf(char searchChar,
int fromIndex,
int breakAtIndex)
Returns the index within this parse text of the last occurrence of the specified character,
searching backwards starting at the position specified by
fromIndex,
and breaking the search at the index specified by breakAtIndex. |
int |
lastIndexOf(java.lang.String searchString,
int fromIndex)
Returns the index within this parse text of the last occurrence of the specified string,
searching backwards starting at the position specified by
fromIndex. |
int |
lastIndexOf(java.lang.String searchString,
int fromIndex,
int breakAtIndex)
Returns the index within this parse text of the last occurrence of the specified string,
searching backwards starting at the position specified by
fromIndex,
and breaking the search at the index specified by breakAtIndex. |
int |
length()
Returns the length of the parse text.
|
java.lang.CharSequence |
subSequence(int begin,
int end)
Returns a new character sequence that is a subsequence of this sequence.
|
java.lang.String |
toString()
Returns the content of the parse text as a
String. |
static final int NO_BREAK
breakAtIndex argument in certain methods to indicate that the search should continue to the start or end of the parse text.char charAt(int index)
charAt in interface java.lang.CharSequenceindex - the index of the character.boolean containsAt(java.lang.String str,
int pos)
This method is analogous to the java.lang.String.startsWith(String prefix, int toffset) method.
str - a string.pos - the position (index) in this parse text at which to check for the specified string.true if this parse text contains the specified string at the specified position, otherwise false.int indexOf(char searchChar,
int fromIndex)
fromIndex.
If the specified character is not found then -1 is returned.
searchChar - a character.fromIndex - the index to start the search from.int indexOf(char searchChar,
int fromIndex,
int breakAtIndex)
fromIndex,
and breaking the search at the index specified by breakAtIndex.
The position specified by breakAtIndex is not included in the search.
If the search is to continue to the end of the text,
the value ParseText.NO_BREAK should be specified as the breakAtIndex.
If the specified character is not found then -1 is returned.
searchChar - a character.fromIndex - the index to start the search from.breakAtIndex - the index at which to break off the search, or NO_BREAK if the search is to continue to the end of the text.int indexOf(java.lang.String searchString,
int fromIndex)
fromIndex.
If the specified string is not found then -1 is returned.
searchString - a string.fromIndex - the index to start the search from.int indexOf(java.lang.String searchString,
int fromIndex,
int breakAtIndex)
fromIndex,
and breaking the search at the index specified by breakAtIndex.
The position specified by breakAtIndex is not included in the search.
If the search is to continue to the end of the text,
the value ParseText.NO_BREAK should be specified as the breakAtIndex.
If the specified string is not found then -1 is returned.
searchString - a string.fromIndex - the index to start the search from.breakAtIndex - the index at which to break off the search, or NO_BREAK if the search is to continue to the end of the text.int lastIndexOf(char searchChar,
int fromIndex)
fromIndex.
If the specified character is not found then -1 is returned.
searchChar - a character.fromIndex - the index to start the search from.int lastIndexOf(char searchChar,
int fromIndex,
int breakAtIndex)
fromIndex,
and breaking the search at the index specified by breakAtIndex.
The position specified by breakAtIndex is not included in the search.
If the search is to continue to the start of the text,
the value ParseText.NO_BREAK should be specified as the breakAtIndex.
If the specified character is not found then -1 is returned.
searchChar - a character.fromIndex - the index to start the search from.breakAtIndex - the index at which to break off the search, or NO_BREAK if the search is to continue to the start of the text.int lastIndexOf(java.lang.String searchString,
int fromIndex)
fromIndex.
If the specified string is not found then -1 is returned.
searchString - a string.fromIndex - the index to start the search from.int lastIndexOf(java.lang.String searchString,
int fromIndex,
int breakAtIndex)
fromIndex,
and breaking the search at the index specified by breakAtIndex.
The position specified by breakAtIndex is not included in the search.
If the search is to continue to the start of the text,
the value ParseText.NO_BREAK should be specified as the breakAtIndex.
If the specified string is not found then -1 is returned.
searchString - a string.fromIndex - the index to start the search from.breakAtIndex - the index at which to break off the search, or NO_BREAK if the search is to continue to the start of the text.int length()
length in interface java.lang.CharSequencejava.lang.CharSequence subSequence(int begin,
int end)
subSequence in interface java.lang.CharSequencebegin - the begin position, inclusive.end - the end position, exclusive.java.lang.String toString()
String.toString in interface java.lang.CharSequencetoString in class java.lang.ObjectString.