org.jboss.soa.esb.actions.soap.attachment
Class SimpleBoyerMoore
java.lang.Object
org.jboss.soa.esb.actions.soap.attachment.SimpleBoyerMoore
public class SimpleBoyerMoore
- extends java.lang.Object
SimpleBoyerMoore
is an implementation of the simplified
version of the Boyer-Moore pattern search algorithm. This just means that the
"good match" portion of the algorithm is removed, which improves the
performance of non repeating patterns with the obvious side-effect of
reducing repeating pattern performance (e.g. gaggaggaaaggaggaagagaggaga).
This version of the algorithm performs incredibly well if the pattern is
rare, for example a MIME boundary.
This algorithm is binary safe.
- Author:
- Jason T. Greene
Constructor Summary |
SimpleBoyerMoore(byte[] pattern)
Constructs a SimpleBoyerMoore instance. |
Method Summary |
int |
patternSearch(byte[] text,
int offset,
int length)
Find an occurence of the search pattern within text. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PATTERN_NOT_FOUND
public static final int PATTERN_NOT_FOUND
- See Also:
- Constant Field Values
SimpleBoyerMoore
public SimpleBoyerMoore(byte[] pattern)
- Constructs a
SimpleBoyerMoore
instance. This internally
stores the pattern so that the same instance can be used across several
searches.
- Parameters:
pattern
- the pattern to search for
patternSearch
public int patternSearch(byte[] text,
int offset,
int length)
- Find an occurence of the search pattern within text.
- Parameters:
text
- a byte array of data to seachoffset
- the index in text to start searching fromlength
- the maximum number of bytes to search
- Returns:
- if a match is found, the index of text where the patter occurs,
otherwise
PATTERN_NOT_FOUND