Package net.morimekta.diff
Class DiffBase
- java.lang.Object
-
- net.morimekta.diff.DiffBase
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)abstract java.util.LinkedList<Change>getChangeList()Get the finished changelist.DiffOptionsgetOptions()Get the diff options used when diffing.inthashCode()intlevenshtein()Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.java.lang.StringprettyHtml()Convert a DiffBase list into a pretty HTML report.java.lang.Stringtext1()Compute and return the source text (all equalities and deletions).java.lang.Stringtext2()Compute and return the destination text (all equalities and insertions).java.lang.StringtoDelta()Crush the diff into an encoded string which describes the operations required to transform text1 into text2.java.lang.StringtoString()intxIndex(int loc)loc is a location in text1, compute and return the equivalent location in text2.
-
-
-
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:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.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.
-
-