org.nuiton.util
Class DigestGenerator

java.lang.Object
  extended by org.nuiton.util.DigestGenerator

public class DigestGenerator
extends java.lang.Object

Helper class to provide the functionality of the digest value generation. This is an implementation of the DHASH algorithm on .


Field Summary
static java.lang.String md5DigestAlgorithm
          String representing the MD5 digest algorithm
static java.lang.String sha1DigestAlgorithm
          String representing the SHA1 digest algorithm
static java.lang.String shaDigestAlgorithm
          String representing the SHA digest algorithm
 
Constructor Summary
DigestGenerator()
           
 
Method Summary
 boolean compareAttribute(org.w3c.dom.Attr attribute, org.w3c.dom.Attr comparingAttribute, java.lang.String digestAlgorithm)
          Compares two Attributes for the XML equality
 boolean compareDocument(org.w3c.dom.Document document, org.w3c.dom.Document comparingDocument, java.lang.String digestAlgorithm)
          Compares two Documents for the XML equality
 boolean compareNode(org.w3c.dom.Node node, org.w3c.dom.Node comparingNode, java.lang.String digestAlgorithm)
          Compares two Nodes for the XML equality
 java.util.Collection getAttributesWithoutNS(org.w3c.dom.Element element)
          Gets the collection of attributes which are none namespace declarations for an Element
 byte[] getDigest(org.w3c.dom.Attr attribute, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for Attr
 byte[] getDigest(org.w3c.dom.Document document, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for Document
 byte[] getDigest(org.w3c.dom.Element element, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for Element
 byte[] getDigest(org.w3c.dom.Node node, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for Node
 byte[] getDigest(org.w3c.dom.ProcessingInstruction pi, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for ProcessingInstruction
 byte[] getDigest(org.w3c.dom.Text text, java.lang.String digestAlgorithm)
          This method is an overloaded method for the digest generation for Text
 java.lang.String getExpandedName(org.w3c.dom.Attr attribute)
          This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Attr
 java.lang.String getExpandedName(org.w3c.dom.Element element)
          This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Element
 java.lang.String getStringRepresentation(byte[] array)
          Gets the String representation of the byte array
 java.util.Collection getValidElements(org.w3c.dom.Document document)
          Gets the valid element collection of an Document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

md5DigestAlgorithm

public static final java.lang.String md5DigestAlgorithm
String representing the MD5 digest algorithm

See Also:
Constant Field Values

shaDigestAlgorithm

public static final java.lang.String shaDigestAlgorithm
String representing the SHA digest algorithm

See Also:
Constant Field Values

sha1DigestAlgorithm

public static final java.lang.String sha1DigestAlgorithm
String representing the SHA1 digest algorithm

See Also:
Constant Field Values
Constructor Detail

DigestGenerator

public DigestGenerator()
Method Detail

getDigest

public byte[] getDigest(org.w3c.dom.Document document,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for Document

Parameters:
document -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest
Throws:
java.lang.Exception

getDigest

public byte[] getDigest(org.w3c.dom.Node node,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for Node

Parameters:
node -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest value
Throws:
java.lang.Exception

getDigest

public byte[] getDigest(org.w3c.dom.Element element,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for Element

Parameters:
element -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest value
Throws:
java.lang.Exception

getDigest

public byte[] getDigest(org.w3c.dom.ProcessingInstruction pi,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for ProcessingInstruction

Parameters:
pi -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest value
Throws:
java.lang.Exception

getDigest

public byte[] getDigest(org.w3c.dom.Attr attribute,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for Attr

Parameters:
attribute -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest value
Throws:
java.lang.Exception

getDigest

public byte[] getDigest(org.w3c.dom.Text text,
                        java.lang.String digestAlgorithm)
                 throws java.lang.Exception
This method is an overloaded method for the digest generation for Text

Parameters:
text -
digestAlgorithm -
Returns:
Returns a byte array representing the calculated digest value
Throws:
java.lang.Exception

getExpandedName

public java.lang.String getExpandedName(org.w3c.dom.Element element)
This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Element

Parameters:
element -
Returns:
Returns the expanded name of Element

getExpandedName

public java.lang.String getExpandedName(org.w3c.dom.Attr attribute)
This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Attr

Parameters:
attribute -
Returns:
Returns the expanded name of the Attr

getAttributesWithoutNS

public java.util.Collection getAttributesWithoutNS(org.w3c.dom.Element element)
Gets the collection of attributes which are none namespace declarations for an Element

Parameters:
element -
Returns:
Returns the collection of attributes which are none namespace declarations

getValidElements

public java.util.Collection getValidElements(org.w3c.dom.Document document)
Gets the valid element collection of an Document. Element and ProcessingInstruction only

Parameters:
document -
Returns:
Returns a collection of ProcessingInstructions and Elements

getStringRepresentation

public java.lang.String getStringRepresentation(byte[] array)
Gets the String representation of the byte array

Parameters:
array -
Returns:
Returns the String of the byte

compareNode

public boolean compareNode(org.w3c.dom.Node node,
                           org.w3c.dom.Node comparingNode,
                           java.lang.String digestAlgorithm)
                    throws java.lang.Exception
Compares two Nodes for the XML equality

Parameters:
node -
comparingNode -
digestAlgorithm -
Returns:
Returns true if the Node XML contents are equal
Throws:
java.lang.Exception

compareDocument

public boolean compareDocument(org.w3c.dom.Document document,
                               org.w3c.dom.Document comparingDocument,
                               java.lang.String digestAlgorithm)
                        throws java.lang.Exception
Compares two Documents for the XML equality

Parameters:
document -
comparingDocument -
digestAlgorithm -
Returns:
Returns true if the Document XML content are equal
Throws:
java.lang.Exception

compareAttribute

public boolean compareAttribute(org.w3c.dom.Attr attribute,
                                org.w3c.dom.Attr comparingAttribute,
                                java.lang.String digestAlgorithm)
                         throws java.lang.Exception
Compares two Attributes for the XML equality

Parameters:
attribute -
comparingAttribute -
digestAlgorithm -
Returns:
Returns true if the Document XML content are equal
Throws:
java.lang.Exception


Copyright © 2004-2010 CodeLutin. All Rights Reserved.