From: Yoshito Umaoka Date: Thu, 25 Apr 2013 20:15:50 +0000 (+0000) Subject: ICU-9104 Updated CollationElementIterator API spec not to support changing the iterat... X-Git-Tag: milestone-59-0-1~2932 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=766add67f0233803a6c4340f33d31b90d274fe47;p=icu ICU-9104 Updated CollationElementIterator API spec not to support changing the iteration direction without reset. Added a field tracking the iteration direction and trigger assertion when a caller violates the restriction (only when Java assertion is enabled). X-SVN-Rev: 33549 --- diff --git a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java index 40d59e0e638..b222c46cca4 100644 --- a/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java +++ b/icu4j/main/classes/collate/src/com/ibm/icu/text/CollationElementIterator.java @@ -1,6 +1,6 @@ /** ******************************************************************************* -* Copyright (C) 1996-2012, International Business Machines Corporation and * +* Copyright (C) 1996-2013, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -92,7 +92,21 @@ import com.ibm.icu.lang.UCharacter; * *

*

- * This class is not subclassable + * The method next() returns the collation order of the next character based on + * the comparison level of the collator. The method previous() returns the + * collation order of the previous character based on the comparison level of + * the collator. The Collation Element Iterator moves only in one direction + * between calls to reset(), setOffset(), or setText(). That is, next() and + * previous() can not be inter-used. Whenever previous() is to be called after + * next() or vice versa, reset(), setOffset() or setText() has to be called first + * to reset the status, shifting current position to either the end or the start of + * the string (reset() or setText()), or the specified position (setOffset()). + * Hence at the next call of previous() or next(), the first or last collation order, + * or collation order at the specified position will be returned. If a change of + * direction is done without one of these calls, the result is undefined. + *

+ *

+ * This class is not subclassable. *

* @see Collator * @see RuleBasedCollator @@ -138,7 +152,7 @@ public final class CollationElementIterator * corresponding to the next collation element. I.e., getOffset() * returns the position in the source string corresponding to the * collation element that will be returned by the next call to - * next(). This value could be any of: + * next() or previous(). This value could be any of: *