|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.text.ParsePosition
javolution.text.TextFormat.Cursor
public static class TextFormat.Cursor
This class represents a parsing cursor over a character sequence (or subsequence). A cursor location may start and end at any predefined location within the character sequence iterated over (equivalent to parsing a subsequence of the character sequence input).
| Method Summary | |
|---|---|
boolean |
at(char c,
java.lang.CharSequence csq)
Indicates if this cursor points to the specified character in the specified character sequence. |
boolean |
at(CharSet charSet,
java.lang.CharSequence csq)
Indicates if this cursor points to one of the specified character. |
boolean |
at(java.lang.String pattern,
java.lang.CharSequence csq)
Indicates if this cursor points to the specified characters in the specified character sequence. |
boolean |
equals(java.lang.Object obj)
Indicates if this cursor is equals to the specified object. |
int |
getEndIndex()
Returns this cursor end index. |
int |
getErrorIndex()
Returns the error index of this cursor if set; otherwise returns the current
index. |
int |
getIndex()
Returns this cursor index. |
int |
getStartIndex()
Returns this cursor start index. |
int |
hashCode()
Returns the hash code for this cursor. |
boolean |
hasNext()
Indicates if this cursor has not reached the end index. |
TextFormat.Cursor |
increment()
Increments the cursor index by one. |
TextFormat.Cursor |
increment(int i)
Increments the cursor index by the specified value. |
static TextFormat.Cursor |
newInstance(int start,
int end)
Returns a new, preallocated or recycled cursor
instance (on the stack when executing in a StackContext). |
char |
next(java.lang.CharSequence csq)
Returns the next character at the cursor position in the specified character sequence and increments the cursor position by one. |
static void |
recycle(TextFormat.Cursor instance)
Recycles a cursor instance immediately
(on the stack when executing in a StackContext). |
void |
setEndIndex(int end)
Sets this cursor end index. |
void |
setErrorIndex(int errorIndex)
Sets this cursor error index. |
void |
setIndex(int i)
Sets the cursor current index. |
void |
setStartIndex(int start)
Sets this cursor start index. |
boolean |
skip(char c,
java.lang.CharSequence csq)
Moves this cursor forward until it points to a character different from the character specified. |
boolean |
skip(CharSet charSet,
java.lang.CharSequence csq)
Moves this cursor forward until it points to a character different from any of the character in the specified set. |
java.lang.String |
toString()
Returns the string representation of this cursor. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Method Detail |
|---|
public static TextFormat.Cursor newInstance(int start,
int end)
recycled cursor
instance (on the stack when executing in a StackContext).
start - the start index.end - the end index (index after the last character to be read).
public static void recycle(TextFormat.Cursor instance)
instance immediately
(on the stack when executing in a StackContext).
instance - the cursor instance being recycled.public final int getIndex()
getIndex in class java.text.ParsePositionpublic final int getStartIndex()
public final int getEndIndex()
public final int getErrorIndex()
set; otherwise returns the current
index.
getErrorIndex in class java.text.ParsePositionpublic final void setIndex(int i)
setIndex in class java.text.ParsePositioni - the index of the next character to parse.
java.lang.IllegalArgumentException - if ((i < getStartIndex()) || (i > getEndIndex()))public final void setStartIndex(int start)
start - the start index.public final void setEndIndex(int end)
end - the end index.public final void setErrorIndex(int errorIndex)
setErrorIndex in class java.text.ParsePositionerrorIndex - the error index.public final boolean hasNext()
this.getIndex() < this.getEndIndex()public final char next(java.lang.CharSequence csq)
for (char c=cursor.next(csq); c != 0; c = cursor.next(csq)) {
...
}
}
csq - the character sequence iterated by this cursor.
'\u0000'
if the end index has already been reached.
public final boolean at(char c,
java.lang.CharSequence csq)
c - the character.csq - the character sequence iterated by this cursor.
true if the cursor next character is the
one specified; false otherwise.
public final boolean at(CharSet charSet,
java.lang.CharSequence csq)
charSet - the character setcsq - the character sequence iterated by this cursor.
true if the cursor next character is one
of the character contained by the character set;
false otherwise.
public final boolean at(java.lang.String pattern,
java.lang.CharSequence csq)
pattern - the characters searched for.csq - the character sequence iterated by this cursor.
true if the cursor next character are the
one specified in the pattern; false otherwise.
public final boolean skip(char c,
java.lang.CharSequence csq)
c - the character to skip.csq - the character sequence iterated by this cursor.
true if this cursor points to a character
different from the ones specified; false
otherwise (e.g. end of sequence reached).
public final boolean skip(CharSet charSet,
java.lang.CharSequence csq)
// Reads numbers separated by tabulations or spaces.
FastTable<Integer> numbers = new FastTable<Integer>();
while (cursor.skip(CharSet.SPACE_OR_TAB, csq)) {
numbers.add(TypeFormat.parseInt(csq, cursor));
}
charSet - the character to skip.csq - the character sequence iterated by this cursor.
true if this cursor points to a character
different from the ones specified; false
otherwise (e.g. end of sequence reached).public final TextFormat.Cursor increment()
thispublic final TextFormat.Cursor increment(int i)
i - the increment value.
thispublic java.lang.String toString()
toString in class java.text.ParsePositionpublic boolean equals(java.lang.Object obj)
equals in class java.text.ParsePositiontrue if the specified object is a cursor
at the same index; false otherwise.public int hashCode()
hashCode in class java.text.ParsePosition
|
J avolution v5.2 (J2SE 1.5+) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||