public class DefaultConfigurationNode extends Object implements ConfigurationNode, Cloneable
A default implementation of the ConfigurationNode
interface.
Modifier and Type | Class and Description |
---|---|
protected static class |
DefaultConfigurationNode.SubNodes
An internally used helper class for managing a collection of sub nodes.
|
Constructor and Description |
---|
DefaultConfigurationNode()
Creates a new uninitialized instance of
DefaultConfigurationNode . |
DefaultConfigurationNode(String name)
Creates a new instance of
DefaultConfigurationNode and
initializes it with the node name. |
DefaultConfigurationNode(String name,
Object value)
Creates a new instance of
DefaultConfigurationNode and
initializes it with the name and a value. |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(ConfigurationNode attr)
Adds the specified attribute to this node.
|
void |
addChild(ConfigurationNode child)
Adds a new child to this node.
|
protected void |
checkState()
Checks if a modification of this node is allowed.
|
Object |
clone()
Creates a copy of this object.
|
protected DefaultConfigurationNode.SubNodes |
createSubNodes(boolean attributes)
Creates a
SubNodes instance that is used for storing
either this node's children or attributes. |
ConfigurationNode |
getAttribute(int index)
Returns the attribute with the given index.
|
int |
getAttributeCount()
Returns the number of attributes contained in this node.
|
int |
getAttributeCount(String name)
Returns the number of attributes of this node with the given name.
|
List<ConfigurationNode> |
getAttributes()
Returns a list with the attributes of this node.
|
List<ConfigurationNode> |
getAttributes(String name)
Returns a list with all attributes of this node with the given name.
|
ConfigurationNode |
getChild(int index)
Returns the child node with the given index.
|
List<ConfigurationNode> |
getChildren()
Returns a list with all children of this node.
|
List<ConfigurationNode> |
getChildren(String name)
Returns a list of all children with the given name.
|
int |
getChildrenCount()
Returns the number of all children of this node.
|
int |
getChildrenCount(String name)
Returns the number of children with the given name.
|
String |
getName()
Returns the name of this node.
|
ConfigurationNode |
getParentNode()
Returns a reference to this node's parent.
|
Object |
getReference()
Returns the reference.
|
Object |
getValue()
Returns the value of this node.
|
boolean |
isAttribute()
Checks if this node is an attribute node.
|
boolean |
isDefined()
Returns a flag if this node is defined.
|
boolean |
removeAttribute(ConfigurationNode node)
Removes the specified attribute.
|
boolean |
removeAttribute(String name)
Removes all attributes with the specified name.
|
void |
removeAttributes()
Removes all attributes of this node.
|
boolean |
removeChild(ConfigurationNode child)
Removes the specified child node from this node.
|
boolean |
removeChild(String childName)
Removes all children with the given name.
|
void |
removeChildren()
Removes all child nodes of this node.
|
protected void |
removeReference()
Deals with the reference when a node is removed.
|
void |
setAttribute(boolean f)
Sets the attribute flag.
|
void |
setName(String name)
Sets the name of this node.
|
void |
setParentNode(ConfigurationNode parent)
Sets the parent of this node.
|
void |
setReference(Object reference)
Sets the reference.
|
void |
setValue(Object val)
Sets the value of this node.
|
void |
visit(ConfigurationNodeVisitor visitor)
Visits this node and all its sub nodes.
|
public DefaultConfigurationNode()
DefaultConfigurationNode
.public DefaultConfigurationNode(String name)
DefaultConfigurationNode
and
initializes it with the node name.name
- the name of this nodepublic String getName()
getName
in interface ConfigurationNode
public void setName(String name)
setName
in interface ConfigurationNode
name
- the new namepublic Object getValue()
getValue
in interface ConfigurationNode
public void setValue(Object val)
setValue
in interface ConfigurationNode
val
- the value of this nodepublic Object getReference()
getReference
in interface ConfigurationNode
public void setReference(Object reference)
setReference
in interface ConfigurationNode
reference
- the reference objectpublic ConfigurationNode getParentNode()
getParentNode
in interface ConfigurationNode
public void setParentNode(ConfigurationNode parent)
setParentNode
in interface ConfigurationNode
parent
- the parent of this nodepublic void addChild(ConfigurationNode child)
addChild
in interface ConfigurationNode
child
- the new childpublic List<ConfigurationNode> getChildren()
getChildren
in interface ConfigurationNode
public int getChildrenCount()
getChildrenCount
in interface ConfigurationNode
public List<ConfigurationNode> getChildren(String name)
getChildren
in interface ConfigurationNode
name
- the name; can be null , then all children are returnedpublic int getChildrenCount(String name)
getChildrenCount
in interface ConfigurationNode
name
- the name; can be null , then the number of all
children is returnedpublic ConfigurationNode getChild(int index)
getChild
in interface ConfigurationNode
index
- the index (0-based)public boolean removeChild(ConfigurationNode child)
removeChild
in interface ConfigurationNode
child
- the node to be removedpublic boolean removeChild(String childName)
removeChild
in interface ConfigurationNode
childName
- the name of the children to be removedpublic void removeChildren()
removeChildren
in interface ConfigurationNode
public boolean isAttribute()
isAttribute
in interface ConfigurationNode
public void setAttribute(boolean f)
setAttribute
in interface ConfigurationNode
f
- the attribute flagpublic void addAttribute(ConfigurationNode attr)
addAttribute
in interface ConfigurationNode
attr
- the attribute to be addedpublic List<ConfigurationNode> getAttributes()
DefaultConfigurationNode
objects, too.getAttributes
in interface ConfigurationNode
public int getAttributeCount()
getAttributeCount
in interface ConfigurationNode
public List<ConfigurationNode> getAttributes(String name)
getAttributes
in interface ConfigurationNode
name
- the attribute's namepublic int getAttributeCount(String name)
getAttributeCount
in interface ConfigurationNode
name
- the namepublic boolean removeAttribute(ConfigurationNode node)
removeAttribute
in interface ConfigurationNode
node
- the attribute node to be removedpublic boolean removeAttribute(String name)
removeAttribute
in interface ConfigurationNode
name
- the namepublic ConfigurationNode getAttribute(int index)
getAttribute
in interface ConfigurationNode
index
- the index (0-based)public void removeAttributes()
removeAttributes
in interface ConfigurationNode
public boolean isDefined()
isDefined
in interface ConfigurationNode
public void visit(ConfigurationNodeVisitor visitor)
visit
in interface ConfigurationNode
visitor
- the visitorConfigurationNodeVisitor
public Object clone()
clone
in interface ConfigurationNode
clone
in class Object
protected void checkState()
protected DefaultConfigurationNode.SubNodes createSubNodes(boolean attributes)
SubNodes
instance that is used for storing
either this node's children or attributes.attributes
- true if the returned instance is used for
storing attributes, false for storing child nodesSubNodes
object to useprotected void removeReference()
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.