Class SimpleBoyerMoore

  extended by 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.

Jason T. Greene

Field Summary
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

Field Detail


public static final int PATTERN_NOT_FOUND
See Also:
Constant Field Values
Constructor Detail


public SimpleBoyerMoore(byte[] pattern)
Constructs a SimpleBoyerMoore instance. This internally stores the pattern so that the same instance can be used across several searches.

pattern - the pattern to search for
Method Detail


public int patternSearch(byte[] text,
                         int offset,
                         int length)
Find an occurence of the search pattern within text.

text - a byte array of data to seach
offset - the index in text to start searching from
length - the maximum number of bytes to search
if a match is found, the index of text where the patter occurs, otherwise PATTERN_NOT_FOUND