public abstract class Delta extends ToString
Diff
,
Chunk
,
modifications
27 Apr 2003 bwm
Added getOriginal() and getRevised() accessor methods Added visitor pattern accept() method
Modifier and Type | Field and Description |
---|---|
protected Chunk |
original |
protected Chunk |
revised |
Modifier | Constructor and Description |
---|---|
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.
|
Modifier and Type | Method and Description |
---|---|
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(StringBuilder s,
String EOL)
Converts this delta into its RCS style string representation.
|
void |
toString(StringBuilder 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.
|
arrayToString, arrayToString, stringToArray, toString
public static Delta newDelta(Chunk orig, Chunk rev)
orig
- the chunk in the original text.rev
- the chunk in the revised text.protected void init(Chunk orig, Chunk rev)
orig
- rev
- public abstract void verify(List<Object> target) throws PatchFailedException
target
- the text to patch.PatchFailedException
- if the patch cannot be applied.public final void patch(List<Object> target) throws PatchFailedException
target
- the text to patch.PatchFailedException
- if the patch cannot be applied.public abstract void applyTo(List<Object> target)
target
- the text to patch.PatchFailedException
- if the patch cannot be applied.public void toString(StringBuilder s)
toString
in class ToString
s
- a StringBuffer
to which the string representation will be
appended.public abstract void toRCSString(StringBuilder s, String EOL)
s
- a StringBuffer
to which the string representation will be
appended.EOL
- the string to use as line separator.public String toRCSString(String EOL)
EOL
- the string to use as line separator.public Chunk getOriginal()
public Chunk getRevised()
public abstract void accept(RevisionVisitor visitor)
See the Visitor pattern in "Design Patterns" by the GOF4.
visitor
- The visitor.Copyright © 2006–2022 Apache Software Foundation. All rights reserved.