com.jaxfront.core.util.stringSearch
Class ShiftOrClasses
java.lang.Object
com.jaxfront.core.util.stringSearch.StringSearch
com.jaxfront.core.util.stringSearch.ShiftOr
com.jaxfront.core.util.stringSearch.ShiftOrClasses
public class ShiftOrClasses
- extends ShiftOr
An implementation of the Shift-Or algorithm that supports character classes. The following character classes are supported:
| x |
a character from the Alphabet Σ |
| ? |
a "don't care" symbol which matches all symbols |
| [characters] |
a class of characters where ranges (a-z, 0-9) are allowed |
| ^ |
the negation of a class(^a, ^[abc], ^[c-h]) |
| \ |
escapes the next character (\ must be written as \\ in Java). |
Examples:
mpeg will obviously match mpeg, and not mpag
mp?g will match mpeg, mp7g, mpog, but not mpg (see com.eaio.stringsearch.ShiftOrWildcards)
mp^ag will match mpeg, mpog, mpcg, but not mpag
mpe^ will only match mpe^
mp\^ag ("mp\\^ag" in Java) will match mp^ag, but not mpeg
mp[aeiou]g will match mpeg, mpug, but not mptg
mp^[a-k]g will match mpog, mpzg, but not mpeg
mp[u-a]g will match mpeg, too
mp^?g will match mpeg
mp^[]g will match mpeg, too (negation of the empty class == all characters)
Preprocessing: O(2n + &sum) time
Searching : O(mn / log n) (worst case and average)
- See Also:
com.eaio.stringsearch.ShiftOr
|
Method Summary |
java.lang.Object |
processBytes(byte[] pattern)
Pre-processing of the pattern. |
java.lang.Object |
processChars(char[] pattern)
Pre-processing of the pattern. |
| Methods inherited from class com.jaxfront.core.util.stringSearch.StringSearch |
equals, getAllOccurences, hashCode, processString, searchBytes, searchBytes, searchBytes, searchBytes, searchBytes, searchChars, searchChars, searchChars, searchChars, searchChars, searchString, searchString, searchString, searchString, searchString, searchString, toString, toStringBuffer, usesNative, usesReflection |
| Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
ShiftOrClasses
public ShiftOrClasses()
- Constructor for ShiftOrClasses. Note that it is not required to create multiple instances.
processBytes
public java.lang.Object processBytes(byte[] pattern)
- Description copied from class:
ShiftOr
- Pre-processing of the pattern. The pattern may not exceed 31 bytes in length. If it does, only it's first 31 bytes are processed which might lead to unexpected results. Returns an
int array.
- Overrides:
processBytes in class ShiftOr
- Parameters:
pattern - the byte array containing the pattern, may not be null
- Returns:
- an Object
- See Also:
ShiftOr.processBytes(byte[])
processChars
public java.lang.Object processChars(char[] pattern)
- Description copied from class:
ShiftOr
- Pre-processing of the pattern. The pattern may not exceed 31 characters in length. If it does, only it's first 31 characters are processed which might lead to unexpected results. Returns a
CharIntMap.
- Overrides:
processChars in class ShiftOr
- Parameters:
pattern - a char array containing the pattern, may not be null
- Returns:
- an Object
- See Also:
ShiftOr.processChars(char[])