com.trolltech.qt.core
Class QStringMatcher

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QStringMatcher
All Implemented Interfaces:
QtJambiInterface

public class QStringMatcher
extends QtJambiObject

The QStringMatcher class holds a sequence of characters that can be quickly matched in a Unicode string.

This class is useful when you have a sequence of QChars that you want to repeatedly match against some strings (perhaps in a loop), or when you want to search for the same sequence of characters multiple times in the same string. Using a matcher object and indexIn is faster than matching a plain QString with QString::indexOf() if repeated matching takes place. This class offers no benefit if you are doing one-off string matches.

Create the QStringMatcher with the QString you want to search for. Then call indexIn on the QString that you want to search.

See Also:
QString, QByteArrayMatcher, QRegExp

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Constructor Summary
QStringMatcher()
          Constructs an empty string matcher that won't match anything.
QStringMatcher(QStringMatcher other)
          Copies the other string matcher to this string matcher.
QStringMatcher(java.lang.String pattern)
          Equivalent to QStringMatcher(pattern, Qt::CaseSensitive).
QStringMatcher(java.lang.String pattern, Qt.CaseSensitivity cs)
          Constructs a string matcher that will search for pattern, with case sensitivity cs.
 
Method Summary
 Qt.CaseSensitivity caseSensitivity()
          Returns the case sensitivity setting for this string matcher.
static QStringMatcher fromNativePointer(QNativePointer nativePointer)
          This function returns the QStringMatcher instance pointed to by nativePointer
 int indexIn(java.lang.String str)
          Equivalent to indexIn(str, 0).
 int indexIn(java.lang.String str, int from)
          Searches the string str from character position from (default 0, i.e. from the first character), for the string pattern that was set in the constructor or in the most recent call to setPattern.
static QNativePointer nativePointerArray(QStringMatcher[] array)
          This function returns a QNativePointer that is pointing to the specified QStringMatcher array.
 java.lang.String pattern()
          Returns the string pattern that this string matcher will search for.
 void setCaseSensitivity(Qt.CaseSensitivity cs)
          Sets the case sensitivity setting of this string matcher to cs.
 void setPattern(java.lang.String pattern)
          Sets the string that this string matcher will search for to pattern.
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QStringMatcher

public QStringMatcher()

Constructs an empty string matcher that won't match anything. Call setPattern to give it a pattern to match.


QStringMatcher

public QStringMatcher(java.lang.String pattern)

Equivalent to QStringMatcher(pattern, Qt::CaseSensitive).


QStringMatcher

public QStringMatcher(java.lang.String pattern,
                      Qt.CaseSensitivity cs)

Constructs a string matcher that will search for pattern, with case sensitivity cs.

Call indexIn to perform a search.


QStringMatcher

public QStringMatcher(QStringMatcher other)

Copies the other string matcher to this string matcher.

Method Detail

caseSensitivity

public final Qt.CaseSensitivity caseSensitivity()

Returns the case sensitivity setting for this string matcher.

See Also:
setCaseSensitivity

indexIn

public final int indexIn(java.lang.String str)

Equivalent to indexIn(str, 0).


indexIn

public final int indexIn(java.lang.String str,
                         int from)

Searches the string str from character position from (default 0, i.e. from the first character), for the string pattern that was set in the constructor or in the most recent call to setPattern. Returns the position where the pattern matched in str, or -1 if no match was found.

See Also:
setPattern, setCaseSensitivity

pattern

public final java.lang.String pattern()

Returns the string pattern that this string matcher will search for.

See Also:
setPattern

setCaseSensitivity

public final void setCaseSensitivity(Qt.CaseSensitivity cs)

Sets the case sensitivity setting of this string matcher to cs.

See Also:
caseSensitivity, setPattern, indexIn

setPattern

public final void setPattern(java.lang.String pattern)

Sets the string that this string matcher will search for to pattern.

See Also:
pattern, setCaseSensitivity, indexIn

fromNativePointer

public static QStringMatcher fromNativePointer(QNativePointer nativePointer)
This function returns the QStringMatcher instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QStringMatcher[] array)
This function returns a QNativePointer that is pointing to the specified QStringMatcher array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.