org.base.apps.xml.elem.impl
Class BaseElement

java.lang.Object
  extended by org.base.apps.xml.elem.impl.BaseElement
All Implemented Interfaces:
Element

public class BaseElement
extends Object
implements Element

Default implementation of Element.

Author:
Kevan Simpson

Constructor Summary
BaseElement()
           
 
Method Summary
 Element addAttribute(Attr attr)
          Adds the specified attribute.
 Element addChild(Element elem)
          Adds the specified child Element.
 Element appendText(String text)
          Appends text to this element's character content.
 Attr getAttribute(String name)
          Fetches an attribute by name.
protected  Map<String,Attr> getAttributeMap()
           
 Iterator<Attr> getAttributes()
          Fetches this Element's attributes.
protected  StringBuffer getBuffer()
           
 Element getChild(int index)
          Fetches a child Element by index.
protected  List<Element> getChildList()
           
 Iterator<Element> getChildren()
          Returns this Element's children.
 ElementContext getContext()
          Returns the context of this Element.
 Element getParent()
          Returns the element's parent, which may be null.
 Tag getTag()
          Returns the element tag.
 String getText()
          Returns the character content of this Element.
 Element removeAttribute(Attr attr)
          Remove the given attribute.
 Element removeAttribute(String name)
          Remove an attribute by name.
 Element removeChild(Element elem)
          Remove the specified child Element.
 Element removeChild(int index)
          Remove a child Element by index.
protected  void setAttributeMap(Map<String,Attr> attributeMap)
           
protected  void setBuffer(StringBuffer buffer)
           
protected  void setChildList(List<Element> childList)
           
 Element setContext(ElementContext ctx)
          Sets the context of this Element.
 Element setParent(Element parent)
          Sets the parent of this Element.
protected  void setTag(Tag tag)
           
 Element setText(String text)
          Sets the character content of this Element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseElement

public BaseElement()
Method Detail

getTag

public Tag getTag()
Description copied from interface: Element
Returns the element tag.

Specified by:
getTag in interface Element
Returns:
the element tag.
See Also:
Element.getTag()

addAttribute

public Element addAttribute(Attr attr)
Description copied from interface: Element
Adds the specified attribute.

Specified by:
addAttribute in interface Element
Parameters:
attr - The attribute to add.
Returns:
this Element
See Also:
Element.addAttribute(org.base.apps.xml.elem.Attr)

getAttribute

public Attr getAttribute(String name)
Description copied from interface: Element
Fetches an attribute by name.

Specified by:
getAttribute in interface Element
Parameters:
name - The attribute name.
Returns:
the attribute or null, if no attribute with the given name exists
See Also:
Element.getAttribute(java.lang.String)

getAttributes

public Iterator<Attr> getAttributes()
Description copied from interface: Element
Fetches this Element's attributes.

Specified by:
getAttributes in interface Element
Returns:
this Element's attributes.
See Also:
Element.getAttributes()

removeAttribute

public Element removeAttribute(Attr attr)
Description copied from interface: Element
Remove the given attribute.

Specified by:
removeAttribute in interface Element
Parameters:
attr - The attribute to remove
Returns:
this Element
See Also:
Element.removeAttribute(org.base.apps.xml.elem.Attr)

removeAttribute

public Element removeAttribute(String name)
Description copied from interface: Element
Remove an attribute by name.

Specified by:
removeAttribute in interface Element
Parameters:
name - The name of the attribute to remove
Returns:
this Element
See Also:
Element.removeAttribute(java.lang.String)

addChild

public Element addChild(Element elem)
Description copied from interface: Element
Adds the specified child Element.

Specified by:
addChild in interface Element
Parameters:
elem - The child to add.
Returns:
this Element
See Also:
Element.addChild(org.base.apps.xml.elem.Element)

getChild

public Element getChild(int index)
Description copied from interface: Element
Fetches a child Element by index.

Specified by:
getChild in interface Element
Parameters:
index - The index of the child to fetch
Returns:
the child or null, if no child with the given name exists
See Also:
Element.getChild(int)

getChildren

public Iterator<Element> getChildren()
Description copied from interface: Element
Returns this Element's children.

Specified by:
getChildren in interface Element
Returns:
this Element's children
See Also:
Element.getChildren()

removeChild

public Element removeChild(Element elem)
Description copied from interface: Element
Remove the specified child Element.

Specified by:
removeChild in interface Element
Parameters:
elem - The child to remove.
Returns:
this Element
See Also:
Element.removeChild(org.base.apps.xml.elem.Element)

removeChild

public Element removeChild(int index)
Description copied from interface: Element
Remove a child Element by index.

Specified by:
removeChild in interface Element
Parameters:
index - The index of the child to remove
Returns:
this Element
See Also:
Element.removeChild(int)

getParent

public Element getParent()
Description copied from interface: Element
Returns the element's parent, which may be null.

Specified by:
getParent in interface Element
Returns:
the element's parent or null.
See Also:
Element.getParent()

setParent

public Element setParent(Element parent)
Description copied from interface: Element
Sets the parent of this Element.

Specified by:
setParent in interface Element
Parameters:
parent - The parent to set
Returns:
this Element
See Also:
Element.setParent(org.base.apps.xml.elem.Element)

getContext

public ElementContext getContext()
Description copied from interface: Element
Returns the context of this Element.

Specified by:
getContext in interface Element
Returns:
the context of this Element.
See Also:
Element.getContext()

setContext

public Element setContext(ElementContext ctx)
Description copied from interface: Element
Sets the context of this Element.

Specified by:
setContext in interface Element
Parameters:
ctx - The context to set
Returns:
this Element
See Also:
Element.setContext(org.base.apps.xml.elem.ElementContext)

appendText

public Element appendText(String text)
Description copied from interface: Element
Appends text to this element's character content.

Specified by:
appendText in interface Element
Parameters:
text - The content to append.
Returns:
this Element
See Also:
Element.appendText(java.lang.String)

getText

public String getText()
Description copied from interface: Element
Returns the character content of this Element.

Specified by:
getText in interface Element
Returns:
the character content of this Element.
See Also:
Element.getText()

setText

public Element setText(String text)
Description copied from interface: Element
Sets the character content of this Element.

Specified by:
setText in interface Element
Parameters:
text - The character content to set
Returns:
this Element
See Also:
Element.setText(java.lang.String)

getAttributeMap

protected Map<String,Attr> getAttributeMap()
Returns:
the mAttributeMap

setAttributeMap

protected void setAttributeMap(Map<String,Attr> attributeMap)
Parameters:
attributeMap - the attributeMap to set

getChildList

protected List<Element> getChildList()
Returns:
the child list

getBuffer

protected StringBuffer getBuffer()
Returns:
the text buffer

setBuffer

protected void setBuffer(StringBuffer buffer)
Parameters:
buffer - the buffer to set

setChildList

protected void setChildList(List<Element> childList)
Parameters:
childList - the child list to set

setTag

protected void setTag(Tag tag)
Parameters:
tag - the tag to set

Please visit Base Apps, hosted on Sourceforge.net.

Copyright 2011, Blue Agate Software Entity (BASE)