diff --git a/src/difflib/ChangeDelta.java b/src/difflib/ChangeDelta.java index 54c6a95..398195f 100644 --- a/src/difflib/ChangeDelta.java +++ b/src/difflib/ChangeDelta.java @@ -84,4 +84,9 @@ public class ChangeDelta extends Delta { return "[ChangeDelta, position: " + getOriginal().getPosition() + ", lines: " + getOriginal().getLines() + " to " + getRevised().getLines() + "]"; } + + @Override + public TYPE getType() { + return Delta.TYPE.CHANGE; + } } diff --git a/src/difflib/DeleteDelta.java b/src/difflib/DeleteDelta.java index 8a06892..9282dc7 100644 --- a/src/difflib/DeleteDelta.java +++ b/src/difflib/DeleteDelta.java @@ -58,6 +58,11 @@ public class DeleteDelta extends Delta { } } + @Override + public TYPE getType() { + return Delta.TYPE.DELETE; + } + @Override public void verify(List target) throws PatchFailedException { getOriginal().verify(target); diff --git a/src/difflib/Delta.java b/src/difflib/Delta.java index ad9d754..7da3985 100644 --- a/src/difflib/Delta.java +++ b/src/difflib/Delta.java @@ -26,6 +26,10 @@ public abstract class Delta { private Chunk original; private Chunk revised; + public enum TYPE { + CHANGE, DELETE, INSERT + } + /** * Construct the delta for original and revised chunks * @@ -61,6 +65,12 @@ public abstract class Delta { */ public abstract void restore(List target); + /** + * Returns the type of delta + * @return the type enum + */ + public abstract TYPE getType(); + /** * @return the Chunk describing the original text */ diff --git a/src/difflib/InsertDelta.java b/src/difflib/InsertDelta.java index 09600a0..57dbbf5 100644 --- a/src/difflib/InsertDelta.java +++ b/src/difflib/InsertDelta.java @@ -66,6 +66,10 @@ public class InsertDelta extends Delta { } + public TYPE getType() { + return Delta.TYPE.INSERT; + } + @Override public String toString() { return "[InsertDelta, position: " + getOriginal().getPosition() + ", lines: "