org.vmguys.vmtools.utils
Class DifferenceFinder2

java.lang.Object
  |
  +--org.vmguys.vmtools.utils.DifferenceFinder2

public class DifferenceFinder2
extends java.lang.Object

This class contains methods to compare two JDOM trees and find the differences. It computes the "cost" to convert one tree to the other, and a set of operations to perform the conversion.

The algorithm used is described in Section 3.1 of Tree-to-tree Correction for Document Trees, Technical Report 95-327. The report can be found at

ftp://ftp.qucis.queensu.ca/pub/reports/1995-372.ps


Constructor Summary
DifferenceFinder2()
          Constructs a DifferenceFinder2 using the namespace of NO_NAMESPACE.
DifferenceFinder2(org.jdom.Namespace namespace)
          Constructs a DifferenceFinder2 with the specified namespace.
DifferenceFinder2(org.jdom.Namespace namespace, boolean discardWhitespace)
          Constructs a Differencefinder with the specified namespace and setting for discardWhitespace.
DifferenceFinder2(org.jdom.Namespace namespace, boolean discardWhitespace, boolean addComments)
          Constructs a DifferenceFinder2 with the specified namespace, setting for discardWhitespace, and setting for addComments.
 
Method Summary
 CostOps findDifferences(DiffElement root1, DiffElement root2)
          Determines what needs to be done to convert the tree rooted at n1 into the tree rooted at n2.
 CostOps findDifferences(org.jdom.Element root1, org.jdom.Element root2)
          Same as the other version of findDifferences except for the types of the parameters.
 ProgressReporter getProgressReporter()
          Returns the current ProgressReporter, or null if there isn't one.
 boolean isAddComments()
          Getter for property addComments.
 boolean isAllowRename()
          Getter for property allowRename.
 boolean isDiscardWhitespace()
          Getter for property discardWhitespace.
 void setAddComments(boolean addComments)
          Setter for property addComments.
 void setAllowRename(boolean allowRename)
          Setter for property allowRename.
 void setDiscardWhitespace(boolean discardWhitespace)
          Setter for property discardWhitespace.
 void setProgressReporter(ProgressReporter progressReporter)
          This method sets the progress reporter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DifferenceFinder2

public DifferenceFinder2()
Constructs a DifferenceFinder2 using the namespace of NO_NAMESPACE. The discardWhitespace property will be set true, and the addComments property will be set false.

DifferenceFinder2

public DifferenceFinder2(org.jdom.Namespace namespace)
Constructs a DifferenceFinder2 with the specified namespace. The discardWhitespace property will be set true, and the addComments property will be set false.

DifferenceFinder2

public DifferenceFinder2(org.jdom.Namespace namespace,
                         boolean discardWhitespace)
Constructs a Differencefinder with the specified namespace and setting for discardWhitespace. The addComments property will be set false. If discardWhitespace is true, any text content that contains only whitespace will be discarded, it will not be considered during the comparisons, and it will not appear in the output.

DifferenceFinder2

public DifferenceFinder2(org.jdom.Namespace namespace,
                         boolean discardWhitespace,
                         boolean addComments)
Constructs a DifferenceFinder2 with the specified namespace, setting for discardWhitespace, and setting for addComments. If addComments is true, comments will be added to the output indicating the reason for each operation. This is most useful for debugging or tracing the operations.
Method Detail

findDifferences

public CostOps findDifferences(org.jdom.Element root1,
                               org.jdom.Element root2)
                        throws org.jdom.JDOMException
Same as the other version of findDifferences except for the types of the parameters. This just casts the Elements to DiffElements and calls the other version. It will throw an exception if the Elements can't be recast.
See Also:
findDifferences(DiffElement, DiffElement)

findDifferences

public CostOps findDifferences(DiffElement root1,
                               DiffElement root2)
                        throws org.jdom.JDOMException

Determines what needs to be done to convert the tree rooted at n1 into the tree rooted at n2. Once the minimum cost set of operations has been determined, it is returned to the caller as a CostOps.


isDiscardWhitespace

public boolean isDiscardWhitespace()
Getter for property discardWhitespace.
Returns:
Value of property discardWhitespace.

setDiscardWhitespace

public void setDiscardWhitespace(boolean discardWhitespace)
Setter for property discardWhitespace.
Parameters:
discardWhitespace - New value of property discardWhitespace.

isAddComments

public boolean isAddComments()
Getter for property addComments.
Returns:
Value of property addComments.

setAddComments

public void setAddComments(boolean addComments)
Setter for property addComments.
Parameters:
addComments - New value of property addComments.

getProgressReporter

public ProgressReporter getProgressReporter()
Returns the current ProgressReporter, or null if there isn't one.

setProgressReporter

public void setProgressReporter(ProgressReporter progressReporter)
This method sets the progress reporter. When generateUpdate is called, it will call the progress reporter with updates on the percentage of the operation that has been performed. This can be useful during lengthy operations to provide feedback to the user.

isAllowRename

public boolean isAllowRename()
Getter for property allowRename.
Returns:
Value of property allowRename.

setAllowRename

public void setAllowRename(boolean allowRename)
Setter for property allowRename.
Parameters:
allowRename - New value of property allowRename.


Copyright © 2001 VM Systems, Inc. All Rights Reserved.