| java.lang.Object com.ibm.icu.impl.RuleCharacterIterator
RuleCharacterIterator | public class RuleCharacterIterator (Code) | | An iterator that returns 32-bit code points. This class is deliberately
not related to any of the JDK or ICU4J character iterator classes
in order to minimize complexity.
author: Alan Liu since: ICU 2.8 |
Field Summary | |
final public static int | DONE Value returned when there are no more characters to iterate. | final public static int | PARSE_ESCAPES Bitmask option to enable parsing of escape sequences. | final public static int | PARSE_VARIABLES Bitmask option to enable parsing of variable names. | final public static int | SKIP_WHITESPACE Bitmask option to enable skipping of whitespace. |
Constructor Summary | |
public | RuleCharacterIterator(String text, SymbolTable sym, ParsePosition pos) Constructs an iterator over the given text, starting at the given
position.
Parameters: text - the text to be iterated Parameters: sym - the symbol table, or null if there is none. |
Method Summary | |
public boolean | atEnd() Returns true if this iterator has no more characters to return. | public Object | getPos(Object p) Returns an object which, when later passed to setPos(), will
restore this iterator's position. | public boolean | inVariable() Returns true if this iterator is currently within a variable expansion. | public boolean | isEscaped() Returns true if the last character returned by next() was
escaped. | public void | jumpahead(int count) Advances the position by the given number of 16-bit code units. | public String | lookahead() Returns a string containing the remainder of the characters to be
returned by this iterator, without any option processing. | public int | next(int options) Returns the next character using the given options, or DONE if there
are no more characters, and advance the position to the next
character.
Parameters: options - one or more of the following options, bitwise-OR-edtogether: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE. | public void | setPos(Object p) Restores this iterator to the position it had when getPos()
returned the given object. | public void | skipIgnored(int options) Skips ahead past any ignored characters, as indicated by the given
options. | public String | toString() Returns a string representation of this object, consisting of the
characters being iterated, with a '|' marking the current position. |
DONE | final public static int DONE(Code) | | Value returned when there are no more characters to iterate.
|
PARSE_ESCAPES | final public static int PARSE_ESCAPES(Code) | | Bitmask option to enable parsing of escape sequences. If (options &
PARSE_ESCAPES) != 0, then an embedded escape sequence will be expanded
to its value. Escapes are parsed using Utility.unescapeAt().
|
PARSE_VARIABLES | final public static int PARSE_VARIABLES(Code) | | Bitmask option to enable parsing of variable names. If (options &
PARSE_VARIABLES) != 0, then an embedded variable will be expanded to
its value. Variables are parsed using the SymbolTable API.
|
SKIP_WHITESPACE | final public static int SKIP_WHITESPACE(Code) | | Bitmask option to enable skipping of whitespace. If (options &
SKIP_WHITESPACE) != 0, then whitespace characters will be silently
skipped, as if they were not present in the input. Whitespace
characters are defined by UCharacterProperty.isRuleWhiteSpace().
|
RuleCharacterIterator | public RuleCharacterIterator(String text, SymbolTable sym, ParsePosition pos)(Code) | | Constructs an iterator over the given text, starting at the given
position.
Parameters: text - the text to be iterated Parameters: sym - the symbol table, or null if there is none. If sym is null,then variables will not be deferenced, even if the PARSE_VARIABLESoption is set. Parameters: pos - upon input, the index of the next character to return. If avariable has been dereferenced, then pos will not increment ascharacters of the variable value are iterated. |
atEnd | public boolean atEnd()(Code) | | Returns true if this iterator has no more characters to return.
|
getPos | public Object getPos(Object p)(Code) | | Returns an object which, when later passed to setPos(), will
restore this iterator's position. Usage idiom:
RuleCharacterIterator iterator = ...;
Object pos = iterator.getPos(null); // allocate position object
for (;;) {
pos = iterator.getPos(pos); // reuse position object
int c = iterator.next(...);
...
}
iterator.setPos(pos);
Parameters: p - a position object previously returned by getPos(),or null. If not null, it will be updated and returned. Ifnull, a new position object will be allocated and returned. a position object which may be passed to setPos(),either `p,' or if `p' == null, a newly-allocated object |
inVariable | public boolean inVariable()(Code) | | Returns true if this iterator is currently within a variable expansion.
|
isEscaped | public boolean isEscaped()(Code) | | Returns true if the last character returned by next() was
escaped. This will only be the case if the option passed in to
next() included PARSE_ESCAPED and the next character was an
escape sequence.
|
jumpahead | public void jumpahead(int count)(Code) | | Advances the position by the given number of 16-bit code units.
This is useful in conjunction with the lookahead() method.
Parameters: count - the number of 16-bit code units to jump over |
lookahead | public String lookahead()(Code) | | Returns a string containing the remainder of the characters to be
returned by this iterator, without any option processing. If the
iterator is currently within a variable expansion, this will only
extend to the end of the variable expansion. This method is provided
so that iterators may interoperate with string-based APIs. The typical
sequence of calls is to call skipIgnored(), then call lookahead(), then
parse the string returned by lookahead(), then call jumpahead() to
resynchronize the iterator.
a string containing the characters to be returned by futurecalls to next() |
next | public int next(int options)(Code) | | Returns the next character using the given options, or DONE if there
are no more characters, and advance the position to the next
character.
Parameters: options - one or more of the following options, bitwise-OR-edtogether: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE. the current 32-bit code point, or DONE |
setPos | public void setPos(Object p)(Code) | | Restores this iterator to the position it had when getPos()
returned the given object.
Parameters: p - a position object previously returned by getPos() |
skipIgnored | public void skipIgnored(int options)(Code) | | Skips ahead past any ignored characters, as indicated by the given
options. This is useful in conjunction with the lookahead() method.
Currently, this only has an effect for SKIP_WHITESPACE.
Parameters: options - one or more of the following options, bitwise-OR-edtogether: PARSE_VARIABLES, PARSE_ESCAPES, SKIP_WHITESPACE. |
toString | public String toString()(Code) | | Returns a string representation of this object, consisting of the
characters being iterated, with a '|' marking the current position.
Position within an expanded variable is not indicated.
a string representation of this object |
|
|