com.topologi.diffx.algorithm
Class GuanoAlgorithm

java.lang.Object
  extended by com.topologi.diffx.algorithm.GuanoAlgorithm
All Implemented Interfaces:
DiffXAlgorithm

public final class GuanoAlgorithm
extends Object
implements DiffXAlgorithm

A matrix-based algorithm using weighted events which produces correct results, but may require minor adjustments during formatting.

Implementation note: this algorithm effectively detects the correct changes in the sequences, but will not necessarily return events that can be serialised as well-formed XML as they stand.

Known problem in this implementation: elements that contain themselves tend to generate events that are harder to serialise as XML.

This class is said 'fit' because it will adapt the matrix to the sequences that it is being given in order to improve performance.

Note: The name of this class comes from a contracted version of the features of this algorithm, as explained below:

Version:
11 May 2010
Author:
Christophe Lauret

Constructor Summary
GuanoAlgorithm(EventSequence seq0, EventSequence seq1)
          Creates a new DiffXAlgorithmBase.
 
Method Summary
 EventSequence getFirstSequence()
          Returns the first sequence used for the diff-x comparison.
 EventSequence getSecondSequence()
          Returns the second sequence used for the diff-x comparison.
 int length()
          Returns the length of the longest common sequence.
 void process(DiffXFormatter formatter)
          Writes the diff sequence using the specified formatter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GuanoAlgorithm

public GuanoAlgorithm(EventSequence seq0,
                      EventSequence seq1)
Creates a new DiffXAlgorithmBase.

Parameters:
seq0 - The first sequence to compare.
seq1 - The second sequence to compare.
Method Detail

length

public int length()
Returns the length of the longest common sequence.

Specified by:
length in interface DiffXAlgorithm
Returns:
the length of the longest common sequence.

process

public void process(DiffXFormatter formatter)
             throws IOException
Writes the diff sequence using the specified formatter.

Specified by:
process in interface DiffXAlgorithm
Parameters:
formatter - The formatter that will handle the output.
Throws:
IOException - If thrown by the formatter.

getFirstSequence

public final EventSequence getFirstSequence()
Description copied from interface: DiffXAlgorithm
Returns the first sequence used for the diff-x comparison.

Specified by:
getFirstSequence in interface DiffXAlgorithm
Returns:
the first sequence used for the diff-x comparison.
See Also:
DiffXAlgorithm.getFirstSequence()

getSecondSequence

public final EventSequence getSecondSequence()
Description copied from interface: DiffXAlgorithm
Returns the second sequence used for the diff-x comparison.

Specified by:
getSecondSequence in interface DiffXAlgorithm
Returns:
the second sequence used for the diff-x comparison.
See Also:
DiffXAlgorithm.getSecondSequence()