Class DiffBase

  • Direct Known Subclasses:
    Bisect, Diff, DiffLines

    public abstract class DiffBase
    extends java.lang.Object
    DiffBase
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      abstract java.util.LinkedList<Change> getChangeList()
      Get the finished changelist.
      DiffOptions getOptions()
      Get the diff options used when diffing.
      int hashCode()  
      int levenshtein()
      Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
      java.lang.String prettyHtml()
      Convert a DiffBase list into a pretty HTML report.
      java.lang.String text1()
      Compute and return the source text (all equalities and deletions).
      java.lang.String text2()
      Compute and return the destination text (all equalities and insertions).
      java.lang.String toDelta()
      Crush the diff into an encoded string which describes the operations required to transform text1 into text2.
      java.lang.String toString()  
      int xIndex​(int loc)
      loc is a location in text1, compute and return the equivalent location in text2.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getOptions

        public DiffOptions getOptions()
        Get the diff options used when diffing.
        Returns:
        The diff options.
      • getChangeList

        public abstract java.util.LinkedList<Change> getChangeList()
        Get the finished changelist.
        Returns:
        List of changes.
      • toString

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • prettyHtml

        public java.lang.String prettyHtml()
        Convert a DiffBase list into a pretty HTML report.
        Returns:
        HTML representation.
      • text1

        public java.lang.String text1()
        Compute and return the source text (all equalities and deletions).
        Returns:
        Source text.
      • text2

        public java.lang.String text2()
        Compute and return the destination text (all equalities and insertions).
        Returns:
        Destination text.
      • levenshtein

        public int levenshtein()
        Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.
        Returns:
        Number of changes.
      • toDelta

        public java.lang.String toDelta()
        Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. "=3\t-2\t+ing" -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using %xx notation.
        Returns:
        Delta text.
      • xIndex

        public int xIndex​(int loc)
        loc is a location in text1, compute and return the equivalent location in text2.

        e.g. "The cat" vs "The big cat", 1->1, 5->8

        Parameters:
        loc - Location within text1.
        Returns:
        Location within text2.