ehcache

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

java.lang.Object
  extended by net.sf.ehcache.config.generator.model.AbstractNodeElement
All Implemented Interfaces:
NodeElement
Direct Known Subclasses:
SimpleNodeElement

public abstract class AbstractNodeElement
extends Object
implements NodeElement

An abstract implementation of NodeElement. Overrides equals(Object) and hashCode() methods by comparing the fully qualified name of this element -- getFQName()

Author:
Abhishek Sanoujam

Field Summary
protected  List<NodeAttribute> attributes
          List of attributes
protected  List<NodeElement> children
          List of child elements
protected  String innerContent
          the inner string content
protected  boolean optional
          Whether this element is optional
protected  NodeElement parent
          The parent
 
Constructor Summary
AbstractNodeElement(NodeElement parent)
          Constructor accepting the parent of this element
 
Method Summary
 void accept(NodeElementVisitor visitor)
          Accepts an NodeElementVisitor
static void addAllFactoryConfigsAsChildElements(NodeElement element, String name, Collection<? extends FactoryConfiguration> factoryConfigurations)
          Helper method that adds all the FactoryConfiguration from the parameter as child elements by creating FactoryConfigurationElement for each of them
 void addAttribute(NodeAttribute attribute)
          Add an attribute
 void addChildElement(NodeElement childElement)
          Adds a child element.
 boolean equals(Object obj)
          
static List<FactoryConfigurationElement> getAllFactoryElements(NodeElement parent, String name, Collection factoryConfigurations1)
          Helper method that creates FactoryConfigurationElement's from a collection of FactoryConfiguration's
 List<NodeAttribute> getAttributes()
          List of attributes of this element
 List<NodeElement> getChildElements()
          Returns the list of child elements.
 String getFQName()
          Same as calling NodeElement.getFQName(String) with the string "."
 String getFQName(String delimiter)
          The fully qualified name of the element.
 String getInnerContent()
          The inner content of this element as string.
abstract  String getName()
          The name of the element
 NodeElement getParent()
          Returns the parent of this element.
 boolean hasChildren()
          Returns true if there is at least one child
 int hashCode()
          
 boolean isOptional()
          Returns true if this element is optional
 void setInnerContent(String content)
          Sets the inner content of this element
 void setOptional(boolean optional)
          Sets optional or not
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected final List<NodeAttribute> attributes
List of attributes


children

protected final List<NodeElement> children
List of child elements


parent

protected NodeElement parent
The parent


optional

protected boolean optional
Whether this element is optional


innerContent

protected String innerContent
the inner string content

Constructor Detail

AbstractNodeElement

public AbstractNodeElement(NodeElement parent)
Constructor accepting the parent of this element

Parameters:
parent -
Method Detail

getName

public abstract String getName()
The name of the element

Specified by:
getName in interface NodeElement
Returns:
Name of the element

getParent

public NodeElement getParent()
Returns the parent of this element. May be null.

Specified by:
getParent in interface NodeElement
Returns:
parent of this element. May be null.

getAttributes

public List<NodeAttribute> getAttributes()
List of attributes of this element

Specified by:
getAttributes in interface NodeElement
Returns:
list of attributes of this element

getChildElements

public List<NodeElement> getChildElements()
Returns the list of child elements.

Specified by:
getChildElements in interface NodeElement
Returns:
the list of child elements

addAttribute

public void addAttribute(NodeAttribute attribute)
Add an attribute

Specified by:
addAttribute in interface NodeElement
Parameters:
attribute - add an attribute

addChildElement

public void addChildElement(NodeElement childElement)
Adds a child element.

Specified by:
addChildElement in interface NodeElement
Parameters:
childElement - adds a child element

isOptional

public boolean isOptional()
Returns true if this element is optional

Specified by:
isOptional in interface NodeElement
Returns:
true if this element is optional

setOptional

public void setOptional(boolean optional)
Sets optional or not

Specified by:
setOptional in interface NodeElement

hasChildren

public boolean hasChildren()
Returns true if there is at least one child

Specified by:
hasChildren in interface NodeElement
Returns:
true if there is at least one child, otherwise false

getInnerContent

public String getInnerContent()
The inner content of this element as string. Does not include the child elements

Specified by:
getInnerContent in interface NodeElement
Returns:
inner content of this element as string. This does not include the child elements

setInnerContent

public void setInnerContent(String content)
Sets the inner content of this element

Specified by:
setInnerContent in interface NodeElement

addAllFactoryConfigsAsChildElements

public static void addAllFactoryConfigsAsChildElements(NodeElement element,
                                                       String name,
                                                       Collection<? extends FactoryConfiguration> factoryConfigurations)
Helper method that adds all the FactoryConfiguration from the parameter as child elements by creating FactoryConfigurationElement for each of them

Parameters:
element - the element in which the child elements will be added
name - name to be used for the child element(s)
factoryConfigurations - the FactoryConfiguration's

getAllFactoryElements

public static List<FactoryConfigurationElement> getAllFactoryElements(NodeElement parent,
                                                                      String name,
                                                                      Collection factoryConfigurations1)
Helper method that creates FactoryConfigurationElement's from a collection of FactoryConfiguration's

Parameters:
parent - the parent for each of the create FactoryConfigurationElement
name - name of the element(s)
factoryConfigurations - the FactoryConfiguration's
Returns:
list of FactoryConfigurationElement

getFQName

public String getFQName()
Same as calling NodeElement.getFQName(String) with the string "."

Specified by:
getFQName in interface NodeElement
Returns:
the fully qualified name of this element

getFQName

public String getFQName(String delimiter)
The fully qualified name of the element. The fully qualified name of the name is the name from the root element till this element separated by the delimiter string

Specified by:
getFQName in interface NodeElement
Returns:
the fully qualified name of this element separated by delimiter

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

public String toString()

Overrides:
toString in class Object

accept

public void accept(NodeElementVisitor visitor)
Accepts an NodeElementVisitor

Specified by:
accept in interface NodeElement
Parameters:
visitor - the visitor whose visit methods will be called

ehcache

Copyright 2001-2015, Terracotta, Inc.