org.apache.felix.ipojo.metadata
Class Element

java.lang.Object
  extended by org.apache.felix.ipojo.metadata.Element

public class Element
extends Object

An element represents an XML Element. It contains a name, a namepace, Attribute objects and sub-elements. This class is used to parse iPOJO metadata.

Author:
Felix Project Team

Constructor Summary
Element(String name, String ns)
          Creates an Element.
 
Method Summary
 void addAttribute(Attribute att)
          Adds a attribute.
 void addElement(Element elem)
          Adds a sub-element.
 boolean containsAttribute(String name)
          Does the element contain an attribute of the name given in parameter.
 boolean containsElement(String name)
          Does the element contain a sub-element of the type given in parameter.
 boolean containsElement(String name, String ns)
          Does the element contain a sub-element of the type given in parameter.
 String getAttribute(String name)
          Returns the value of the attribute given in parameter.
 String getAttribute(String name, String ns)
          Returns the value of the attribute "name" of the namespace "ns".
 Attribute[] getAttributes()
          Gets element attributes.
 Element[] getElements()
          Gets sub-elements.
 Element[] getElements(String name)
          Gets the elements array of the element type given in parameter.
 Element[] getElements(String name, String ns)
          Gets the elements array of the element type given in parameter.
 String getName()
          Gets element name.
 String getNameSpace()
          Gets element namespace.
 void removeAttribute(Attribute att)
          Removes an attribute.
 void removeElement(Element elem)
          Removes a sub-element.
 String toString()
          To String method.
 String toXMLString()
          Gets the XML form of this element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Element

public Element(String name,
               String ns)
Creates an Element.

Parameters:
name - the name of the element
ns - the namespace of the element
Method Detail

getElements

public Element[] getElements()
Gets sub-elements. If no sub-elements, an empty array is returned.

Returns:
the sub elements

getAttributes

public Attribute[] getAttributes()
Gets element attributes. If no attributes, an empty array is returned.

Returns:
the attributes

getName

public String getName()
Gets element name.

Returns:
the name of the element

getNameSpace

public String getNameSpace()
Gets element namespace.

Returns:
the namespace of the element

getAttribute

public String getAttribute(String name)
Returns the value of the attribute given in parameter.

Parameters:
name - the name of the searched attribute
Returns:
the value of the attribute given in parameter, null if the attribute does not exist

getAttribute

public String getAttribute(String name,
                           String ns)
Returns the value of the attribute "name" of the namespace "ns".

Parameters:
name - the name of the attribute to find
ns - the namespace of the attribute to find
Returns:
the String value of the attribute, or null if the attribute is not found.

addElement

public void addElement(Element elem)
Adds a sub-element.

Parameters:
elem - the element to add

removeElement

public void removeElement(Element elem)
Removes a sub-element.

Parameters:
elem - the element to remove

addAttribute

public void addAttribute(Attribute att)
Adds a attribute.

Parameters:
att - the attribute to add

removeAttribute

public void removeAttribute(Attribute att)
Removes an attribute.

Parameters:
att - the attribute to remove

getElements

public Element[] getElements(String name)
Gets the elements array of the element type given in parameter. This method looks for an empty namespace.

Parameters:
name - the type of the element to find (element name)
Returns:
the resulting element array (null if the search failed)

getElements

public Element[] getElements(String name,
                             String ns)
Gets the elements array of the element type given in parameter.

Parameters:
name - the type of the element to find (element name)
ns - the namespace of the element
Returns:
the resulting element array (null if the search failed)

containsElement

public boolean containsElement(String name)
Does the element contain a sub-element of the type given in parameter.

Parameters:
name - the type of the element to check.
Returns:
true if the element contains an element of the type "name"

containsElement

public boolean containsElement(String name,
                               String ns)
Does the element contain a sub-element of the type given in parameter.

Parameters:
name - the type of the element to check.
ns - the namespace of the element to check.
Returns:
true if the element contains an element of the type "name"

containsAttribute

public boolean containsAttribute(String name)
Does the element contain an attribute of the name given in parameter.

Parameters:
name - the name of the element
Returns:
true if the element contains an attribute of the type "name"

toXMLString

public String toXMLString()
Gets the XML form of this element.

Returns:
the XML snippet representing this element.

toString

public String toString()
To String method.

Overrides:
toString in class Object
Returns:
the String form of this element.
See Also:
Object.toString()


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.