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

Class com.ibm.xml.parser.ToXMLStringVisitor

java.lang.Object
    |
    +----com.ibm.xml.parser.NOOPVisitor
            |
            +----com.ibm.xml.parser.ToXMLStringVisitor
Subclasses:
FormatPrintVisitor, HTMLPrintVisitor

public class ToXMLStringVisitor
extends NOOPVisitor
implements Visitor
ToXMLStringVisitor implements the Visitor interface in the visitor design pattern for the purpose of a toString operation on the various DOM- and XML4J-defined Nodes as the document object tree is traversed. The returned string will be in XML format.

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


 Visitor visitor = new ToXMLStringVisitor(stringWriter, encoding);
 new NonRecursivePreorderTreeTraversal(visitor).traverse(this);

 

Version:
Revision: %M% %I% %W% %Q%
See Also:
Visitor, NOOPVisitor, TreeTraversal, NonRecursivePreorderTreeTraversal

Field Summary
java.lang.String  encoding
 
java.io.Writer  writer
 
 

Constructor Summary
 ToXMLStringVisitor(java.io.Writer writer, java.lang.String encoding)
Constructor for customized encoding.
 ToXMLStringVisitor(java.io.Writer writer)
Constructor for default encoding.
 

Method Summary
void  visitAttDefPre(AttDef attDef)
Creates a string representation of the specified attDef Node in XML format.
void  visitAttlistPre(Attlist attlist)
Creates a string representation of the specified attlist Node and any associated AttDefs in XML format.
void  visitAttributePre(TXAttribute attribute)
Creates a string representation of the specified attribute Node in XML format.
void  visitCommentPre(TXComment comment)
Creates a string representation of the specified comment Node in XML format.
void  visitDocumentPost(TXDocument document)
Flush the writer.
void  visitDocumentPre(TXDocument document)
Creates a string representation of the specified document Node in XML format.
void  visitDTDPre(DTD dtd)
Creates a string representation of the specified dtd Node, and optionally its internal DTD subset, in XML format.
void  visitElementDeclPre(ElementDecl elementDecl)
Creates a string representation of the specified elementDecl Node in XML format.
void  visitElementPost(TXElement element)
Creates a string representation of the end of the specified element Node in XML format.
void  visitElementPre(TXElement element)
Creates a string representation of the start of the specified element Node and its associated attributes in XML format.
void  visitEntityPre(Entity entity)
Creates a string representation of the specified entity Node in XML format.
void  visitGeneralReferencePre(GeneralReference generalReference)
Creates a string representation of the specified generalReference Node in XML format.
void  visitNotationPre(TXNotation notation)
Creates a string representation of the specified notation Node in XML format.
void  visitPIPre(TXPI pi)
Creates a string representation of the specified pi Node in XML format.
void  visitPseudoNodePre(PseudoNode pseudoNode)
Creates a string representation of the specified pseudoNode Node in XML format.
void  visitTextPre(TXText text)
Creates a string representation of the specified text Node in XML format.
 
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

writer

protected java.io.Writer writer

encoding

protected java.lang.String encoding
Constructor Detail

ToXMLStringVisitor

public ToXMLStringVisitor(java.io.Writer writer,
                          java.lang.String encoding)
Constructor for customized encoding.
Parameters:
writer - The character output stream to use.
encoding - Java character encoding in use by writer.

ToXMLStringVisitor

public ToXMLStringVisitor(java.io.Writer writer)
Constructor for default encoding.
Parameters:
writer - The character output stream to use.
Method Detail

visitDocumentPre

public void visitDocumentPre(TXDocument document) throws java.io.IOException
Creates a string representation of the specified document Node in XML format.
Implements:
visitDocumentPre in interface Visitor
Parameters:
document - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitDocumentPre in class NOOPVisitor
See Also:
TXDocument

visitDocumentPost

public void visitDocumentPost(TXDocument document) throws java.io.IOException
Flush the writer.
Implements:
visitDocumentPost in interface Visitor
Parameters:
document - CURRENTLY NOT IMPLEMENTED.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitDocumentPost in class NOOPVisitor
See Also:
TXDocument

visitElementPre

public void visitElementPre(TXElement element) throws java.io.IOException
Creates a string representation of the start of the specified element Node and its associated attributes in XML format.
Implements:
visitElementPre in interface Visitor
Parameters:
element - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitElementPre in class NOOPVisitor
See Also:
TXElement

