Class Match

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

    public class Match
    extends java.lang.Object
    implements java.lang.Comparable<Match>
    Match maintains information about a single match between two programs. The match can consist of either bytes or code units.
    • Constructor Detail

      • Match

        public Match​(Address thisBeginning,
                     Address otherBeginning,
                     byte[] bytes,
                     int length)
        Parameters:
        thisBeginning - The start Address of the match in the program from which the matches are being found.
        otherBeginning - The start Address of the match in the program to which the matches are being found.
        bytes - the bytes which make up this match.
        length - the length of the bytes array.
      • Match

        public Match​(Address thisBeginning,
                     Address otherBeginning,
                     CodeUnit[] codeUnits,
                     CodeUnit[] otherUnits,
                     int length)
        Parameters:
        thisBeginning - The start Address of the match in the program from which the matches are being found.
        otherBeginning - The start Address of the match in the program to which the matches are being found.
        codeUnits - The CodeUnits which make up the match in this Program.
        otherUnits - The CodeUnits which make up this match in the other program. Note, the code units need no match up byte for byte.
        length - The length of the CodeUnit arrays.
    • Method Detail

      • continueMatch

        public void continueMatch​(byte b)
        Parameters:
        b - Continue the match by adding the additional byte b.
      • continueMatch

        public void continueMatch​(CodeUnit cu,
                                  CodeUnit otherUnit)
        Parameters:
        cu - The CodeUnit which extends the match in 'this' program.
        otherUnit - The CodeUnit which extends the match in 'the other' program.
      • length

        public int length()
        Returns:
        The number of items that make up this match.
      • totalLength

        public int totalLength()
        Returns:
        The total number of bytes that make up this match.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getOtherBeginning

        public Address getOtherBeginning()
        Returns:
        The Address that starts the match in the other program.
      • getThisBeginning

        public Address getThisBeginning()
        Returns:
        The Address that starts the match in this program.
      • getBytes

        public java.lang.Object[] getBytes()
        Returns:
        array containing the objects that make up the match in this program.
      • getOtherBytes

        public java.lang.Object[] getOtherBytes()
        Returns:
        array containing the objects that make up the match in the other program.
      • printMatch

        public java.lang.String printMatch()
      • compareTo

        public int compareTo​(Match m)
        Specified by:
        compareTo in interface java.lang.Comparable<Match>
      • expectedAddressForNextMatch

        public Address expectedAddressForNextMatch​(int baseLength)
        Parameters:
        baseLength - the minimum number of items which make up a match. There are different values for instruction and byte matches. This value should either be NaiveMatchPlugin.MATCH_LENGTH_FOR_INSTRUCTIONS or NaiveMatchPlugin.MATCH_LENGTH_FOR_BYTES which can be found by calling getMatchLengthForInstructions() or getMatchLengthForBytes().
        Returns:
        The Address at which a continuing byte or code unit would be expected to be found in the other program.