public class XMLGeneratorVisitor extends AbstractDepthFirstVisitor
AbstractDepthFirstVisitor
which can generate XML out of a NodeElement
.
Accepts a PrintWriter
in the constructor and uses it to output the generated XML.
Output can be controlled by enabling/disabling the various options present in XMLGeneratorVisitor.OutputBehavior
by calling
enableOutputBehavior(OutputBehavior)
or disableOutputBehavior(OutputBehavior)
Modifier and Type | Class and Description |
---|---|
static class |
XMLGeneratorVisitor.OutputBehavior
Enum controlling the generated XML output
|
Constructor and Description |
---|
XMLGeneratorVisitor(PrintWriter out)
Constructor accepting the
PrintWriter . |
Modifier and Type | Method and Description |
---|---|
void |
disableAllOutputBehaviors()
Disables all output behaviors
|
void |
disableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
Disables one particular
XMLGeneratorVisitor.OutputBehavior |
void |
enableAllOutputBehaviors()
Enables all output behaviors
|
void |
enableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
Enables one particular
XMLGeneratorVisitor.OutputBehavior |
protected void |
endAttributes(NodeElement element)
Finish visiting attributes of the element.
|
protected void |
endChildren(NodeElement element)
Finish visiting children of the element.
|
protected void |
endElement(NodeElement element)
Finish visiting the element.
|
boolean |
isOutputBehaviorEnabled(XMLGeneratorVisitor.OutputBehavior behavior)
Returns true if the output behavior is enabled
|
protected void |
startAttributes(NodeElement element)
Starts visiting the attributes of the element.
|
protected void |
startChildren(NodeElement element)
Starts visiting children of the element.
|
protected void |
startElement(NodeElement element)
Starts visiting an element.
|
protected void |
visitAttribute(NodeElement element,
NodeAttribute attribute)
Visits an attribute.
|
protected void |
visitAttributes(NodeElement element,
List<NodeAttribute> attributes)
Visits the attributes of the element.
|
protected void |
visitElement(NodeElement element)
Visits the element.
|
visit
public XMLGeneratorVisitor(PrintWriter out)
PrintWriter
. All output behaviors are enabled by default.out
- the PrintWriter
public void enableAllOutputBehaviors()
public void disableAllOutputBehaviors()
public void enableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
XMLGeneratorVisitor.OutputBehavior
behavior
- public void disableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
XMLGeneratorVisitor.OutputBehavior
behavior
- public boolean isOutputBehaviorEnabled(XMLGeneratorVisitor.OutputBehavior behavior)
behavior
- the output behavior to inspectprotected void startElement(NodeElement element)
startElement
in class AbstractDepthFirstVisitor
element
- the elementprotected void startAttributes(NodeElement element)
startAttributes
in class AbstractDepthFirstVisitor
element
- the elementprotected void visitAttributes(NodeElement element, List<NodeAttribute> attributes)
visitAttributes
in class AbstractDepthFirstVisitor
element
- the elementattributes
- the attributesprotected void visitAttribute(NodeElement element, NodeAttribute attribute)
element
- attribute
- protected void endAttributes(NodeElement element)
endAttributes
in class AbstractDepthFirstVisitor
element
- the elementprotected void visitElement(NodeElement element)
visitElement
in class AbstractDepthFirstVisitor
element
- the elementprotected void startChildren(NodeElement element)
startChildren
in class AbstractDepthFirstVisitor
element
- the elementprotected void endChildren(NodeElement element)
endChildren
in class AbstractDepthFirstVisitor
element
- the elementprotected void endElement(NodeElement element)
endElement
in class AbstractDepthFirstVisitor
element
- the elementCopyright © 2003-2013 Terracotta, Inc.. All Rights Reserved.