add type information to the interface

This commit is contained in:
dm.naumenko@gmail.com
2010-10-15 12:16:49 +00:00
parent 76b4dbc840
commit 1fbf668da0
4 changed files with 24 additions and 0 deletions

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -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<Object> target);
/**
* Returns the type of delta
* @return the type enum
*/
public abstract TYPE getType();
/**
* @return the Chunk describing the original text
*/

View File

@@ -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: "