org.apache.wicket.util.diff
Class Delta

java.lang.Object
  extended by org.apache.wicket.util.diff.ToString
      extended by org.apache.wicket.util.diff.Delta
Direct Known Subclasses:
AddDelta, ChangeDelta, DeleteDelta

public abstract class Delta
extends ToString

Holds a "delta" difference between to revisions of a text.

Version:
$Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
Author:
Juanco Anez, Brian McBride
See Also:
Diff, Chunk, modifications 27 Apr 2003 bwm Added getOriginal() and getRevised() accessor methods Added visitor pattern accept() method

Field Summary
protected  Chunk original
           
protected  Chunk revised
           
 
Constructor Summary
protected Delta()
          Creates an uninitialized delta.
protected Delta(Chunk orig, Chunk rev)
          Creates a delta object with the given chunks from the original and revised texts.
 
Method Summary
abstract  void accept(RevisionVisitor visitor)
          Accepts a visitor.
abstract  void applyTo(List<Object> target)
          Applies this delta as a patch to the given text.
 Chunk getOriginal()
          Accessor method to return the chunk representing the original sequence of items
 Chunk getRevised()
          Accessor method to return the chunk representing the updated sequence of items.
protected  void init(Chunk orig, Chunk rev)
          Initializes the delta with the given chunks from the original and revised texts.
static Delta newDelta(Chunk orig, Chunk rev)
          Returns a Delta that corresponds to the given chunks in the original and revised text respectively.
 void patch(List<Object> target)
          Applies this delta as a patch to the given text.
 String toRCSString(String EOL)
          Converts this delta into its RCS style string representation.
abstract  void toRCSString(StringBuffer s, String EOL)
          Converts this delta into its RCS style string representation.
 void toString(StringBuffer s)
          Converts this delta into its Unix diff style string representation.
abstract  void verify(List<Object> target)
          Verifies that this delta can be used to patch the given text.
 
Methods inherited from class org.apache.wicket.util.diff.ToString
arrayToString, arrayToString, stringToArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

original

protected Chunk original

revised

protected Chunk revised
Constructor Detail

Delta

protected Delta()
Creates an uninitialized delta.


Delta

protected Delta(Chunk orig,
                Chunk rev)
Creates a delta object with the given chunks from the original and revised texts.

Parameters:
orig -
rev -
Method Detail

newDelta

public static Delta newDelta(Chunk orig,
                             Chunk rev)
Returns a Delta that corresponds to the given chunks in the original and revised text respectively.

Parameters:
orig - the chunk in the original text.
rev - the chunk in the revised text.
Returns:
Delta

init

protected void init(Chunk orig,
                    Chunk rev)
Initializes the delta with the given chunks from the original and revised texts.

Parameters:
orig -
rev -

verify

public abstract void verify(List<Object> 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.

patch

public final void patch(List<Object> target)
                 throws PatchFailedException
Applies this delta as a patch to the given text.

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

applyTo

public abstract void applyTo(List<Object> target)
Applies this delta as a patch to the given text.

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

toString

public void toString(StringBuffer s)
Converts this delta into its Unix diff style string representation.

Overrides:
toString in class ToString
Parameters:
s - a StringBuffer to which the string representation will be appended.

toRCSString

public abstract void toRCSString(StringBuffer s,
                                 String EOL)
Converts this delta into its RCS style string representation.

Parameters:
s - a StringBuffer to which the string representation will be appended.
EOL - the string to use as line separator.

toRCSString

public String toRCSString(String EOL)
Converts this delta into its RCS style string representation.

Parameters:
EOL - the string to use as line separator.
Returns:
String

getOriginal

public Chunk getOriginal()
Accessor method to return the chunk representing the original sequence of items

Returns:
the original sequence

getRevised

public Chunk getRevised()
Accessor method to return the chunk representing the updated sequence of items.

Returns:
the updated sequence

accept

public abstract void accept(RevisionVisitor visitor)
Accepts a visitor.

See the Visitor pattern in "Design Patterns" by the GOF4.

Parameters:
visitor - The visitor.


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.