Class Diff

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected DiffAlgorithm algorithm
      The differencing algorithm to use.
      static java.lang.String NL
      The standard line separator.
      protected java.lang.Object[] orig
      The original sequence.
      static java.lang.String RCS_EOL
      The line separator to use in RCS format output.
    • Constructor Summary

      Constructors 
      Constructor Description
      Diff​(java.lang.Object[] original)
      Create a differencing object using the default algorithm
      Diff​(java.lang.Object[] original, DiffAlgorithm algorithm)
      Create a differencing object using the given algorithm
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String arrayToString​(java.lang.Object[] o)
      Converts an array of Object to a string using Diff.NL as the line separator.
      static boolean compare​(java.lang.Object[] orig, java.lang.Object[] rev)
      Compares the two input sequences.
      protected DiffAlgorithm defaultAlgorithm()  
      Revision diff​(java.lang.Object[] rev)
      compute the difference between the original and a revision.
      static Revision diff​(java.lang.Object[] orig, java.lang.Object[] rev)
      compute the difference between an original and a revision.
      static Revision diff​(java.lang.Object[] orig, java.lang.Object[] rev, DiffAlgorithm algorithm)
      compute the difference between an original and a revision.
      static java.lang.Object[] editAll​(java.lang.Object[] text)
      Edits all of the items in the input sequence.
      static java.lang.Object[] randomEdit​(java.lang.Object[] text)
      Performs random edits on the input sequence.
      static java.lang.Object[] randomEdit​(java.lang.Object[] text, long seed)
      Performs random edits on the input sequence.
      static java.lang.Object[] randomSequence​(int size)
      Generate a random sequence of the given size.
      static java.lang.Object[] randomSequence​(int size, long seed)
      Generate a random sequence of the given size.
      static java.lang.Object[] shuffle​(java.lang.Object[] text)
      Shuffles around the items in the input sequence.
      static java.lang.Object[] shuffle​(java.lang.Object[] text, long seed)
      Shuffles around the items in the input sequence.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NL

        public static final java.lang.String NL
        The standard line separator.
      • RCS_EOL

        public static final java.lang.String RCS_EOL
        The line separator to use in RCS format output.
        See Also:
        Constant Field Values
      • orig

        protected final java.lang.Object[] orig
        The original sequence.
      • algorithm

        protected DiffAlgorithm algorithm
        The differencing algorithm to use.
    • Constructor Detail

      • Diff

        public Diff​(java.lang.Object[] original)
        Create a differencing object using the default algorithm
        Parameters:
        original - the original text that will be compared
      • Diff

        public Diff​(java.lang.Object[] original,
                    DiffAlgorithm algorithm)
        Create a differencing object using the given algorithm
        Parameters:
        original - the original text that will be compared
        algorithm - the difference algorithm to use.
    • Method Detail

      • diff

        public static Revision diff​(java.lang.Object[] orig,
                                    java.lang.Object[] rev)
                             throws DifferentiationFailedException
        compute the difference between an original and a revision.
        Parameters:
        orig - the original
        rev - the revision to compare with the original.
        Returns:
        a Revision describing the differences
        Throws:
        DifferentiationFailedException
      • diff

        public static Revision diff​(java.lang.Object[] orig,
                                    java.lang.Object[] rev,
                                    DiffAlgorithm algorithm)
                             throws DifferentiationFailedException
        compute the difference between an original and a revision.
        Parameters:
        orig - the original
        rev - the revision to compare with the original.
        algorithm - the difference algorithm to use
        Returns:
        a Revision describing the differences
        Throws:
        DifferentiationFailedException
      • compare

        public static boolean compare​(java.lang.Object[] orig,
                                      java.lang.Object[] rev)
        Compares the two input sequences.
        Parameters:
        orig - The original sequence.
        rev - The revised sequence.
        Returns:
        true if the sequences are identical. False otherwise.
      • arrayToString

        public static java.lang.String arrayToString​(java.lang.Object[] o)
        Converts an array of Object to a string using Diff.NL as the line separator.
        Parameters:
        o - the array of objects.
        Returns:
        String
      • editAll

        public static java.lang.Object[] editAll​(java.lang.Object[] text)
        Edits all of the items in the input sequence.
        Parameters:
        text - The input sequence.
        Returns:
        A sequence of the same length with all the lines differing from the corresponding ones in the input.
      • randomEdit

        public static java.lang.Object[] randomEdit​(java.lang.Object[] text)
        Performs random edits on the input sequence. Useful for testing.
        Parameters:
        text - The input sequence.
        Returns:
        The sequence with random edits performed.
      • randomEdit

        public static java.lang.Object[] randomEdit​(java.lang.Object[] text,
                                                    long seed)
        Performs random edits on the input sequence. Useful for testing.
        Parameters:
        text - The input sequence.
        seed - A seed value for the randomizer.
        Returns:
        The sequence with random edits performed.
      • shuffle

        public static java.lang.Object[] shuffle​(java.lang.Object[] text)
        Shuffles around the items in the input sequence.
        Parameters:
        text - the input sequence.
        Returns:
        The shuffled sequence.
      • shuffle

        public static java.lang.Object[] shuffle​(java.lang.Object[] text,
                                                 long seed)
        Shuffles around the items in the input sequence.
        Parameters:
        text - the input sequence.
        seed - a seed value for randomizing the generation.
        Returns:
        The shuffled sequence.
      • randomSequence

        public static java.lang.Object[] randomSequence​(int size)
        Generate a random sequence of the given size.
        Parameters:
        size - the size of the sequence to generate.
        Returns:
        The generated sequence.
      • randomSequence

        public static java.lang.Object[] randomSequence​(int size,
                                                        long seed)
        Generate a random sequence of the given size.
        Parameters:
        size - the size of the sequence to generate.
        seed - a seed value for randomizing the generation.
        Returns:
        The generated sequence.