public class UnicodeSetIterator extends Object
To iterate over code points and multicharacter strings, use a loop like this:
for (UnicodeSetIterator it = new UnicodeSetIterator(set); it.next();) { processString(it.getString()); }
To iterate over code point ranges, use a loop like this:
for (UnicodeSetIterator it = new UnicodeSetIterator(set); it.nextRange();) { if (it.codepoint != UnicodeSetIterator.IS_STRING) { processCodepointRange(it.codepoint, it.codepointEnd); } else { processString(it.getString()); } }
Warning: For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.
Modifier and Type | Field and Description |
---|---|
int |
codepoint
Current code point, or the special value IS_STRING, if
the iterator points to a string.
|
int |
codepointEnd
When iterating over ranges using nextRange(),
codepointEnd contains the inclusive end of the
iteration range, if codepoint !
|
protected int |
endElement
Deprecated.
This API is ICU internal only.
|
static int |
IS_STRING
Value of codepoint if the iterator points to a string.
|
protected int |
nextElement
Deprecated.
This API is ICU internal only.
|
String |
string
If codepoint == IS_STRING, then string points
to the current string.
|
Constructor and Description |
---|
UnicodeSetIterator()
Create an iterator over nothing.
|
UnicodeSetIterator(UnicodeSet set)
Create an iterator over the given set.
|
Modifier and Type | Method and Description |
---|---|
UnicodeSet |
getSet()
Deprecated.
This API is ICU internal only.
|
String |
getString()
Gets the current string from the iterator.
|
protected void |
loadRange(int aRange)
Deprecated.
This API is ICU internal only.
|
boolean |
next()
Returns the next element in the set, either a single code point
or a string.
|
boolean |
nextRange()
Returns the next element in the set, either a code point range
or a string.
|
void |
reset()
Resets this iterator to the start of the set.
|
void |
reset(UnicodeSet uset)
Sets this iterator to visit the elements of the given set and
resets it to the start of that set.
|
public static int IS_STRING
public int codepoint
public int codepointEnd
public String string
@Deprecated protected int endElement
@Deprecated protected int nextElement
public UnicodeSetIterator(UnicodeSet set)
set
- set to iterate overpublic UnicodeSetIterator()
public boolean next()
The order of iteration is all code points in sorted order, followed by all strings sorted order. codepointEnd is undefined after calling this method. string is undefined unless codepoint == IS_STRING. Do not mix calls to next() and nextRange() without calling reset() between them. The results of doing so are undefined.
Warning: For speed, UnicodeSet iteration does not check for concurrent modification. Do not alter the UnicodeSet while iterating.
public boolean nextRange()
The order of iteration is all code points ranges in sorted order, followed by all strings sorted order. Ranges are disjoint and non-contiguous. string is undefined unless codepoint == IS_STRING. Do not mix calls to next() and nextRange() without calling reset() between them. The results of doing so are undefined.
public void reset(UnicodeSet uset)
uset
- the set to iterate over.public void reset()
public String getString()
@Deprecated public UnicodeSet getSet()
@Deprecated protected void loadRange(int aRange)
Copyright © 2016 Unicode, Inc. and others.