Package org.nuiton.util
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.Stringmd5DigestAlgorithmString representing the MD5 digest algorithmstatic java.lang.Stringsha1DigestAlgorithmString representing the SHA1 digest algorithmstatic java.lang.StringshaDigestAlgorithmString representing the SHA digest algorithmstatic java.lang.StringUNICODE_BIG_UNMARKED -
Constructor Summary
Constructors Constructor Description DigestGenerator() -
Method Summary
Modifier and Type Method Description booleancompareAttribute(org.w3c.dom.Attr attribute, org.w3c.dom.Attr comparingAttribute, java.lang.String digestAlgorithm)Compares two Attributes for the XML equalitybooleancompareDocument(org.w3c.dom.Document document, org.w3c.dom.Document comparingDocument, java.lang.String digestAlgorithm)Compares two Documents for the XML equalitybooleancompareNode(org.w3c.dom.Node node, org.w3c.dom.Node comparingNode, java.lang.String digestAlgorithm)Compares two Nodes for the XML equalityjava.util.CollectiongetAttributesWithoutNS(org.w3c.dom.Element element)Gets the collection of attributes which are none namespace declarations for an Elementbyte[]getDigest(org.w3c.dom.Attr attribute, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for Attrbyte[]getDigest(org.w3c.dom.Document document, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for Documentbyte[]getDigest(org.w3c.dom.Element element, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for Elementbyte[]getDigest(org.w3c.dom.Node node, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for Nodebyte[]getDigest(org.w3c.dom.ProcessingInstruction pi, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for ProcessingInstructionbyte[]getDigest(org.w3c.dom.Text text, java.lang.String digestAlgorithm)This method is an overloaded method for the digest generation for Textjava.lang.StringgetExpandedName(org.w3c.dom.Attr attribute)This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Attrjava.lang.StringgetExpandedName(org.w3c.dom.Element element)This method is an overloaded method for getting the expanded name namespaceURI followed by the local name for Elementjava.lang.StringgetStringRepresentation(byte[] array)Gets the String representation of the byte arrayjava.util.CollectiongetValidElements(org.w3c.dom.Document document)Gets the valid element collection of an Document.
-
Field Details
-
UNICODE_BIG_UNMARKED
public static final java.lang.String UNICODE_BIG_UNMARKED- See Also:
- Constant Field Values
-
md5DigestAlgorithm
public static final java.lang.String md5DigestAlgorithmString representing the MD5 digest algorithm- See Also:
- Constant Field Values
-
shaDigestAlgorithm
public static final java.lang.String shaDigestAlgorithmString representing the SHA digest algorithm- See Also:
- Constant Field Values
-
sha1DigestAlgorithm
public static final java.lang.String sha1DigestAlgorithmString representing the SHA1 digest algorithm- See Also:
- Constant Field Values
-
-
Constructor Details
-
DigestGenerator
public DigestGenerator()
-
-
Method Details
-
getDigest
public byte[] getDigest(org.w3c.dom.Document document, java.lang.String digestAlgorithm) throws java.lang.ExceptionThis method is an overloaded method for the digest generation for Document- Parameters:
document- FIXMEdigestAlgorithm- 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.ExceptionThis method is an overloaded method for the digest generation for Node- Parameters:
node- FIXMEdigestAlgorithm- 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.ExceptionThis method is an overloaded method for the digest generation for Element- Parameters:
element- FIXMEdigestAlgorithm- 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.ExceptionThis method is an overloaded method for the digest generation for ProcessingInstruction- Parameters:
pi- FIXMEdigestAlgorithm- 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.ExceptionThis method is an overloaded method for the digest generation for Attr- Parameters:
attribute- FIXMEdigestAlgorithm- 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.ExceptionThis method is an overloaded method for the digest generation for Text- Parameters:
text- FIXMEdigestAlgorithm- 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.ExceptionCompares two Nodes for the XML equality- Parameters:
node- FIXMEcomparingNode- FIXMEdigestAlgorithm- 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.ExceptionCompares two Documents for the XML equality- Parameters:
document- FIXMEcomparingDocument- FIXMEdigestAlgorithm- 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.ExceptionCompares two Attributes for the XML equality- Parameters:
attribute- FIXMEcomparingAttribute- FIXMEdigestAlgorithm- FIXME- Returns:
- Returns true if the Document XML content are equal
- Throws:
java.lang.Exception- FIXME
-