SearchIterator Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
SearchIterator
is an abstract base class that provides
methods to search for a pattern within a text string.
[Android.Runtime.Register("android/icu/text/SearchIterator", ApiSince=24, DoNotGenerateAcw=true)]
public abstract class SearchIterator : Java.Lang.Object
[<Android.Runtime.Register("android/icu/text/SearchIterator", ApiSince=24, DoNotGenerateAcw=true)>]
type SearchIterator = class
inherit Object
- Inheritance
- Derived
- Attributes
Remarks
SearchIterator
is an abstract base class that provides methods to search for a pattern within a text string. Instances of SearchIterator
maintain a current position and scan over the target text, returning the indices the pattern is matched and the length of each match.
SearchIterator
defines a protocol for text searching. Subclasses provide concrete implementations of various search algorithms. For example, StringSearch
implements language-sensitive pattern matching based on the comparison rules defined in a RuleBasedCollator
object.
Other options for searching include using a BreakIterator to restrict the points at which matches are detected.
SearchIterator
provides an API that is similar to that of other text iteration classes such as BreakIterator
. Using this class, it is easy to scan through text looking for all occurrences of a given pattern. The following example uses a StringSearch
object to find all instances of "fox" in the target string. Any other subclass of SearchIterator
can be used in an identical manner.
<code>
String target = "The quick brown fox jumped over the lazy fox";
String pattern = "fox";
SearchIterator iter = new StringSearch(pattern, target);
for (int pos = iter.first(); pos != SearchIterator.DONE;
pos = iter.next()) {
System.out.println("Found match at " + pos +
", length is " + iter.getMatchLength());
}
</code>
Java documentation for android.icu.text.SearchIterator
.
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.
Constructors
SearchIterator(ICharacterIterator, BreakIterator) |
Protected constructor for use by subclasses. |
SearchIterator(IntPtr, JniHandleOwnership) |
Fields
Done |
DONE is returned by previous() and next() after all valid matches have been returned, and by first() and last() if there are no matches at all. |
Properties
BreakIterator |
Returns the BreakIterator that is used to restrict the indexes at which matches are detected. -or- Set the BreakIterator that will be used to restrict the points at which matches are detected. |
Class |
Returns the runtime class of this |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
Index | |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
MatchedText |
Returns the text that was matched by the most recent call to
|
MatchLength |
Returns the length of text in the string which matches the search pattern. |
MatchStart |
Returns the index to the match in the text string that was searched. |
Overlapping |
Return true if the overlapping property has been set. -or- Determines whether overlapping matches are returned. |
PeerReference | (Inherited from Object) |
Target |
Return the string text to be searched. -or- Set the target text to be searched. |
TargetText |
Target text for searching. |
ThresholdClass | |
ThresholdType |
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) |
First() |
Returns the first index at which the string text matches the search pattern. |
Following(Int32) |
Returns the first index equal or greater than |
GetElementComparisonType() | |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
HandleNext(Int32) |
Abstract method which subclasses override to provide the mechanism for finding the next match in the target text. |
HandlePrevious(Int32) |
Abstract method which subclasses override to provide the mechanism for finding the previous match in the target text. |
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) |
Last() |
Returns the last index in the target text at which it matches the search pattern. |
Next() |
Returns the index of the next point at which the text matches the
search pattern, starting from the current position
The iterator is adjusted so that its current index (as returned by
|
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) |
Preceding(Int32) |
Returns the first index less than |
Previous() |
Returns the index of the previous point at which the string text matches the search pattern, starting at the current position. |
Reset() |
Resets the iteration. |
SetElementComparisonType(SearchIterator+ElementComparisonType) | |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetIndex(Int32) |
Sets the position in the target text at which the next search will start. |
SetMatchLength(Int32) |
Sets the length of the most recent match in the target text. |
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 |
JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |