Class AbstractNodeElement
- java.lang.Object
-
- net.sf.ehcache.config.generator.model.AbstractNodeElement
-
- All Implemented Interfaces:
NodeElement
- Direct Known Subclasses:
SimpleNodeElement
public abstract class AbstractNodeElement extends java.lang.Object implements NodeElement
An abstract implementation ofNodeElement. Overridesequals(Object)andhashCode()methods by comparing the fully qualified name of this element --getFQName()- Author:
- Abhishek Sanoujam
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<NodeAttribute>attributesList of attributesprotected java.util.List<NodeElement>childrenList of child elementsprotected java.lang.StringinnerContentthe inner string contentprotected booleanoptionalWhether this element is optionalprotected NodeElementparentThe parent
-
Constructor Summary
Constructors Constructor Description AbstractNodeElement(NodeElement parent)Constructor accepting the parent of this element
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaccept(NodeElementVisitor visitor)Accepts anNodeElementVisitorstatic voidaddAllFactoryConfigsAsChildElements(NodeElement element, java.lang.String name, java.util.Collection<? extends FactoryConfiguration> factoryConfigurations)Helper method that adds all theFactoryConfigurationfrom the parameter as child elements by creatingFactoryConfigurationElementfor each of themvoidaddAttribute(NodeAttribute attribute)Add an attributevoidaddChildElement(NodeElement childElement)Adds a child element.booleanequals(java.lang.Object obj)static java.util.List<FactoryConfigurationElement>getAllFactoryElements(NodeElement parent, java.lang.String name, java.util.Collection factoryConfigurations1)Helper method that createsFactoryConfigurationElement's from a collection ofFactoryConfiguration'sjava.util.List<NodeAttribute>getAttributes()List of attributes of this elementjava.util.List<NodeElement>getChildElements()Returns the list of child elements.java.lang.StringgetFQName()Same as callingNodeElement.getFQName(String)with the string "."java.lang.StringgetFQName(java.lang.String delimiter)The fully qualified name of the element.java.lang.StringgetInnerContent()The inner content of this element as string.abstract java.lang.StringgetName()The name of the elementNodeElementgetParent()Returns the parent of this element.booleanhasChildren()Returns true if there is at least one childinthashCode()booleanisOptional()Returns true if this element is optionalvoidsetInnerContent(java.lang.String content)Sets the inner content of this elementvoidsetOptional(boolean optional)Sets optional or notjava.lang.StringtoString()
-
-
-
Field Detail
-
attributes
protected final java.util.List<NodeAttribute> attributes
List of attributes
-
children
protected final java.util.List<NodeElement> children
List of child elements
-
parent
protected NodeElement parent
The parent
-
optional
protected boolean optional
Whether this element is optional
-
innerContent
protected java.lang.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 java.lang.String getName()
The name of the element- Specified by:
getNamein interfaceNodeElement- Returns:
- Name of the element
-
getParent
public NodeElement getParent()
Returns the parent of this element. May be null.- Specified by:
getParentin interfaceNodeElement- Returns:
- parent of this element. May be null.
-
getAttributes
public java.util.List<NodeAttribute> getAttributes()
List of attributes of this element- Specified by:
getAttributesin interfaceNodeElement- Returns:
- list of attributes of this element
-
getChildElements
public java.util.List<NodeElement> getChildElements()
Returns the list of child elements.- Specified by:
getChildElementsin interfaceNodeElement- Returns:
- the list of child elements
-
addAttribute
public void addAttribute(NodeAttribute attribute)
Add an attribute- Specified by:
addAttributein interfaceNodeElement- Parameters:
attribute- add an attribute
-
addChildElement
public void addChildElement(NodeElement childElement)
Adds a child element.- Specified by:
addChildElementin interfaceNodeElement- Parameters:
childElement- adds a child element
-
isOptional
public boolean isOptional()
Returns true if this element is optional- Specified by:
isOptionalin interfaceNodeElement- Returns:
- true if this element is optional
-
setOptional
public void setOptional(boolean optional)
Sets optional or not- Specified by:
setOptionalin interfaceNodeElement
-
hasChildren
public boolean hasChildren()
Returns true if there is at least one child- Specified by:
hasChildrenin interfaceNodeElement- Returns:
- true if there is at least one child, otherwise false
-
getInnerContent
public java.lang.String getInnerContent()
The inner content of this element as string. Does not include the child elements- Specified by:
getInnerContentin interfaceNodeElement- Returns:
- inner content of this element as string. This does not include the child elements
-
setInnerContent
public void setInnerContent(java.lang.String content)
Sets the inner content of this element- Specified by:
setInnerContentin interfaceNodeElement
-
addAllFactoryConfigsAsChildElements
public static void addAllFactoryConfigsAsChildElements(NodeElement element, java.lang.String name, java.util.Collection<? extends FactoryConfiguration> factoryConfigurations)
Helper method that adds all theFactoryConfigurationfrom the parameter as child elements by creatingFactoryConfigurationElementfor each of them- Parameters:
element- the element in which the child elements will be addedname- name to be used for the child element(s)factoryConfigurations- theFactoryConfiguration's
-
getAllFactoryElements
public static java.util.List<FactoryConfigurationElement> getAllFactoryElements(NodeElement parent, java.lang.String name, java.util.Collection factoryConfigurations1)
Helper method that createsFactoryConfigurationElement's from a collection ofFactoryConfiguration's- Parameters:
parent- the parent for each of the createFactoryConfigurationElementname- name of the element(s)factoryConfigurations1- theFactoryConfiguration's- Returns:
- list of
FactoryConfigurationElement
-
getFQName
public java.lang.String getFQName()
Same as callingNodeElement.getFQName(String)with the string "."- Specified by:
getFQNamein interfaceNodeElement- Returns:
- the fully qualified name of this element
-
getFQName
public java.lang.String getFQName(java.lang.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 thedelimiterstring- Specified by:
getFQNamein interfaceNodeElement- Returns:
- the fully qualified name of this element separated by delimiter
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
accept
public void accept(NodeElementVisitor visitor)
Accepts anNodeElementVisitor- Specified by:
acceptin interfaceNodeElement- Parameters:
visitor- the visitor whose visit methods will be called
-
-