## org.apache.commons.configuration.tree
Interface ConfigurationNode

All Known Implementing Classes:
  DefaultConfigurationNode, HierarchicalConfiguration.Node, ViewNode, XMLPropertyListConfiguration.ArrayNode, XMLPropertyListConfiguration.PListNode

    public interface ConfigurationNode

Definition of an interface for the nodes of a hierarchical configuration.

This interface defines a tree like structure for configuration data. A node has a value and can have an arbitrary number of children and attributes.

Since:
  1.3
Version:
  $Id: ConfigurationNode.java 1234988 2012-01-23 21:12:15Z oheger $
Author:
  Commons Configuration team

Method Summary
`void` `addAttribute(ConfigurationNode attr)` Adds the specified attribute to this node
`void` `addChild(ConfigurationNode node)` Adds a child to this node.
`Object` `clone()` Returns a copy of this node.
`ConfigurationNode` `getAttribute(int index)` Returns the attribute node with the given index.
`int` `getAttributeCount()` Returns the number of attributes of this node.
`int` `getAttributeCount(String name)` Returns the number of attributes with the given name.
`List<ConfigurationNode>` `getAttributes()` Returns a list with this node's attributes.
`List<ConfigurationNode>` `getAttributes(String name)` Returns a list with the attribute nodes with the given name.
`ConfigurationNode` `getChild(int index)` Returns the child node with the given index.
`List<ConfigurationNode>` `getChildren()` Returns a list with the child nodes of this node.
`List<ConfigurationNode>` `getChildren(String name)` Returns a list with all children of this node with the given name.
`int` `getChildrenCount()` Returns the number of this node's children.
`int` `getChildrenCount(String name)` Returns the number of children with the given name.
`String` `getName()` Returns the name of this node.
`ConfigurationNode` `getParentNode()` Returns this node's parent.
`Object` `getReference()` Returns this node's reference.
`Object` `getValue()` Returns the value of this node.
`boolean` `isAttribute()` Returns a flag whether this node is an attribute.
`boolean` `isDefined()` Returns a flag if this node is defined.
`boolean` `removeAttribute(ConfigurationNode node)` Removes the specified attribute from this node.
`boolean` `removeAttribute(String name)` Removes all attributes with the given name.
`void` `removeAttributes()` Removes all attributes of this node.
`boolean` `removeChild(ConfigurationNode child)` Removes the given node from this node's children.
`boolean` `removeChild(String childName)` Removes all child nodes of this node with the given name.
`void` `removeChildren()` Removes all children from this node.
`void` `setAttribute(boolean f)` Sets a flag whether this node is an attribute.
`void` `setName(String name)` Sets the name of this node.
`void` `setParentNode(ConfigurationNode parent)` Sets the parent of this node.
`void` `setReference(Object ref)` Sets this node's reference.
`void` `setValue(Object val)` Sets the value of this node.
`void` `visit(ConfigurationNodeVisitor visitor)` Visits this node and all its sub nodes.

Method Detail

### getName

    String getName()

  Returns the name of this node.

  Returns:
    the node name

### setName

    void setName(String name)

  Sets the name of this node.

  Parameters:
    `name` - the node name

### getValue

    Object getValue()

  Returns the value of this node.

  Returns:
    the node's value

### setValue

    void setValue(Object val)

  Sets the value of this node.

  Parameters:
    `val` - the node's value

### getReference

    Object getReference()

  Returns this node's reference.

  Returns:
    the reference

### setReference

    void setReference(Object ref)

  Sets this node's reference. This reference can be used by concrete Configuration implementations to store data associated with each node. A XML based configuration for instance could here store a reference to the corresponding DOM element.

  Parameters:
    `ref` - the reference

### getParentNode

    ConfigurationNode getParentNode()

  Returns this node's parent. Can be null, then this node is the top level node.

  Returns:
    the parent of this node

### setParentNode

    void setParentNode(ConfigurationNode parent)

  Sets the parent of this node.

  Parameters:
    `parent` - the parent of this node

