Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
au.id.jericho.lib.html.ParseText
public final class ParseText
extends java.lang.Object
implements CharSequence
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.
Field Summary | |
static int |
|
Method Summary | |
char |
|
boolean |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
int |
|
CharSequence |
|
String |
|
String |
|
public static final int NO_BREAK
A value to use as thebreakAtIndex
argument in certain methods to indicate that the search should continue to the start or end of the parse text.
- Field Value:
- -1
public char charAt(int index)
Returns the character at the specified index.
- Parameters:
index
- the index of the character.
- Returns:
- the character at the specified index, which is always in lower case.
public boolean containsAt(String str, int pos)
Indicates whether this parse text contains the specified string at the specified position. This method is analogous to thejava.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:
true
if this parse text contains the specified string at the specified position, otherwisefalse
.
public int indexOf(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.
public int indexOf(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 bybreakAtIndex
is not included in the search. If the search is to continue to the end of the text, the valueParseText.NO_BREAK
should 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_BREAK
if 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.
public 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.
public 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 bybreakAtIndex
is not included in the search. If the search is to continue to the end of the text, the valueParseText.NO_BREAK
should 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_BREAK
if 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.
public int indexOf(char[] searchCharArray, int fromIndex)
Returns the index within this parse text of the first occurrence of the specified character array, starting the search at the position specified byfromIndex
. If the specified character array is not found then -1 is returned.
- Parameters:
searchCharArray
- a character array.fromIndex
- the index to start the search from.
- Returns:
- the index within this parse text of the first occurrence of the specified character array within the specified range, or -1 if the character array is not found.
public int indexOf(char[] searchCharArray, int fromIndex, int breakAtIndex)
Returns the index within this parse text of the first occurrence of the specified character array, starting the search at the position specified byfromIndex
, and breaking the search at the index specified bybreakAtIndex
. The position specified bybreakAtIndex
is not included in the search. If the search is to continue to the end of the text, the valueParseText.NO_BREAK
should be specified as thebreakAtIndex
. If the specified character array is not found then -1 is returned.
- Parameters:
searchCharArray
- a character array.fromIndex
- the index to start the search from.breakAtIndex
- the index at which to break off the search, orNO_BREAK
if 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 array within the specified range, or -1 if the character array is not found.
public int lastIndexOf(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.
public int lastIndexOf(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 bybreakAtIndex
is not included in the search. If the search is to continue to the start of the text, the valueParseText.NO_BREAK
should 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_BREAK
if 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.
public 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.
public 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 bybreakAtIndex
is not included in the search. If the search is to continue to the start of the text, the valueParseText.NO_BREAK
should 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_BREAK
if 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.
public int lastIndexOf(char[] searchCharArray, int fromIndex)
Returns the index within this parse text of the last occurrence of the specified character array, searching backwards starting at the position specified byfromIndex
. If the specified character array is not found then -1 is returned.
- Parameters:
searchCharArray
- a character array.fromIndex
- the index to start the search from.
- Returns:
- the index within this parse text of the last occurrence of the specified character array within the specified range, or -1 if the character array is not found.
public int lastIndexOf(char[] searchCharArray, int fromIndex, int breakAtIndex)
Returns the index within this parse text of the last occurrence of the specified character array, searching backwards starting at the position specified byfromIndex
, and breaking the search at the index specified bybreakAtIndex
. The position specified bybreakAtIndex
is not included in the search. If the search is to continue to the start of the text, the valueParseText.NO_BREAK
should be specified as thebreakAtIndex
. If the specified character array is not found then -1 is returned.
- Parameters:
searchCharArray
- a character array.fromIndex
- the index to start the search from.breakAtIndex
- the index at which to break off the search, orNO_BREAK
if 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 array within the specified range, or -1 if the character array is not found.
public int length()
Returns the length of the parse text.
- Returns:
- the length of the parse text.
public CharSequence subSequence(int beginIndex, int endIndex)
Returns a new character sequence that is a subsequence of this sequence. This is equivalent tosubstring(beginIndex,endIndex)
.
- Parameters:
beginIndex
- the begin index, inclusive.endIndex
- the end index, exclusive.
- Returns:
- a new character sequence that is a subsequence of this sequence.
public String substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this parse text. The substring begins at the specifiedbeginIndex
and extends to the character at indexendIndex
- 1. Thus the length of the substring isendIndex-beginIndex
.
- Parameters:
beginIndex
- the begin index, inclusive.endIndex
- the end index, exclusive.
- Returns:
- a new string that is a substring of this parse text.
public String toString()
Returns the content of the parse text as aString
.
- Returns:
- the content of the parse text as a
String
.