org.vmguys.vmtools.utils
Class JdomDifferenceFinder

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

public class JdomDifferenceFinder
extends java.lang.Object

This class finds the differences between two JDOM trees, and returns a JDOM tree containing the operations needed to convert one tree to the other. It uses the methods in DifferenceFinder2 to do most of the work.


Constructor Summary
JdomDifferenceFinder()
          Constructs a JdomDifferenceFinder using the namespace of NO_NAMESPACE.
JdomDifferenceFinder(org.jdom.Namespace namespace)
          Constructs a JdomDifferenceFinder with the specified namespace.
JdomDifferenceFinder(org.jdom.Namespace namespace, boolean discardWhitespace)
          Constructs a JdomDifferencefinder with the specified namespace and setting for discardWhitespace.
JdomDifferenceFinder(org.jdom.Namespace namespace, boolean discardWhitespace, boolean addComments)
          Constructs a JdomDifferenceFinder with the specified namespace, setting for discardWhitespace, and setting for addComments.
 
Method Summary
 void findDifferences(org.jdom.Element tree1, org.jdom.Element tree2, org.jdom.Element diffRoot)
          This method finds the minimal differences between two JDOM trees and returns the operations needed to convert one to the other as a JDOM tree.
 void setAllowRename(boolean flag)
          This method sets property that indicates whether the difference finder should include operations that rename a node.
 void setProgressReporter(ProgressReporter pr)
          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

JdomDifferenceFinder

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

JdomDifferenceFinder

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

JdomDifferenceFinder

public JdomDifferenceFinder(org.jdom.Namespace namespace,
                            boolean discardWhitespace)
Constructs a JdomDifferencefinder 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.

JdomDifferenceFinder

public JdomDifferenceFinder(org.jdom.Namespace namespace,
                            boolean discardWhitespace,
                            boolean addComments)
Constructs a JdomDifferenceFinder 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 void findDifferences(org.jdom.Element tree1,
                            org.jdom.Element tree2,
                            org.jdom.Element diffRoot)
                     throws org.jdom.JDOMException
This method finds the minimal differences between two JDOM trees and returns the operations needed to convert one to the other as a JDOM tree. It takes the root Elements of the trees as parameters, and also the root Element for the tree of differences. The tree is built under the caller's root.

setProgressReporter

public void setProgressReporter(ProgressReporter pr)
This method sets the progress reporter. When findDifferences 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.

setAllowRename

public void setAllowRename(boolean flag)
This method sets property that indicates whether the difference finder should include operations that rename a node. Some applications have difficulty with that operation.


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