### addChild

    void addChild(ConfigurationNode node)

  Adds a child to this node.

  Parameters:
    `node` - the new child

### getChildren

    List<ConfigurationNode> getChildren()

  Returns a list with the child nodes of this node. The nodes in this list should be in the order they were inserted into this node.

  Returns:
    a list with the children of this node (never null)

### getChildrenCount

    int getChildrenCount()

  Returns the number of this node's children.

  Returns:
    the number of the children of this node

### getChildren

    List<ConfigurationNode> getChildren(String name)

  Returns a list with all children of this node with the given name.

  Parameters:
    `name` - the name of the searched children
  Returns:
    a list with all child nodes with this name (never null)

### getChildrenCount

    int getChildrenCount(String name)

  Returns the number of children with the given name.

  Parameters:
    `name` - the name
  Returns:
    the number of children with this name

### getChild

    ConfigurationNode getChild(int index)

  Returns the child node with the given index. If the index does not exist, an exception will be thrown.

  Parameters:
    `index` - the index of the child node (0-based)
  Returns:
    the child node with this index

### removeChild

    boolean removeChild(ConfigurationNode child)

  Removes the given node from this node's children.

  Parameters:
    `child` - the child node to be removed
  Returns:
    a flag if the node could be removed

### removeChild

    boolean removeChild(String childName)

  Removes all child nodes of this node with the given name.

  Parameters:
    `childName` - the name of the children to be removed
  Returns:
    a flag if at least one child was removed

### removeChildren

    void removeChildren()

  Removes all children from this node.

### isAttribute

    boolean isAttribute()

  Returns a flag whether this node is an attribute.

  Returns:
    a flag whether this node is an attribute

### setAttribute

    void setAttribute(boolean f)

  Sets a flag whether this node is an attribute.

  Parameters:
    `f` - the attribute flag

### getAttributes

    List<ConfigurationNode> getAttributes()

  Returns a list with this node's attributes. Attributes are also modeled as `ConfigurationNode` objects.

  Returns:
    a list with the attributes

### getAttributeCount

    int getAttributeCount()

  Returns the number of attributes of this node.

  Returns:
    the number of attributes

### getAttributes

    List<ConfigurationNode> getAttributes(String name)

  Returns a list with the attribute nodes with the given name. Attributes with same names can be added multiple times, so the return value of this method is a list.

  Parameters:
    `name` - the name of the attribute
  Returns:
    the attribute nodes with this name (never null)

### getAttributeCount

    int getAttributeCount(String name)

  Returns the number of attributes with the given name.

  Parameters:
    `name` - the name of the attribute
  Returns:
    the number of attributes with this name

### getAttribute

    ConfigurationNode getAttribute(int index)

  Returns the attribute node with the given index. If no such index exists, an exception will be thrown.

  Parameters:
    `index` - the index
  Returns:
    the attribute node with this index

### removeAttribute

    boolean removeAttribute(ConfigurationNode node)

  Removes the specified attribute from this node.

  Parameters:
    `node` - the attribute to remove
  Returns:
    a flag if the node could be removed

### removeAttribute

    boolean removeAttribute(String name)

  Removes all attributes with the given name.

  Parameters:
    `name` - the name of the attributes to be removed
  Returns:
    a flag if at least one attribute was removed

### removeAttributes

    void removeAttributes()

  Removes all attributes of this node.

### addAttribute

    void addAttribute(ConfigurationNode attr)

  Adds the specified attribute to this node

  Parameters:
    `attr` - the attribute node

### isDefined

    boolean isDefined()

  Returns a flag if this node is defined. This means that the node contains some data.

  Returns:
    a flag whether this node is defined

### visit

    void visit(ConfigurationNodeVisitor visitor)

  Visits this node and all its sub nodes. This method provides a simple means for going through a hierarchical structure of configuration nodes.

  Parameters:
    `visitor` - the visitor
  See Also:
    `ConfigurationNodeVisitor`

### clone

    Object clone()

  Returns a copy of this node.

  Returns:
    the copy

Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.