Freigeben über


CollationElementIterator Class

Definition

CollationElementIterator is an iterator created by a RuleBasedCollator to walk through a string.

[Android.Runtime.Register("android/icu/text/CollationElementIterator", ApiSince=24, DoNotGenerateAcw=true)]
public sealed class CollationElementIterator : Java.Lang.Object
[<Android.Runtime.Register("android/icu/text/CollationElementIterator", ApiSince=24, DoNotGenerateAcw=true)>]
type CollationElementIterator = class
    inherit Object
Inheritance
CollationElementIterator
Attributes

Remarks

CollationElementIterator is an iterator created by a RuleBasedCollator to walk through a string. The return result of each iteration is a 32-bit collation element (CE) that defines the ordering priority of the next character or sequence of characters in the source string.

For illustration, consider the following in Slovak and in traditional Spanish collation: <blockquote>

"ca" -&gt; the first collation element is CE('c') and the second
                    collation element is CE('a').
            "cha" -&gt; the first collation element is CE('ch') and the second
                     collation element is CE('a').

</blockquote> And in German phonebook collation, <blockquote>

Since the character '&#230;' is a composed character of 'a' and 'e', the
            iterator returns two collation elements for the single character '&#230;'

            "&#230;b" -&gt; the first collation element is collation_element('a'), the
                         second collation element is collation_element('e'), and the
                         third collation element is collation_element('b').

</blockquote>

For collation ordering comparison, the collation element results can not be compared simply by using basic arithmetic operators, e.g. &lt;, == or &gt;, further processing has to be done. Details can be found in the ICU User Guide. An example of using the CollationElementIterator for collation ordering comparison is the class android.icu.text.StringSearch.

To construct a CollationElementIterator object, users call the method getCollationElementIterator() on a RuleBasedCollator that defines the desired sorting order.

Example: <blockquote>

String testString = "This is a test";
             RuleBasedCollator rbc = new RuleBasedCollator("&amp;a&lt;b");
             CollationElementIterator iterator = rbc.getCollationElementIterator(testString);
             int primaryOrder = iterator.IGNORABLE;
             while (primaryOrder != iterator.NULLORDER) {
                 int order = iterator.next();
                 if (order != iterator.IGNORABLE &amp;&amp;
                     order != iterator.NULLORDER) {
                     // order is valid, not ignorable and we have not passed the end
                     // of the iteration, we do something
                     primaryOrder = CollationElementIterator.primaryOrder(order);
                     System.out.println("Next primary order 0x" +
                                        Integer.toHexString(primaryOrder));
                 }
             }

</blockquote>

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 next() or previous(), 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.

Java documentation for android.icu.text.CollationElementIterator.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

Ignorable

This constant is returned by the iterator in the methods next() and previous() when a collation element result is to be ignored.

Nullorder

This constant is returned by the iterator in the methods next() and previous() when the end or the beginning of the source string has been reached, and there are no more valid collation elements to return.

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Offset

Returns the character offset in the source string corresponding to the next collation element. -or- Sets the iterator to point to the collation element corresponding to the character at the specified offset.

PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetMaxExpansion(Int32)

Returns the maximum length of any expansion sequence that ends with the specified collation element.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Next()

Get the next collation element in the source string.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
Previous()

Get the previous collation element in the source string.

PrimaryOrder(Int32)

Return the primary order of the specified collation element, i.

Reset()

Resets the cursor to the beginning of the string.

SecondaryOrder(Int32)

Return the secondary order of the specified collation element, i.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetText(ICharacterIterator)

Set a new source string iterator for iteration, and reset the offset to the beginning of the text.

SetText(String)

Set a new source string for iteration, and reset the offset to the beginning of the text.

SetText(UCharacterIterator)

Set a new source string iterator for iteration, and reset the offset to the beginning of the text.

TertiaryOrder(Int32)

Return the tertiary order of the specified collation element, i.

ToArray<T>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to