Class Diff

    • Constructor Detail

      • Diff

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

        public Diff​(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

      • compare

        public static boolean compare​(Object[] orig,
                                      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 String arrayToString​(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 Object[] editAll​(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 Object[] randomEdit​(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 Object[] randomEdit​(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 Object[] shuffle​(Object[] text)
        Shuffles around the items in the input sequence.
        Parameters:
        text - the input sequence.
        Returns:
        The shuffled sequence.
      • shuffle

        public static Object[] shuffle​(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 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 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.