Package com.github.javaparser.printer
Class XmlPrinter
java.lang.Object
com.github.javaparser.printer.XmlPrinter
Outputs an XML file containing the AST meant for inspecting it.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGenerate a xml string for given AST Node.void
output
(Node node, String name, int level, StringBuilder builder) Deprecated.void
outputDocument
(Node node, String name, Writer writer) Output the XML Document representing given AST node to given writer.void
outputDocument
(Node node, String name, XMLStreamWriter xmlWriter) Output the XML Document representing an AST node to given XMLStreamWriter.void
outputNode
(Node node, String name, XMLStreamWriter xmlWriter) Output the XML Element representing an AST node to given writer.static void
stringWriterOutput
(Node node, String name) Create a string writer filled with XML document representing an AST node.
-
Field Details
-
outputNodeType
private final boolean outputNodeType -
TYPE_CLASS
-
-
Constructor Details
-
XmlPrinter
public XmlPrinter(boolean outputNodeType)
-
-
Method Details
-
output
Generate a xml string for given AST Node. Tag name of root element in the result document will be "root".- Parameters:
node
- AST node to be converted to XML- Returns:
- XML document corresponding to node
-
output
Deprecated.Output XML data from an AST node to a String Builder. This method is kept for backward compatilibity only and should be removed in future releases.- Parameters:
node
- AST node to be converted to XMLname
- Tag name of root element in the resulting documentlevel
- Nesting level of node in tree. Not used.builder
- Target object to receive the generated XML
-
stringWriterOutput
Create a string writer filled with XML document representing an AST node.Returned stringWriter is not closed upon return because doing so
has no effect
. So users of this method are not required to close it.- Parameters:
node
- AST node to be converted to XMLname
- Tag name of root element in the resulting document- Returns:
- Stringwriter filled with XML document
- Throws:
RuntimeXMLStreamException
- Unchecked exception wrapping checkedXMLStreamException
, when any error on producing XML output occours
-
outputDocument
Output the XML Document representing given AST node to given writer.This method creates a
XMLStreamWriter
that writes to given writer and delegates execution tooutputDocument(Node, String, XMLStreamWriter)
Provided writer is NOT closed at the end of execution of this method.
- Parameters:
node
- AST node to be converted to XMLname
- Tag name of root element of documentwriter
- Target to get the document writen to- Throws:
XMLStreamException
- When any error on outputting XML occours
-
outputDocument
public void outputDocument(Node node, String name, XMLStreamWriter xmlWriter) throws XMLStreamException Output the XML Document representing an AST node to given XMLStreamWriter.- Throws:
XMLStreamException
-
outputNode
Output the XML Element representing an AST node to given writer.This method outputs an XML Element with given tag name to writer. It is used recursively for generating nested elements corresponding to AST.
For generating a complete XML document from an AST node,
invalid reference
outputDocument(String, Node, XMLStreamWriter)
Provided xmlWriter is NOT closed at the end of execution of this method.
- Parameters:
node
- AST node to be converted to XMLname
- Tag name of element corresponding to nodexmlWriter
- Target to get XML written to- Throws:
XMLStreamException
- When any error on outputting XML occours- See Also:
-
print
-