|
XML for Java Compatibility API 2.0.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.ibm.xml.parser.NOOPVisitor
|
+--com.ibm.xml.parser.ToXMLStringVisitor
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);
Visitor,
NOOPVisitor,
TreeTraversal,
NonRecursivePreorderTreeTraversal| Field Summary | |
protected java.lang.String |
encoding
|
protected boolean |
isPrintNonSpecifiedAttributes
|
protected java.io.Writer |
writer
|
| Constructor Summary | |
ToXMLStringVisitor(java.io.Writer writer)
Constructor for default encoding. |
|
ToXMLStringVisitor(java.io.Writer writer,
java.lang.String encoding)
Constructor for customized encoding. |
|
| Method Summary | |
boolean |
getPrintNonSpecifiedAttributes()
Returns whether this prints non-specified default attributes appended by DTD. |
void |
setPrintNonSpecifiedAttributes(boolean print)
Sets whether this prints non-specified default attributes appended by DTD. |
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 |
visitDTDPost(DTD dtd)
Creates a string representation of the specified dtd Node, and optionally its internal DTD subset, 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 |
visitEntityDeclPre(EntityDecl entityDecl)
Creates a string representation of the specified entityDecl 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,
visitAttlistPost,
visitAttributePost,
visitCommentPost,
visitDocumentFragmentPost,
visitDocumentFragmentPre,
visitElementDeclPost,
visitEntityDeclPost,
visitGeneralReferencePost,
visitNotationPost,
visitPIPost,
visitPseudoNodePost,
visitTextPost |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
protected java.io.Writer writer
protected java.lang.String encoding
protected boolean isPrintNonSpecifiedAttributes
| Constructor Detail |
public ToXMLStringVisitor(java.io.Writer writer,
java.lang.String encoding)
writer - The character output stream to use.encoding - Java character encoding in use by writer.public ToXMLStringVisitor(java.io.Writer writer)
writer - The character output stream to use.| Method Detail |
public void setPrintNonSpecifiedAttributes(boolean print)
By default, non-specified attributes are printed.
TXAttribute.getSpecified()public boolean getPrintNonSpecifiedAttributes()
public void visitDocumentPre(TXDocument document)
throws java.lang.Exception
document - Node toString in XML format.TXDocument
public void visitDocumentPost(TXDocument document)
throws java.lang.Exception
document - CURRENTLY NOT IMPLEMENTED.TXDocument
public void visitElementPre(TXElement element)
throws java.lang.Exception
element - Node toString in XML format.TXElement
public void visitElementPost(TXElement element)
throws java.lang.Exception
element - Node toString in XML format.TXElement
public void visitAttributePre(TXAttribute attribute)
throws java.lang.Exception
Note that TXAttribute Nodes are not parsed into the document object hierarchy by the XML4J parser; attributes exist as part of a TXElement Node.
attribute - Node toString in XML format.TXAttribute
public void visitPIPre(TXPI pi)
throws java.lang.Exception
pi - Node toString in XML format.TXPI
public void visitCommentPre(TXComment comment)
throws java.lang.Exception
comment - Node toString in XML format.TXComment
public void visitTextPre(TXText text)
throws java.lang.Exception
text - Node toString in XML format.TXText
public void visitDTDPre(DTD dtd)
throws java.lang.Exception
isPrintInternalDTD().dtd - Node toString in XML format.DTD.isPrintInternalDTD(),
DTD
public void visitDTDPost(DTD dtd)
throws java.lang.Exception
isPrintInternalDTD().dtd - Node toString in XML format.DTD.isPrintInternalDTD(),
DTD
public void visitElementDeclPre(ElementDecl elementDecl)
throws java.lang.Exception
elementDecl - Node toString in XML format.ElementDecl
public void visitAttlistPre(Attlist attlist)
throws java.lang.Exception
attlist - Node toString in XML format.Attlist
public void visitAttDefPre(AttDef attDef)
throws java.lang.Exception
attDef - Node toString in XML format.AttDef
public void visitEntityDeclPre(EntityDecl entityDecl)
throws java.lang.Exception
entity - Node toString in XML format.EntityDecl
public void visitNotationPre(TXNotation notation)
throws java.lang.Exception
notation - Node toString in XML format.TXNotation
public void visitGeneralReferencePre(GeneralReference generalReference)
throws java.lang.Exception
generalReference - Node toString in XML format.GeneralReference
public void visitPseudoNodePre(PseudoNode pseudoNode)
throws java.lang.Exception
pseudoNode - Node toString in XML format.PseudoNode
|
XML for Java Compatibility API 2.0.15 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||