Interface ParseText
-
- All Superinterfaces:
java.lang.CharSequence
public interface ParseText extends java.lang.CharSequenceRepresents the text from the source document that is to be parsed.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.Stringclass, but adds an extra parameter calledbreakAtIndexto the variousindexOfmethods. This parameter allows a search on only a specified segment of the text, which is not possible using the normalStringclass.ParseTextinstances are obtained using theSource.getParseText()method.
-
-
Field Summary
Fields Modifier and Type Field Description static intNO_BREAKA value to use as thebreakAtIndexargument in certain methods to indicate that the search should continue to the start or end of the parse text.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description charcharAt(int index)Returns the character at the specified index.booleancontainsAt(java.lang.String str, int pos)Indicates whether this parse text contains the specified string at the specified position.intindexOf(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 byfromIndex.intindexOf(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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.intindexOf(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 byfromIndex.intindexOf(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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.intlastIndexOf(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 byfromIndex.intlastIndexOf(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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.intlastIndexOf(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 byfromIndex.intlastIndexOf(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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.intlength()Returns the length of the parse text.java.lang.CharSequencesubSequence(int begin, int end)Returns a new character sequence that is a subsequence of this sequence.java.lang.StringtoString()Returns the content of the parse text as aString.
-
-
-
Field Detail
-
NO_BREAK
static final int NO_BREAK
A value to use as thebreakAtIndexargument in certain methods to indicate that the search should continue to the start or end of the parse text.- See Also:
- Constant Field Values
-
-
Method Detail
-
charAt
char charAt(int index)
Returns the character at the specified index.- Specified by:
charAtin interfacejava.lang.CharSequence- Parameters:
index- the index of the character.- Returns:
- the character at the specified index, which is always in lower case.
-
containsAt
boolean containsAt(java.lang.String str, int pos)Indicates whether this parse text contains the specified string at the specified position.This method is analogous to the
java.lang.String.startsWith(String prefix, int toffset)method.- Parameters:
str- a string.pos- the position (index) in this parse text at which to check for the specified string.- Returns:
trueif this parse text contains the specified string at the specified position, otherwisefalse.
-
indexOf
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 byfromIndex.If the specified character is not found then -1 is returned.
- Parameters:
searchChar- a character.fromIndex- the index to start the search from.- Returns:
- the index within this parse text of the first occurrence of the specified character within the specified range, or -1 if the character is not found.
-
indexOf
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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.The position specified by
breakAtIndexis not included in the search.If the search is to continue to the end of the text, the value
ParseText.NO_BREAKshould be specified as thebreakAtIndex.If the specified character is not found then -1 is returned.
- Parameters:
searchChar- a character.fromIndex- the index to start the search from.breakAtIndex- the index at which to break off the search, orNO_BREAKif the search is to continue to the end of the text.- Returns:
- the index within this parse text of the first occurrence of the specified character within the specified range, or -1 if the character is not found.
-
indexOf
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 byfromIndex.If the specified string is not found then -1 is returned.
- Parameters:
searchString- a string.fromIndex- the index to start the search from.- Returns:
- the index within this parse text of the first occurrence of the specified string within the specified range, or -1 if the string is not found.
-
indexOf
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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.The position specified by
breakAtIndexis not included in the search.If the search is to continue to the end of the text, the value
ParseText.NO_BREAKshould be specified as thebreakAtIndex.If the specified string is not found then -1 is returned.
- Parameters:
searchString- a string.fromIndex- the index to start the search from.breakAtIndex- the index at which to break off the search, orNO_BREAKif the search is to continue to the end of the text.- Returns:
- the index within this parse text of the first occurrence of the specified string within the specified range, or -1 if the string is not found.
-
lastIndexOf
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 byfromIndex.If the specified character is not found then -1 is returned.
- Parameters:
searchChar- a character.fromIndex- the index to start the search from.- Returns:
- the index within this parse text of the last occurrence of the specified character within the specified range, or -1 if the character is not found.
-
lastIndexOf
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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.The position specified by
breakAtIndexis not included in the search.If the search is to continue to the start of the text, the value
ParseText.NO_BREAKshould be specified as thebreakAtIndex.If the specified character is not found then -1 is returned.
- Parameters:
searchChar- a character.fromIndex- the index to start the search from.breakAtIndex- the index at which to break off the search, orNO_BREAKif the search is to continue to the start of the text.- Returns:
- the index within this parse text of the last occurrence of the specified character within the specified range, or -1 if the character is not found.
-
lastIndexOf
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 byfromIndex.If the specified string is not found then -1 is returned.
- Parameters:
searchString- a string.fromIndex- the index to start the search from.- Returns:
- the index within this parse text of the last occurrence of the specified string within the specified range, or -1 if the string is not found.
-
lastIndexOf
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 byfromIndex, and breaking the search at the index specified bybreakAtIndex.The position specified by
breakAtIndexis not included in the search.If the search is to continue to the start of the text, the value
ParseText.NO_BREAKshould be specified as thebreakAtIndex.If the specified string is not found then -1 is returned.
- Parameters:
searchString- a string.fromIndex- the index to start the search from.breakAtIndex- the index at which to break off the search, orNO_BREAKif the search is to continue to the start of the text.- Returns:
- the index within this parse text of the last occurrence of the specified string within the specified range, or -1 if the string is not found.
-
length
int length()
Returns the length of the parse text.- Specified by:
lengthin interfacejava.lang.CharSequence- Returns:
- the length of the parse text.
-
subSequence
java.lang.CharSequence subSequence(int begin, int end)Returns a new character sequence that is a subsequence of this sequence.- Specified by:
subSequencein interfacejava.lang.CharSequence- Parameters:
begin- the begin position, inclusive.end- the end position, exclusive.- Returns:
- a new character sequence that is a subsequence of this sequence.
-
toString
java.lang.String toString()
Returns the content of the parse text as aString.- Specified by:
toStringin interfacejava.lang.CharSequence- Overrides:
toStringin classjava.lang.Object- Returns:
- the content of the parse text as a
String.
-
-