net.smartlab.config
Class Element

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

public abstract class Element
extends java.lang.Object

This class identifies a configuration element which can in turn contains other configuration elements. An element is composed by a name, a set of attributes which can be empty and, optionally, by its contents.

Author:
rlogiacco

Field Summary
protected  java.lang.String name
          The element name.
protected  Node parent
          The containing node.
 
Constructor Summary
protected Element(Node parent, java.lang.String name)
          Constructs an element with a givenparent node and name.
 
Method Summary
abstract  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.
abstract  java.util.Collection getAttributeNames()
          Returns all the attributes names of this element.
abstract  java.util.Collection getAttributes()
          Returns all the attributes of this element.
 java.util.Collection getAttributeValues(java.lang.String name)
          Returns an unmodifiable Collection build on the attribute value parsed as a comma separated list.
abstract  java.lang.String getContent()
          Returns the element content as a string.
 Element getElement(java.lang.String name)
          Returns the first contained element whose name equals the given one.
 Element getElement(java.lang.String name, java.lang.String attribute)
          Returns the first contained element whose name equals the given one and whose attribute list contains the given one.
abstract  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.
abstract  java.util.Collection getElements()
          Returns all the contained elements.
abstract  java.util.Collection getElements(java.lang.String name)
          Returns all the contained elements which name equals the given one.
abstract  java.lang.String getId()
          Returns the unique identifier associated with this element.
 java.lang.String getName()
          Returns the name of this configuration element.
abstract  void resolve()
          Resolves the element reference.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected Node parent
The containing node.


name

protected java.lang.String name
The element name.

Constructor Detail

Element

protected Element(Node parent,
                  java.lang.String name)
Constructs an element with a givenparent node and name.

Parameters:
parent - the node containing the element.
name - the element name.
Method Detail

getName

public java.lang.String getName()
Returns the name of this configuration element.

Returns:
a String representing the name of this configuration element.

getId

public abstract java.lang.String getId()
Returns the unique identifier associated with this element.

Returns:
the unique identifier associated with this element.

getElements

public abstract java.util.Collection getElements()
                                          throws ConfigurationException
Returns all the contained elements.

Returns:
an unmodifiable Collection which enumerates the contained elements.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getElements

public abstract java.util.Collection getElements(java.lang.String name)
                                          throws ConfigurationException
Returns all the contained elements which name equals the given one.

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.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getElement

public Element getElement(java.lang.String name)
                   throws ConfigurationException
Returns the first contained element whose name equals the given one.

Parameters:
name - the name of the element to search for.
Returns:
the contained Element or null if the search fails.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getElement

public Element getElement(java.lang.String name,
                          java.lang.String attribute)
                   throws ConfigurationException
Returns the first contained element whose name equals the given one and whose attribute list contains the given one.

Parameters:
name - the name of the element to search for.
attribute - the name of the attribute which must be defined on the element.
Returns:
the contained Element or null if the search fails.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getElement

public abstract Element getElement(java.lang.String name,
                                   java.lang.String attribute,
                                   java.lang.String value)
                            throws ConfigurationException
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.

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.

getAttributeNames

public abstract java.util.Collection getAttributeNames()
                                                throws ConfigurationException
Returns all the attributes names of this element.

Returns:
an unmodifiable Collection which enumerates the attributes of this element.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getAttribute

public abstract java.lang.String getAttribute(java.lang.String name)
                                       throws ConfigurationException
Returns the value of the attribute whose name equals the specified one or null if the element doesn't contain a such named attribute.

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.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getAttributes

public abstract java.util.Collection getAttributes()
                                            throws ConfigurationException
Returns all the attributes of this element.

Returns:
an unmodifiable Collection which enumerates the attributes of this element.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getAttributeValues

public java.util.Collection getAttributeValues(java.lang.String name)
                                        throws ConfigurationException
Returns an unmodifiable Collection build on the attribute value parsed as a comma separated list.

Parameters:
name - the name of the attribute whose value will be parsed as a comma separated list.
Returns:
an unmodifiable Collection which enumerates the attribute values parsed as a comma separated list.
Throws:
ConfigurationException - if something wrong occurs during the operation.

getContent

public abstract java.lang.String getContent()
                                     throws ConfigurationException
Returns the element content as a string.

Returns:
the characters contained between the tag boundaries.
Throws:
ConfigurationException - if the content couldn't be retrieved.

resolve

public abstract void resolve()
                      throws ConfigurationException
Resolves the element reference.

Throws:
ConfigurationException - if something wrong occurs during the operation.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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