Contents | Package | Class | Tree | Deprecated | Index | Help XML for Java 1.0.4
PREV | NEXT SHOW LISTS | HIDE LISTS

Class com.ibm.xml.parser.MakeDigestVisitor

java.lang.Object
    |
    +----com.ibm.xml.parser.NOOPVisitor
            |
            +----com.ibm.xml.parser.MakeDigestVisitor

public class MakeDigestVisitor
extends NOOPVisitor
implements Visitor
MakeDigestVisitor implements the Visitor interface in the visitor design pattern for the purpose of calculating and storing a digest on the various DOM- and XML4J-defined Nodes as the document object tree is traversed. Digests are calculated usng the message digest passed on the constructor.

Digests can be made for the following Node types:

The following sample code uses the MakeDigestVisitor on a hierarchy of nodes:


 MakeDigestVisitor makeDigestVisitor = new MakeDigestVisitor(this.getFactory().createMessageDigest());
 new NonRecursivePreorderTreeTraversal(makeDigestVisitor).traverse(this);

 

Version:
Revision: 45 1.3 src/com/ibm/xml/parser/MakeDigestVisitor.java, xml4jsrc, xml4j-jtcsv, xml4j_1_0_4
See Also:
Visitor, NOOPVisitor, TreeTraversal, NonRecursivePreorderTreeTraversal

Field Summary
java.security.MessageDigest  messageDigest
 
 

Constructor Summary
 MakeDigestVisitor(java.security.MessageDigest messageDigest)
Constructor.
 

Method Summary
void  visitAttributePre(TXAttribute attribute)
Calculates and sets a digest for the specified attribute.
void  visitCommentPre(TXComment comment)
Calculates and sets a digest for the specified comment.
void  visitElementPost(TXElement element)
Calculates and sets a digest for the specified element.
void  visitElementPre(TXElement element)
If the specified element already has a calculated digest, throw an exception to avoid unnecessary traversal of children.
void  visitPIPre(TXPI pi)
Calculates and sets a digest for the specified pi.
void  visitTextPre(TXText text)
Calculates and sets a digest for the specified text.
 
Methods inherited from class com.ibm.xml.parser.NOOPVisitor
 visitAttDefPost, visitAttDefPre, visitAttlistPost, visitAttlistPre, visitAttributePost, visitAttributePre, visitCommentPost, visitCommentPre, visitDocumentPost, visitDocumentPre, visitDTDPost, visitDTDPre, visitElementDeclPost, visitElementDeclPre, visitElementPost, visitElementPre, visitEntityPost, visitEntityPre, visitGeneralReferencePost, visitGeneralReferencePre, visitNotationPost, visitNotationPre, visitPIPost, visitPIPre, visitPseudoNodePost, visitPseudoNodePre, visitTextPost, visitTextPre
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageDigest

protected java.security.MessageDigest messageDigest
Constructor Detail

MakeDigestVisitor

public MakeDigestVisitor(java.security.MessageDigest messageDigest)
Constructor.
Parameters:
messageDigest - Message digest instance to use when visitting.
See Also:
createMessageDigest
Method Detail

visitElementPre

public void visitElementPre(TXElement element) throws ToNextSiblingTraversalException
If the specified element already has a calculated digest, throw an exception to avoid unnecessary traversal of children.
Implements:
visitElementPre in interface Visitor
Parameters:
element - Node to calculate and set a digest.
Throws:
ToNextSiblingTraversalException - Thrown if this Node already has a digest.
Overrides:
visitElementPre in class NOOPVisitor
See Also:
TXElement, visitElementPost

visitElementPost

public void visitElementPost(TXElement element) throws LibraryException
Calculates and sets a digest for the specified element.

A digest of a TXElement Node consists of its:

Implements:
visitElementPost in interface Visitor
Parameters:
element - Node to calculate and set a digest.
Throws:
LibraryException - Thrown if this Node can not be visitted because of a problem in calculating the digest. Often, this is because the message digest specified on the constructor is invalid, the JVM does not support UnicodeBigUnmarked encoding, or the JVM does not have the required security providers for the message digest.
Overrides:
visitElementPost in class NOOPVisitor
See Also:
TXElement, visitElementPre

visitAttributePre

public void visitAttributePre(TXAttribute attribute) throws LibraryException
Calculates and sets a digest for the specified attribute.

A digest of a TXAttribute Node consists of its Node type, its name, and its value.

Note that TXAttribute Nodes are not parsed into the document object hierarchy by the XML4J parser; attributes exist as part of a TXElement Node.

Implements:
visitAttributePre in interface Visitor
Parameters:
attribute - Node to calculate and set a digest.
Throws:
LibraryException - Thrown if this Node can not be visitted because of a problem in calculating the digest. Often, this is because the message digest specified on the constructor is invalid, the JVM does not support UnicodeBigUnmarked encoding, or the JVM does not have the required security providers for the message digest.
Overrides:
visitAttributePre in class NOOPVisitor
See Also:
TXAttribute

visitPIPre

public void visitPIPre(TXPI pi) throws LibraryException
Calculates and sets a digest for the specified pi.

A digest of a TXPI Node consists of its Node type, its name, and its data.

Implements:
visitPIPre in interface Visitor
Parameters:
pi - Node to calculate and set a digest.
Throws:
LibraryException - Thrown if this Node can not be visitted because of a problem in calculating the digest. Often, this is because the message digest specified on the constructor is invalid, the JVM does not support UnicodeBigUnmarked encoding, or the JVM does not have the required security providers for the message digest.
Overrides:
visitPIPre in class NOOPVisitor
See Also:
TXPI

visitCommentPre

public void visitCommentPre(TXComment comment) throws LibraryException
Calculates and sets a digest for the specified comment.

A digest of a TXComment Node consists of its Node type and its data.

Implements:
visitCommentPre in interface Visitor
Parameters:
comment - Node to calculate and set a digest.
Throws:
LibraryException - Thrown if this Node can not be visitted because of a problem in calculating the digest. Often, this is because the message digest specified on the constructor is invalid, the JVM does not support UnicodeBigUnmarked encoding, or the JVM does not have the required security providers for the message digest.
Overrides:
visitCommentPre in class NOOPVisitor
See Also:
TXComment

visitTextPre

public void visitTextPre(TXText text) throws LibraryException
Calculates and sets a digest for the specified text.

A digest of a TXText Node consists of its Node type and its data.

Implements:
visitTextPre in interface Visitor
Parameters:
text - Node to calculate and set a digest.
Throws:
LibraryException - Thrown if this Node can not be visitted because of a problem in calculating the digest. Often, this is because the message digest specified on the constructor is invalid, the JVM does not support UnicodeBigUnmarked encoding, or the JVM does not have the required security providers for the message digest.
Overrides:
visitTextPre in class NOOPVisitor
See Also:
TXText

Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS