Class SequenceSearchState

  • All Implemented Interfaces:
    java.lang.Comparable<SequenceSearchState>

    public class SequenceSearchState
    extends java.lang.Object
    implements java.lang.Comparable<SequenceSearchState>
    SeqenceSearchState holds the state of a search for a DittedBitSequence within a byte sequence.
    • Constructor Detail

      • SequenceSearchState

        public SequenceSearchState​(SequenceSearchState parent)
        Construct a sub sequence state with a parent sequence
        Parameters:
        parent - parent SequenceSearchState
    • Method Detail

      • getMaxSequenceSize

        public int getMaxSequenceSize()
        Returns:
        maximum number of bytes that could be matched by this sequence
      • addSequence

        public void addSequence​(DittedBitSequence pat,
                                int pos)
        Add a pattern to this search sequence. The last pattern added is the successful match pattern.
        Parameters:
        pat - pattern to add
        pos - position within the current set of patterns to add this pattern
      • sortSequences

        public void sortSequences()
        Sort the sequences that have been added
      • sequenceMatch

        public void sequenceMatch​(byte[] bytearray,
                                  int numbytes,
                                  java.util.ArrayList<Match> match)
        Try to match this Sequence to the byteArray, and add any matches to the match list
        Parameters:
        bytearray - array of bytes to match
        numbytes - retrict number of bytes to allow to match
        match - list of matches, the result
      • apply

        public void apply​(byte[] buffer,
                          java.util.ArrayList<Match> match)
        Search for patterns in a byte array. All matches are returned.
        Parameters:
        buffer - is the array of bytes to search
        match - is populated with a Match object for each pattern and position that matches
      • apply

        public void apply​(java.io.InputStream in,
                          java.util.ArrayList<Match> match,
                          TaskMonitor monitor)
                   throws java.io.IOException
        Search for pattern in the stream -in-.
        Parameters:
        in - - The stream to scan for matches
        match - - Any matches are appended as Match records to this ArrayList
        monitor - - if non-null, check for user cancel, and maintain progress info
        Throws:
        java.io.IOException
      • apply

        public void apply​(java.io.InputStream in,
                          long maxBytes,
                          java.util.ArrayList<Match> match,
                          TaskMonitor monitor)
                   throws java.io.IOException
        Search for pattern in the stream -in-.
        Parameters:
        in - - The stream to scan for matches
        maxBytes - - The maximum number of bytes to scan forward in this stream
        match - - Any matches are appended as Match records to this ArrayList
        monitor - - if non-null, check for user cancel, and maintain progress info
        Throws:
        java.io.IOException
      • buildStateMachine

        public static SequenceSearchState buildStateMachine​(java.util.ArrayList<? extends DittedBitSequence> patterns)
        Build a search state machine from a list of DittedBitSequences
        Parameters:
        patterns - bit sequence patterns
        Returns:
        search state the will match the given sequences