Class DigestGenerator

java.lang.Object
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 . 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

    Fields 
    Modifier and Type Field Description
    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
    static java.lang.String UNICODE_BIG_UNMARKED  
  • Constructor Summary

    Constructors 
    Constructor Description
    DigestGenerator()  
  • Method Summary

    Modifier and Type Method Description
    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 Details

  • Constructor Details

  • Method Details

    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest value
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest value
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest value
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest value
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns a byte array representing the calculated digest value
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      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 - FIXME
      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 - FIXME
      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 - FIXME
      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 - FIXME
      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 - FIXME
      comparingNode - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns true if the Node XML contents are equal
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      comparingDocument - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns true if the Document XML content are equal
      Throws:
      java.lang.Exception - FIXME
    • 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 - FIXME
      comparingAttribute - FIXME
      digestAlgorithm - FIXME
      Returns:
      Returns true if the Document XML content are equal
      Throws:
      java.lang.Exception - FIXME