ehcache

net.sf.ehcache.config.generator.model
Class XMLGeneratorVisitor

java.lang.Object
  extended by net.sf.ehcache.config.generator.model.AbstractDepthFirstVisitor
      extended by net.sf.ehcache.config.generator.model.XMLGeneratorVisitor
All Implemented Interfaces:
NodeElementVisitor

public class XMLGeneratorVisitor
extends AbstractDepthFirstVisitor

Implementation of an ElementVisitor extending from 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)

Author:
Abhishek Sanoujam

Nested Class Summary
static class XMLGeneratorVisitor.OutputBehavior
          Enum controlling the generated XML output
 
Constructor Summary
XMLGeneratorVisitor(PrintWriter out)
          Constructor accepting the PrintWriter.
 
Method Summary
 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.
 
Methods inherited from class net.sf.ehcache.config.generator.model.AbstractDepthFirstVisitor
visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLGeneratorVisitor

public XMLGeneratorVisitor(PrintWriter out)
Constructor accepting the PrintWriter. All output behaviors are enabled by default.

Parameters:
out - the PrintWriter
Method Detail

enableAllOutputBehaviors

public void enableAllOutputBehaviors()
Enables all output behaviors


disableAllOutputBehaviors

public void disableAllOutputBehaviors()
Disables all output behaviors


enableOutputBehavior

public void enableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
Enables one particular XMLGeneratorVisitor.OutputBehavior

Parameters:
behavior -

disableOutputBehavior

public void disableOutputBehavior(XMLGeneratorVisitor.OutputBehavior behavior)
Disables one particular XMLGeneratorVisitor.OutputBehavior

Parameters:
behavior -

isOutputBehaviorEnabled

public boolean isOutputBehaviorEnabled(XMLGeneratorVisitor.OutputBehavior behavior)
Returns true if the output behavior is enabled

Parameters:
behavior - the output behavior to inspect
Returns:
true if enabled, otherwise false

startElement

protected void startElement(NodeElement element)
Starts visiting an element. Override as needed

Overrides:
startElement in class AbstractDepthFirstVisitor
Parameters:
element - the element

startAttributes

protected void startAttributes(NodeElement element)
Starts visiting the attributes of the element. Override as needed

Overrides:
startAttributes in class AbstractDepthFirstVisitor
Parameters:
element - the element

visitAttributes

protected void visitAttributes(NodeElement element,
                               List<NodeAttribute> attributes)
Visits the attributes of the element. Override as needed

Overrides:
visitAttributes in class AbstractDepthFirstVisitor
Parameters:
element - the element
attributes - the attributes

visitAttribute

protected void visitAttribute(NodeElement element,
                              NodeAttribute attribute)
Visits an attribute.

Parameters:
element -
attribute -

endAttributes

protected void endAttributes(NodeElement element)
Finish visiting attributes of the element. Override as needed

Overrides:
endAttributes in class AbstractDepthFirstVisitor
Parameters:
element - the element

visitElement

protected void visitElement(NodeElement element)
Visits the element. Override as needed

Overrides:
visitElement in class AbstractDepthFirstVisitor
Parameters:
element - the element

startChildren

protected void startChildren(NodeElement element)
Starts visiting children of the element. Override as needed

Overrides:
startChildren in class AbstractDepthFirstVisitor
Parameters:
element - the element

endChildren

protected void endChildren(NodeElement element)
Finish visiting children of the element. Override as needed

Overrides:
endChildren in class AbstractDepthFirstVisitor
Parameters:
element - the element

endElement

protected void endElement(NodeElement element)
Finish visiting the element. Override as needed

Overrides:
endElement in class AbstractDepthFirstVisitor
Parameters:
element - the element

ehcache

Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.