visitElementPost

public void visitElementPost(TXElement element) throws java.io.IOException
Creates a string representation of the end of the specified element Node in XML format.
Implements:
visitElementPost in interface Visitor
Parameters:
element - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitElementPost in class NOOPVisitor
See Also:
TXElement

visitAttributePre

public void visitAttributePre(TXAttribute attribute) throws java.io.IOException
Creates a string representation of the specified attribute Node in XML format.

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 toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitAttributePre in class NOOPVisitor
See Also:
TXAttribute

visitPIPre

public void visitPIPre(TXPI pi) throws java.io.IOException
Creates a string representation of the specified pi Node in XML format.
Implements:
visitPIPre in interface Visitor
Parameters:
pi - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitPIPre in class NOOPVisitor
See Also:
TXPI

visitCommentPre

public void visitCommentPre(TXComment comment) throws java.io.IOException
Creates a string representation of the specified comment Node in XML format.
Implements:
visitCommentPre in interface Visitor
Parameters:
comment - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitCommentPre in class NOOPVisitor
See Also:
TXComment

visitTextPre

public void visitTextPre(TXText text) throws java.io.IOException
Creates a string representation of the specified text Node in XML format. CDATASections are respected.
Implements:
visitTextPre in interface Visitor
Parameters:
text - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitTextPre in class NOOPVisitor
See Also:
TXText

visitDTDPre

public void visitDTDPre(DTD dtd) throws java.io.IOException
Creates a string representation of the specified dtd Node, and optionally its internal DTD subset, in XML format. The internal DTD subset will be included based on the value of isPrintInternalDTD().
Implements:
visitDTDPre in interface Visitor
Parameters:
dtd - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitDTDPre in class NOOPVisitor
See Also:
isPrintInternalDTD, DTD

visitElementDeclPre

public void visitElementDeclPre(ElementDecl elementDecl) throws java.io.IOException
Creates a string representation of the specified elementDecl Node in XML format.
Implements:
visitElementDeclPre in interface Visitor
Parameters:
elementDecl - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitElementDeclPre in class NOOPVisitor
See Also:
ElementDecl

visitAttlistPre

public void visitAttlistPre(Attlist attlist) throws java.io.IOException
Creates a string representation of the specified attlist Node and any associated AttDefs in XML format.
Implements:
visitAttlistPre in interface Visitor
Parameters:
attlist - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitAttlistPre in class NOOPVisitor
See Also:
Attlist

visitAttDefPre

public void visitAttDefPre(AttDef attDef) throws java.io.IOException
Creates a string representation of the specified attDef Node in XML format.
Implements:
visitAttDefPre in interface Visitor
Parameters:
attDef - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitAttDefPre in class NOOPVisitor
See Also:
AttDef

visitEntityPre

public void visitEntityPre(Entity entity) throws java.io.IOException
Creates a string representation of the specified entity Node in XML format.
Implements:
visitEntityPre in interface Visitor
Parameters:
entity - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitEntityPre in class NOOPVisitor
See Also:
Entity

visitNotationPre

public void visitNotationPre(TXNotation notation) throws java.io.IOException
Creates a string representation of the specified notation Node in XML format.
Implements:
visitNotationPre in interface Visitor
Parameters:
notation - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitNotationPre in class NOOPVisitor
See Also:
com.ibm.xml.parser.Notation

visitGeneralReferencePre

public void visitGeneralReferencePre(GeneralReference generalReference) throws java.io.IOException
Creates a string representation of the specified generalReference Node in XML format.
Implements:
visitGeneralReferencePre in interface Visitor
Parameters:
generalReference - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitGeneralReferencePre in class NOOPVisitor
See Also:
GeneralReference

visitPseudoNodePre

public void visitPseudoNodePre(PseudoNode pseudoNode) throws java.io.IOException
Creates a string representation of the specified pseudoNode Node in XML format.
Implements:
visitPseudoNodePre in interface Visitor
Parameters:
pseudoNode - Node toString in XML format.
Throws:
java.io.IOException - Thrown if this Node can not be visitted because of an invalid character output stream.
Overrides:
visitPseudoNodePre in class NOOPVisitor
See Also:
PseudoNode

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