org.nuiton.util
Class DigestGenerator

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

public class DigestGenerator
extends Object

Helper class to provide the functionality of the digest value generation. This is an implementation of the DHASH algorithm on . TODO tchemit 2010-08-25 : This class is a nightmare ? we talk about digest mixed with dom nodes ? TODO tchemit 2010-08-25 : Should have more to explain the purpose (javadoc, author, since...) or (rename | split) this class.


Field Summary
static String md5DigestAlgorithm
          String representing the MD5 digest algorithm
static String sha1DigestAlgorithm
          String representing the SHA1 digest algorithm
static String shaDigestAlgorithm
          String representing the SHA digest algorithm
static String UNICODE_BIG_UNMARKED
           
 
Constructor Summary
DigestGenerator()
           
 
Method Summary
 boolean compareAttribute(Attr attribute, Attr comparingAttribute, String digestAlgorithm)
          Compares two Attributes for the XML equality
 boolean compareDocument(Document document, Document comparingDocument, String digestAlgorithm)
          Compares two Documents for the XML equality
 boolean compareNode(Node node, Node comparingNode, String digestAlgorithm)
          Compares two Nodes for the XML equality
 Collection getAttributesWithoutNS(Element element)
          Gets the collection of attributes which are none namespace declarations for an Element
 byte[] getDigest(Attr attribute, String digestAlgorithm)
          This method is an overloaded method for the digest generation for Attr
 byte[] getDigest(Document document, String digestAlgorithm)
          This method is an overloaded method for the digest generation for Document
 byte[] getDigest(Element element, String digestAlgorithm)
          This method is an overloaded method for the digest generation for Element
 byte[] getDigest(Node node, String digestAlgorithm)
          This method is an overloaded method for the digest generation for Node
 byte[] getDigest(ProcessingInstruction pi, String digestAlgorithm)
          This method is an overloaded method for the digest generation for ProcessingInstruction
 byte[] getDigest(Text text, String digestAlgorithm)
          This method is an overloaded method for the digest generation for Text
 String getExpandedName(Attr attribute)
          This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Attr
 String getExpandedName(Element element)
          This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Element
 String getStringRepresentation(byte[] array)
          Gets the String representation of the byte array
 Collection getValidElements(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

UNICODE_BIG_UNMARKED

public static final String UNICODE_BIG_UNMARKED
See Also:
Constant Field Values

md5DigestAlgorithm

public static final String md5DigestAlgorithm
String representing the MD5 digest algorithm

See Also:
Constant Field Values

shaDigestAlgorithm

public static final String shaDigestAlgorithm
String representing the SHA digest algorithm

See Also:
Constant Field Values

sha1DigestAlgorithm

public static final String sha1DigestAlgorithm
String representing the SHA1 digest algorithm

See Also:
Constant Field Values
Constructor Detail

DigestGenerator

public DigestGenerator()
Method Detail

getDigest

public byte[] getDigest(Document document,
                        String digestAlgorithm)
                 throws 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:
Exception

getDigest

public byte[] getDigest(Node node,
                        String digestAlgorithm)
                 throws 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:
Exception

getDigest

public byte[] getDigest(Element element,
                        String digestAlgorithm)
                 throws 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:
Exception

getDigest

public byte[] getDigest(ProcessingInstruction pi,
                        String digestAlgorithm)
                 throws 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:
Exception

getDigest

public byte[] getDigest(Attr attribute,
                        String digestAlgorithm)
                 throws 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:
Exception

getDigest

public byte[] getDigest(Text text,
                        String digestAlgorithm)
                 throws 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:
Exception

getExpandedName

public String getExpandedName(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 String getExpandedName(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 Collection getAttributesWithoutNS(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 Collection getValidElements(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 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(Node node,
                           Node comparingNode,
                           String digestAlgorithm)
                    throws Exception
Compares two Nodes for the XML equality

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

compareDocument

public boolean compareDocument(Document document,
                               Document comparingDocument,
                               String digestAlgorithm)
                        throws Exception
Compares two Documents for the XML equality

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

compareAttribute

public boolean compareAttribute(Attr attribute,
                                Attr comparingAttribute,
                                String digestAlgorithm)
                         throws Exception
Compares two Attributes for the XML equality

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


Copyright © 2004-2010 CodeLutin. All Rights Reserved.