difflib
Class Delta<T>

java.lang.Object
  extended by difflib.Delta<T>
Direct Known Subclasses:
ChangeDelta, DeleteDelta, InsertDelta

public abstract class Delta<T>
extends Object

Describes the delta between original and revised texts.

Author:
Dmitry Naumenko

Nested Class Summary
static class Delta.TYPE
          Specifies the type of the delta.
 
Constructor Summary
Delta(Chunk<T> original, Chunk<T> revised)
          Construct the delta for original and revised chunks
 
Method Summary
abstract  void applyTo(List<T> target)
          Applies this delta as the patch for a given target
 boolean equals(Object obj)
           
 Chunk<T> getOriginal()
           
 Chunk<T> getRevised()
           
abstract  Delta.TYPE getType()
          Returns the type of delta
 int hashCode()
           
abstract  void restore(List<T> target)
          Cancel this delta for a given revised text.
 void setOriginal(Chunk<T> original)
           
 void setRevised(Chunk<T> revised)
           
abstract  void verify(List<T> target)
          Verifies that this delta can be used to patch the given text.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Delta

public Delta(Chunk<T> original,
             Chunk<T> revised)
Construct the delta for original and revised chunks

Parameters:
original - Chunk describing the original text. Must not be null.
revised - Chunk describing the revised text. Must not be null.
Method Detail

verify

public abstract void verify(List<T> target)
                     throws PatchFailedException
Verifies that this delta can be used to patch the given text.

Parameters:
target - the text to patch.
Throws:
PatchFailedException - if the patch cannot be applied.

applyTo

public abstract void applyTo(List<T> target)
                      throws PatchFailedException
Applies this delta as the patch for a given target

Parameters:
target - the given target
Throws:
PatchFailedException

restore

public abstract void restore(List<T> target)
Cancel this delta for a given revised text. The action is opposite to patch.

Parameters:
target - the given revised text

getType

public abstract Delta.TYPE getType()
Returns the type of delta

Returns:
the type enum

getOriginal

public Chunk<T> getOriginal()
Returns:
The Chunk describing the original text.

setOriginal

public void setOriginal(Chunk<T> original)
Parameters:
original - The Chunk describing the original text to set.

getRevised

public Chunk<T> getRevised()
Returns:
The Chunk describing the revised text.

setRevised

public void setRevised(Chunk<T> revised)
Parameters:
revised - The Chunk describing the revised text to set.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2009-2013. All Rights Reserved.