net.smartlab.config
Class Node

java.lang.Object
  extended by net.smartlab.config.Element
      extended by net.smartlab.config.Node
Direct Known Subclasses:
Configuration

public class Node
extends Element

Author:
rlogiacco

Field Summary
protected  java.util.Map attributes
          The node attributes.
protected  java.util.List children
          The node sub elements.
protected  java.lang.String content
          The node direct contents.
protected  boolean resolved
          Marks this node as already resolved for references.
 
Fields inherited from class net.smartlab.config.Element
name, parent
 
Constructor Summary
protected Node(Node parent, java.lang.String name, org.xml.sax.Attributes attributes)
          Constructs a generic empty node.
 
Method Summary
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the attribute whose name equals the specified one or null if the element doesn't contain a such named attribute.
 java.util.Collection getAttributeNames()
          Returns all the attributes names of this element.
 java.util.Collection getAttributes()
          Returns all the attributes of this element.
 java.lang.String getContent()
          Returns the element content as a string.
 Element getElement(java.lang.String name, java.lang.String attribute, java.lang.String value)
          Returns the first contained element whose name equals the given one and whose attribute list defines an attribute whose name and values matches the given parameters.
 java.util.Collection getElements()
          Returns all the contained elements.
 java.util.Collection getElements(java.lang.String name)
          Returns all the contained elements which name equals the given one.
 java.lang.String getId()
          Returns the unique identifier associated with this element.
 void resolve()
          Resolves the element reference.
protected  Node resolve(java.lang.String name, java.lang.String id)
          Resolves the requested reference through its children nodes or, recursively in the parent node children.
protected  void setContent(java.lang.String content)
          Sets the content.
 
Methods inherited from class net.smartlab.config.Element
getAttributeValues, getElement, getElement, getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected java.util.List children
The node sub elements.


attributes

protected java.util.Map attributes
The node attributes.


content

protected java.lang.String content
The node direct contents.


resolved

protected boolean resolved
Marks this node as already resolved for references.

Constructor Detail

Node

protected Node(Node parent,
               java.lang.String name,
               org.xml.sax.Attributes attributes)
Constructs a generic empty node.

Parameters:
parent - the node containing this node.
name - a name associated to this node.
attributes - a set of attributes associated with this node.
Method Detail

getId

public java.lang.String getId()
Description copied from class: Element
Returns the unique identifier associated with this element.

Specified by:
getId in class Element
Returns:
the unique identifier associated with this element.
See Also:
Element.getId()

getElements

public java.util.Collection getElements()
Description copied from class: Element
Returns all the contained elements.

Specified by:
getElements in class Element
Returns:
an unmodifiable Collection which enumerates the contained elements.
See Also:
Element.getElements()

getElements

public java.util.Collection getElements(java.lang.String name)
Description copied from class: Element
Returns all the contained elements which name equals the given one.

Specified by:
getElements in class Element
Parameters:
name - the name of the elements to search for.
Returns:
an unmodifiable Collection which enumerates the contained elements which name equals the given one.
See Also:
Element.getElements(java.lang.String)

getElement

public Element getElement(java.lang.String name,
                          java.lang.String attribute,
                          java.lang.String value)
                   throws ConfigurationException
Description copied from class: Element
Returns the first contained element whose name equals the given one and whose attribute list defines an attribute whose name and values matches the given parameters.

Specified by:
getElement in class Element
Parameters:
name - the name of the element to search for.
attribute - attribute the name of the attribute which must be defined on the element.
value - the value the attribute must match.
Returns:
the contained Element or null if the search fails.
Throws:
ConfigurationException - if something wrong occurs during the operation.
See Also:
Element.getElement(java.lang.String, java.lang.String, java.lang.String)

getAttributeNames

public java.util.Collection getAttributeNames()
Description copied from class: Element
Returns all the attributes names of this element.

Specified by:
getAttributeNames in class Element
Returns:
an unmodifiable Collection which enumerates the attributes of this element.
See Also:
Element.getAttributeNames()

getAttributes

public java.util.Collection getAttributes()
Description copied from class: Element
Returns all the attributes of this element.

Specified by:
getAttributes in class Element
Returns:
an unmodifiable Collection which enumerates the attributes of this element.
See Also:
Element.getAttributes()

getAttribute

public java.lang.String getAttribute(java.lang.String name)
Description copied from class: Element
Returns the value of the attribute whose name equals the specified one or null if the element doesn't contain a such named attribute.

Specified by:
getAttribute in class Element
Parameters:
name - the name of the attribute to get.
Returns:
a String instance representing the attribute value or null if no attribute with the specified name was found.
See Also:
Element.getAttribute(java.lang.String)

getContent

public java.lang.String getContent()
Description copied from class: Element
Returns the element content as a string.

Specified by:
getContent in class Element
Returns:
the characters contained between the tag boundaries.
See Also:
Element.getContent()

setContent

protected void setContent(java.lang.String content)
Sets the content.

Parameters:
content - the content to set

resolve

public void resolve()
             throws ConfigurationException
Description copied from class: Element
Resolves the element reference.

Specified by:
resolve in class Element
Throws:
ConfigurationException - if something wrong occurs during the operation.
See Also:
Element.resolve()

resolve

protected Node resolve(java.lang.String name,
                       java.lang.String id)
                throws ConfigurationException
Resolves the requested reference through its children nodes or, recursively in the parent node children.

Parameters:
name - the referenced element name.
id - the referenced element identifier.
Returns:
the referenced element.
Throws:
ConfigurationException - if the referenced element cannot be found in the wntire configuration tree.


Copyright © 2002-2008 SmartLab s.r.l.. All Rights Reserved.