public class SimpleBoyerMoore extends 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.| Modifier and Type | Field and Description |
|---|---|
static int |
PATTERN_NOT_FOUND |
| Constructor and Description |
|---|
SimpleBoyerMoore(byte[] pattern)
Constructs a
SimpleBoyerMoore instance. |
| Modifier and Type | Method and Description |
|---|---|
int |
patternSearch(byte[] text,
int offset,
int length)
Find an occurence of the search pattern within text.
|
public static final int PATTERN_NOT_FOUND
public SimpleBoyerMoore(byte[] pattern)
SimpleBoyerMoore instance. This internally
stores the pattern so that the same instance can be used across several
searches.pattern - the pattern to search forpublic int patternSearch(byte[] text,
int offset,
int length)
text - a byte array of data to seachoffset - the index in text to start searching fromlength - the maximum number of bytes to searchPATTERN_NOT_FOUNDCopyright © 2012 JBoss, by Red Hat. All Rights Reserved.