GeezerVison is showing docs.oracle.com — CollationElementIterator (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.text
Class CollationElementIterator
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
static int |
NULLORDER |
Null order which indicates the end of string is reached by the
cursor.
|
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
int |
getMaxExpansion(int order) |
Return the maximum length of any expansion sequences that end
with the specified comparison order.
|
int |
getOffset() |
Returns the character offset in the original text corresponding to the next
collation element.
|
int |
next() |
Get the next collation element in the string.
|
int |
previous() |
Get the previous collation element in the string.
|
static int |
primaryOrder(int order) |
Return the primary component of a collation element.
|
void |
reset() |
Resets the cursor to the beginning of the string.
|
static short |
secondaryOrder(int order) |
Return the secondary component of a collation element.
|
void |
setOffset(int newOffset) |
Sets the iterator to point to the collation element corresponding to
the specified character (the parameter is a CHARACTER offset in the
original string, not an offset into its corresponding sequence of
collation elements).
|
void |
setText(CharacterIterator source) |
Set a new string over which to iterate.
|
void |
setText(String source) |
Set a new string over which to iterate.
|
static short |
tertiaryOrder(int order) |
Return the tertiary component of a collation element.
|
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
next
public int next()
Get the next collation element in the string. This iterator iterates
over a sequence of collation elements that were built from the string.
Because there isn't necessarily a one-to-one mapping from characters to
collation elements, this doesn't mean the same thing as "return the
collation element [or ordering priority] of the next character in the
string".
This function returns the collation element that the iterator is currently
pointing to and then updates the internal pointer to point to the next element.
previous() updates the pointer first and then returns the element. This
means that when you change direction while iterating (i.e., call next() and
then call previous(), or call previous() and then call next()), you'll get
back the same element twice.
- Returns:
- the next collation element
-
previous
public int previous()
Get the previous collation element in the string. This iterator iterates
over a sequence of collation elements that were built from the string.
Because there isn't necessarily a one-to-one mapping from characters to
collation elements, this doesn't mean the same thing as "return the
collation element [or ordering priority] of the previous character in the
string".
This function updates the iterator's internal pointer to point to the
collation element preceding the one it's currently pointing to and then
returns that element, while next() returns the current element and then
updates the pointer. This means that when you change direction while
iterating (i.e., call next() and then call previous(), or call previous()
and then call next()), you'll get back the same element twice.
- Returns:
- the previous collation element
- Since:
- 1.2
-
setOffset
public void setOffset(int newOffset)
Sets the iterator to point to the collation element corresponding to
the specified character (the parameter is a CHARACTER offset in the
original string, not an offset into its corresponding sequence of
collation elements). The value returned by the next call to next()
will be the collation element corresponding to the specified position
in the text. If that position is in the middle of a contracting
character sequence, the result of the next call to next() is the
collation element for that sequence. This means that getOffset()
is not guaranteed to return the same value as was passed to a preceding
call to setOffset().
- Parameters:
newOffset - The new character offset into the original text.
- Since:
- 1.2
-
getOffset
public int getOffset()
Returns the character offset in the original text corresponding to the next
collation element. (That is, getOffset() returns the position in the text
corresponding to the collation element that will be returned by the next
call to next().) This value will always be the index of the FIRST character
corresponding to the collation element (a contracting character sequence is
when two or more characters all correspond to the same collation element).
This means if you do setOffset(x) followed immediately by getOffset(), getOffset()
won't necessarily return x.
- Returns:
- The character offset in the original text corresponding to the collation
element that will be returned by the next call to next().
- Since:
- 1.2
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|