org.springframework.shell.support.util
Class XmlRoundTripUtils

java.lang.Object
  extended by org.springframework.shell.support.util.XmlRoundTripUtils

public final class XmlRoundTripUtils
extends Object

Utilities related to round-tripping XML documents

Since:
1.1

Method Summary
static String calculateUniqueKeyFor(Element element)
          Create a base 64 encoded SHA1 hash key for a given XML element.
static boolean compareDocuments(Document original, Document proposed)
          This method will compare the original document with the proposed document and return true if adjustments to the original document were necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calculateUniqueKeyFor

public static String calculateUniqueKeyFor(Element element)
Create a base 64 encoded SHA1 hash key for a given XML element. The key is based on the element name, the attribute names and their values. Child elements are ignored. Attributes named 'z' are not concluded since they contain the hash key itself.

Parameters:
element - The element to create the base 64 encoded hash key for
Returns:
the unique key

compareDocuments

public static boolean compareDocuments(Document original,
                                       Document proposed)
This method will compare the original document with the proposed document and return true if adjustments to the original document were necessary. Adjustments are only made if new elements or attributes are proposed. Changes to the order of attributes or elements in the original document will not result in an adjustment.

Parameters:
original - document as read from the file system
proposed - document as determined by the JspViewManager
Returns:
true if the document was adjusted, otherwise false