tuwien.auto.calimero.xml.def
Class DefaultElement

java.lang.Object
  extended by tuwien.auto.calimero.xml.def.DefaultElement
All Implemented Interfaces:
Element

public class DefaultElement
extends java.lang.Object
implements Element

Default implementation of XML element.


Constructor Summary
DefaultElement(java.lang.String name)
          Creates a new element name.
 
Method Summary
 void addAttribute(Attribute a)
          Adds a new attribute associated with this element.
 java.lang.String getAttribute(java.lang.String name)
          Returns the value of the attribute with name.
 java.lang.String getCharacterData()
          Returns the character data contained in this element.
 java.lang.String getName()
          Returns the name of this element, the element type.
 boolean hasAttribute(java.lang.String name)
          Returns whether an attribute with the given name is associated with this element.
 boolean isEmptyElementTag()
          Returns whether this element uses an empty element tag to indicate an empty element.
 void setCharacterData(java.lang.String data)
          Sets the character data contained in this element.
 void setEmptyElementTag(boolean empty)
          Determines if this element uses an empty element tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultElement

public DefaultElement(java.lang.String name)
Creates a new element name.

Parameters:
name - name of element, the element's type
Method Detail

addAttribute

public final void addAttribute(Attribute a)
Description copied from interface: Element
Adds a new attribute associated with this element.

Specified by:
addAttribute in interface Element
Parameters:
a - the attribute to add

getAttribute

public final java.lang.String getAttribute(java.lang.String name)
Description copied from interface: Element
Returns the value of the attribute with name.

Specified by:
getAttribute in interface Element
Parameters:
name - name of attribute to get attribute value
Returns:
value as String, or null if no such attribute

getCharacterData

public final java.lang.String getCharacterData()
Description copied from interface: Element
Returns the character data contained in this element.

Character data is the element's content without markup. No formatting is done on character data.
Put it more simple, character data is the actual value information (in textual format) of an element.

Specified by:
getCharacterData in interface Element
Returns:
character data as String or null if no data available

getName

public final java.lang.String getName()
Description copied from interface: Element
Returns the name of this element, the element type.

Specified by:
getName in interface Element
Returns:
name as string, the element's type

hasAttribute

public boolean hasAttribute(java.lang.String name)
Description copied from interface: Element
Returns whether an attribute with the given name is associated with this element.

Specified by:
hasAttribute in interface Element
Parameters:
name - attribute name
Returns:
true if an attribute with the given name is associated with this element, false otherwise

isEmptyElementTag

public final boolean isEmptyElementTag()
Description copied from interface: Element
Returns whether this element uses an empty element tag to indicate an empty element.

An element with no content is said to be empty. An empty element tag is of the form '<' Name (S Attribute)* S? '/>', with S being space. Note that if this method returns false, it does not imply this element has any content, returned by Element.getCharacterData().

Specified by:
isEmptyElementTag in interface Element
Returns:
true if empty element with empty element tag, false otherwise

setCharacterData

public final void setCharacterData(java.lang.String data)
Description copied from interface: Element
Sets the character data contained in this element.

If new character data is set, the empty element tag is set false.

Specified by:
setCharacterData in interface Element
Parameters:
data - character data of this element, null for no data

setEmptyElementTag

public final void setEmptyElementTag(boolean empty)
Description copied from interface: Element
Determines if this element uses an empty element tag.

If empty element tag is used, this element also has no content.

Specified by:
setEmptyElementTag in interface Element
Parameters:
empty - true if empty element, false otherwise