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 OutputBehavior by calling
enableOutputBehavior(OutputBehavior) or disableOutputBehavior(OutputBehavior)
| Modifier and Type | Class and Description |
|---|---|
| public static enum | XMLGeneratorVisitor.OutputBehavior
Enum controlling the generated XML output |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private int | |
| private final PrintWriter | |
| private NodeElement | |
| private static final String | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | disableOutputBehavior(XMLGeneratorVisitor.
Disables one particular |
| public void | |
| public void | enableOutputBehavior(XMLGeneratorVisitor.
Enables one particular |
| protected void | endAttributes(NodeElement
the element element)Overrides net. |
| protected void | endChildren(NodeElement
the element element)Overrides net. |
| protected void | endElement(NodeElement
the element element)Overrides net. |
| private void | |
| private void | |
| public boolean | Returns: true if enabled, otherwise falsethe output behavior to inspect behaviorReturns true if the output behavior is enabled |
| private void | |
| private void | |
| private void | |
| private String | |
| protected void | startAttributes(NodeElement
the element element)Overrides net. |
| protected void | startChildren(NodeElement
the element element)Overrides net. |
| protected void | startElement(NodeElement
the element element)Overrides net. |
| protected void | |
| protected void | visitAttributes(NodeElement
the element element, List<NodeAttribute> the attributes attributes)Overrides net. |
| protected void | visitElement(NodeElement
the element element)Overrides net. |
| enabledOutputBehaviors | back to summary |
|---|---|
| private final Map<XMLGeneratorVisitor. | |
| indent | back to summary |
|---|---|
| private int indent | |
| out | back to summary |
|---|---|
| private final PrintWriter out | |
| rootElement | back to summary |
|---|---|
| private NodeElement rootElement | |
| SPACER | back to summary |
|---|---|
| private static final String SPACER | |
| visitedFirstElement | back to summary |
|---|---|
| private boolean visitedFirstElement | |
| XMLGeneratorVisitor | back to summary |
|---|---|
| public XMLGeneratorVisitor(PrintWriter out) Constructor accepting the
| |
| disableAllOutputBehaviors | back to summary |
|---|---|
| public void disableAllOutputBehaviors() Disables all output behaviors | |
| disableOutputBehavior | back to summary |
|---|---|
| public void disableOutputBehavior(XMLGeneratorVisitor. Disables one particular | |
| enableAllOutputBehaviors | back to summary |
|---|---|
| public void enableAllOutputBehaviors() Enables all output behaviors | |
| enableOutputBehavior | back to summary |
|---|---|
| public void enableOutputBehavior(XMLGeneratorVisitor. Enables one particular | |
| endAttributes | back to summary |
|---|---|
| protected void endAttributes(NodeElement element) Overrides net. Doc from net. Finish visiting attributes of the element. Override as needed
| |
| endChildren | back to summary |
|---|---|
| protected void endChildren(NodeElement element) Overrides net. Doc from net. Finish visiting children of the element. Override as needed
| |
| endElement | back to summary |
|---|---|
| protected void endElement(NodeElement element) Overrides net. Doc from net. Finish visiting the element. Override as needed
| |
| indentBackward | back to summary |
|---|---|
| private void indentBackward() | |
| indentForward | back to summary |
|---|---|
| private void indentForward() | |
| isOutputBehaviorEnabled | back to summary |
|---|---|
| public boolean isOutputBehaviorEnabled(XMLGeneratorVisitor. Returns true if the output behavior is enabled
| |
| newLine | back to summary |
|---|---|
| private void newLine() | |
| back to summary | |
|---|---|
| private void print(String string) | |
| printWithoutSpacer | back to summary |
|---|---|
| private void printWithoutSpacer(String string) | |
| spacer | back to summary |
|---|---|
| private String spacer() | |
| startAttributes | back to summary |
|---|---|
| protected void startAttributes(NodeElement element) Overrides net. Doc from net. Starts visiting the attributes of the element. Override as needed
| |
| startChildren | back to summary |
|---|---|
| protected void startChildren(NodeElement element) Overrides net. Doc from net. Starts visiting children of the element. Override as needed
| |
| startElement | back to summary |
|---|---|
| protected void startElement(NodeElement element) Overrides net. Doc from net. Starts visiting an element. Override as needed
| |
| visitAttribute | back to summary |
|---|---|
| protected void visitAttribute(NodeElement element, NodeAttribute attribute) Visits an attribute. | |
| visitAttributes | back to summary |
|---|---|
| protected void visitAttributes(NodeElement element, List<NodeAttribute> attributes) Overrides net. Doc from net. Visits the attributes of the element. Override as needed
| |
| visitElement | back to summary |
|---|---|
| protected void visitElement(NodeElement element) Overrides net. Doc from net. Visits the element. Override as needed
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final XMLGeneratorVisitor. | INDENT_CHIlD_ELEMENTS
Output behavior controlling whether child elements should be indented or not |
| public static final XMLGeneratorVisitor. | NEWLINE_AT_END
Output behavior controlling whether new lines should be added at the end or not |
| public static final XMLGeneratorVisitor. | NEWLINE_FOR_EACH_ATTRIBUTE
Output behavior controlling whether new lines should be added for each attribute |
| public static final XMLGeneratorVisitor. | NEWLINE_FOR_EACH_ELEMENT
Output behavior controlling whether new lines should be added for each child element |
| public static final XMLGeneratorVisitor. | OUTPUT_OPTIONAL_ATTRIBUTES_WITH_DEFAULT_VALUES
Output behavior controlling whether optional attributes having default values should be generated or not |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static XMLGeneratorVisitor. | |
| public static XMLGeneratorVisitor. |
| INDENT_CHIlD_ELEMENTS | back to summary |
|---|---|
| public static final XMLGeneratorVisitor. Output behavior controlling whether child elements should be indented or not | |
| NEWLINE_AT_END | back to summary |
|---|---|
| public static final XMLGeneratorVisitor. Output behavior controlling whether new lines should be added at the end or not | |
| NEWLINE_FOR_EACH_ATTRIBUTE | back to summary |
|---|---|
| public static final XMLGeneratorVisitor. Output behavior controlling whether new lines should be added for each attribute | |
| NEWLINE_FOR_EACH_ELEMENT | back to summary |
|---|---|
| public static final XMLGeneratorVisitor. Output behavior controlling whether new lines should be added for each child element | |
| OUTPUT_OPTIONAL_ATTRIBUTES_WITH_DEFAULT_VALUES | back to summary |
|---|---|
| public static final XMLGeneratorVisitor. Output behavior controlling whether optional attributes having default values should be generated or not | |
| OutputBehavior | back to summary |
|---|---|
| private OutputBehavior() | |
| valueOf | back to summary |
|---|---|
| public static XMLGeneratorVisitor. | |
| values | back to summary |
|---|---|
| public static XMLGeneratorVisitor. | |