org.xpresso.xml
Class Element

java.lang.Object
  extended by org.xpresso.xml.XmlContent
      extended by org.xpresso.xml.Element
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
ConcurrentElement

public class Element
extends XmlContent
implements java.lang.Cloneable

Element represents a level in the XML tree. If stacked in the Document,
any further content will be added as child of this Element.

This code is under the LGPL v3 licence.

Author:
Alexis Dufrenoy
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.xpresso.xml.XmlContent
content
 
Constructor Summary
protected Element(java.lang.String label)
          Constructor creating a new Element using a given label.
 
Method Summary
 void addAttribute(java.lang.String key, java.lang.String value)
          Adds an attribute to the Element, using given key and value.
 Element clone()
           
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
          Return the map containing all attributes
 java.lang.String getLabel()
          Returns the label of the Element
 java.lang.String getText()
          Return the Element as an empty element
static boolean isValid(java.lang.String content)
          Tests if the given String is a valid element or attribut name
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Element

protected Element(java.lang.String label)
           throws IllegalContentException
Constructor creating a new Element using a given label.

Parameters:
label - The label of the Element
Throws:
IllegalContentException - Thrown if label contains invalid characters. Valid characters are uppercase and
lower case letters, digits, ":", "-", "_" and "."
Method Detail

addAttribute

public void addAttribute(java.lang.String key,
                         java.lang.String value)
                  throws IllegalContentException
Adds an attribute to the Element, using given key and value.

Parameters:
key - the key part of the attribute
value - the value part of the attribute
Throws:
IllegalContentException - Thrown if label contains invalid characters. Valid characters are uppercase and
lower case letters, numbers, ":", "-", "_" and "."

getLabel

public java.lang.String getLabel()
Returns the label of the Element

Returns:
the label of the attribute

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Return the map containing all attributes

Returns:
the map

getText

public java.lang.String getText()
Return the Element as an empty element

Overrides:
getText in class XmlContent
Returns:
text for an empty element

isValid

public static boolean isValid(java.lang.String content)
Tests if the given String is a valid element or attribut name

Parameters:
content - text to be tested
Returns:
true if the text is valid, false else

clone

public Element clone()
              throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException