public class Diff extends ToString
Object
.
Within this library, the word text means a unit of information subject to version control.
Text is represented as Object[]
because
the diff engine is capable of handling more than plain ascci. In fact,
arrays of any type that implements
hashCode()
and
equals()
correctly can be subject to differencing using this
library.
This library provides a framework in which different differencing algorithms may be used. If no algorithm is specififed, a default algorithm is used.
Delta
,
modifications:
27 Apr 2003 bwm
Added some comments whilst trying to figure out the algorithm
03 May 2003 bwm
Factored out the algorithm implementation into a separate difference
algorithm class to allow pluggable algorithms.
Modifier and Type | Field and Description |
---|---|
protected DiffAlgorithm |
algorithm
The differencing algorithm to use.
|
static java.lang.String |
NL
The standard line separator.
|
protected java.lang.Object[] |
orig
The original sequence.
|
static java.lang.String |
RCS_EOL
The line separator to use in RCS format output.
|
Constructor and Description |
---|
Diff(java.lang.Object[] original)
Create a differencing object using the default algorithm
|
Diff(java.lang.Object[] original,
DiffAlgorithm algorithm)
Create a differencing object using the given algorithm
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
arrayToString(java.lang.Object[] o)
Converts an array of
Object to a string
using Diff.NL
as the line separator. |
static boolean |
compare(java.lang.Object[] orig,
java.lang.Object[] rev)
Compares the two input sequences.
|
protected DiffAlgorithm |
defaultAlgorithm() |
Revision |
diff(java.lang.Object[] rev)
compute the difference between the original and a revision.
|
static Revision |
diff(java.lang.Object[] orig,
java.lang.Object[] rev)
compute the difference between an original and a revision.
|
static Revision |
diff(java.lang.Object[] orig,
java.lang.Object[] rev,
DiffAlgorithm algorithm)
compute the difference between an original and a revision.
|
static java.lang.Object[] |
editAll(java.lang.Object[] text)
Edits all of the items in the input sequence.
|
static java.lang.Object[] |
randomEdit(java.lang.Object[] text)
Performs random edits on the input sequence.
|
static java.lang.Object[] |
randomEdit(java.lang.Object[] text,
long seed)
Performs random edits on the input sequence.
|
static java.lang.Object[] |
randomSequence(int size)
Generate a random sequence of the given size.
|
static java.lang.Object[] |
randomSequence(int size,
long seed)
Generate a random sequence of the given size.
|
static java.lang.Object[] |
shuffle(java.lang.Object[] text)
Shuffles around the items in the input sequence.
|
static java.lang.Object[] |
shuffle(java.lang.Object[] text,
long seed)
Shuffles around the items in the input sequence.
|
arrayToString, stringToArray, stringToArraya, stringToArrayold, toString, toString
public static final java.lang.String NL
public static final java.lang.String RCS_EOL
protected final java.lang.Object[] orig
protected DiffAlgorithm algorithm
public Diff(java.lang.Object[] original)
the
- original text that will be comparedpublic Diff(java.lang.Object[] original, DiffAlgorithm algorithm)
o
- the original text which will be compared againstalgorithm
- the difference algorithm to use.protected DiffAlgorithm defaultAlgorithm()
public static Revision diff(java.lang.Object[] orig, java.lang.Object[] rev) throws DifferentiationFailedException
orig
- the originalrev
- the revision to compare with the original.DifferentiationFailedException
public static Revision diff(java.lang.Object[] orig, java.lang.Object[] rev, DiffAlgorithm algorithm) throws DifferentiationFailedException
orig
- the originalrev
- the revision to compare with the original.algorithm
- the difference algorithm to useDifferentiationFailedException
public Revision diff(java.lang.Object[] rev) throws DifferentiationFailedException
rev
- the revision to compare with the original.DifferentiationFailedException
public static boolean compare(java.lang.Object[] orig, java.lang.Object[] rev)
orig
- The original sequence.rev
- The revised sequence.public static java.lang.String arrayToString(java.lang.Object[] o)
Object
to a string
using Diff.NL
as the line separator.o
- the array of objects.public static java.lang.Object[] editAll(java.lang.Object[] text)
text
- The input sequence.public static java.lang.Object[] randomEdit(java.lang.Object[] text)
text
- The input sequence.public static java.lang.Object[] randomEdit(java.lang.Object[] text, long seed)
text
- The input sequence.seed
- A seed value for the randomizer.public static java.lang.Object[] shuffle(java.lang.Object[] text)
text
- The input sequence.public static java.lang.Object[] shuffle(java.lang.Object[] text, long seed)
text
- The input sequence.seed
- A seed value for randomizing the suffle.public static java.lang.Object[] randomSequence(int size)
The
- size of the sequence to generate.public static java.lang.Object[] randomSequence(int size, long seed)
The
- size of the sequence to generate.seed
- A seed value for randomizing the generation.Copyright 2002 the Apache Software Foundation
Copyright ? 1999-2001 Juancarlo A?ez, Caracas, Venezuela.
All rights reserved
. http://www.suigeneris.org/jrcs