SMACS

smacs.xngr.browser.exchanger
Class XngrElement

java.lang.Object
  extended byorg.dom4j.tree.AbstractNode
      extended byorg.dom4j.tree.AbstractBranch
          extended byorg.dom4j.tree.AbstractElement
              extended byorg.dom4j.tree.DefaultElement
                  extended bysmacs.xngr.browser.exchanger.XngrElement
All Implemented Interfaces:
Branch, Cloneable, Element, ExchangerElement, Node, Serializable, XElement

public class XngrElement
extends DefaultElement
implements ExchangerElement

The default implementation of the XElement interface.

Author:
Edwin Dankert
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.dom4j.tree.AbstractElement
EMPTY_ITERATOR, EMPTY_LIST, USE_STRINGVALUE_SEPARATOR, VERBOSE_TOSTRING
 
Fields inherited from class org.dom4j.tree.AbstractBranch
DEFAULT_CONTENT_LIST_SIZE, outputFormat
 
Fields inherited from class org.dom4j.tree.AbstractNode
NODE_TYPE_NAMES
 
Fields inherited from interface org.dom4j.Node
ANY_NODE, ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_REFERENCE_NODE, MAX_NODE_TYPE, NAMESPACE_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE, UNKNOWN_NODE
 
Constructor Summary
XngrElement(QName name)
          Constructs a default element with a dom4j element.
XngrElement(String name)
          Constructs a default element with an initial name.
XngrElement(XElementType type)
          Constructs a default element with an initial type.
 
Method Summary
 void add(XElement child)
          Adds a child element to this element.
 String asXML()
           
 XDocument document()
          Returns the document for this element.
 void document(XDocument document)
          Sets the document for this element.
 String getAttribute(String name)
          Returns the value of the attribute with the name.
 String[][] getAttributes()
          Returns a 2 dimensional array of attributes.
 XElement getElement(String name)
          Returns the first element for the given name.
 XElement[] getElements()
          Returns all the child elements of this element.
 XElement[] getElements(String name)
          Returns all the child elements with a given name for this element.
 String getName()
          Returns the (local)name for this element.
 XElementType getType()
          Returns the type of this element.
 String getUniversalName()
          Returns the universal name for this element.
 String getValue()
          Gets the text value of this element.
 XUrl getXUrl()
          Returns the url of this element.
 boolean isRoot()
          A check wether this element is the root element.
 String namespace()
          Returns the namespace for this element.
 ExchangerElement newExchangerElement(QName name)
          Constructs a default element with a dom4j element.
 ExchangerElement newExchangerElement(String name)
          Constructs a default element with an initial name.
 ExchangerElement newExchangerElement(XElementType type)
          Constructs a default element with an initial type.
 XElement parent()
          Returns the parent of this element.
 String path()
          Returns an XPath result, uniquely identifying this element.
 void putAttribute(String name, String value)
          Adds an attribute to the list of attributes or overwrites the attribute if the attribute name already exists.
 void remove(XElement child)
          Removes a child element from this element.
 void setValue(String text)
          Sets the text value of this element.
 String toString()
          Returns the contents of this element as an XML formatted String.
 
Methods inherited from class org.dom4j.tree.DefaultElement
add, additionalNamespaces, additionalNamespaces, addNewNode, attribute, attribute, attribute, attribute, attributeCount, attributeIterator, attributeList, attributeList, attributes, clearContent, clone, contentList, declaredNamespaces, element, element, element, elementIterator, elementIterator, elementIterator, elementIterator, elements, elements, elements, elements, getDocument, getDocumentFactory, getNamespaceForPrefix, getNamespaceForURI, getParent, getQName, getStringValue, getText, indexOf, node, nodeCount, nodeIterator, processingInstruction, processingInstructions, processingInstructions, remove, removeNode, removeProcessingInstruction, setAttributeList, setAttributes, setContent, setDocument, setParent, setQName, supportsParent
 
Methods inherited from class org.dom4j.tree.AbstractElement
accept, add, add, add, add, add, add, add, add, addAttribute, addAttribute, addCDATA, addComment, addElement, addEntity, addNamespace, addNode, addProcessingInstruction, addProcessingInstruction, addText, appendAttributes, attributeValue, attributeValue, attributeValue, attributeValue, childAdded, childRemoved, createAttributeList, createAttributeList, createCopy, createCopy, createCopy, createElement, createElement, createSingleIterator, elementText, elementText, elementTextTrim, elementTextTrim, ensureAttributesCapacity, getData, getNamespace, getNamespacePrefix, getNamespaceURI, getNodeType, getPath, getQName, getQualifiedName, getUniquePath, getXPathNameStep, getXPathResult, hasMixedContent, isRootElement, isTextOnly, normalize, remove, remove, remove, remove, remove, remove, remove, remove, setAttributes, setAttributeValue, setAttributeValue, setData, setName, setNamespace, setText, write
 
Methods inherited from class org.dom4j.tree.AbstractBranch
addElement, addElement, addElement, appendContent, content, contentRemoved, createContentList, createContentList, createEmptyList, createResultList, createSingleResultList, elementByID, elementID, getContentAsStringValue, getContentAsText, getTextTrim, hasContent, invalidNodeTypeAddException, isReadOnly, setProcessingInstructions
 
Methods inherited from class org.dom4j.tree.AbstractNode
asXPathResult, createPattern, createXPath, createXPathFilter, createXPathResult, detach, getNodeTypeName, getPath, getUniquePath, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, valueOf
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.dom4j.Element
add, add, add, add, add, addAttribute, addAttribute, addCDATA, addComment, addEntity, additionalNamespaces, addNamespace, addProcessingInstruction, addProcessingInstruction, addText, appendAttributes, attribute, attribute, attribute, attributeCount, attributeIterator, attributes, attributeValue, attributeValue, attributeValue, attributeValue, createCopy, createCopy, createCopy, declaredNamespaces, element, element, elementIterator, elementIterator, elementIterator, elements, elements, elements, elementText, elementText, elementTextTrim, elementTextTrim, getData, getNamespace, getNamespaceForPrefix, getNamespaceForURI, getNamespacePrefix, getNamespaceURI, getQName, getQName, getQualifiedName, getStringValue, getText, getTextTrim, getXPathResult, hasMixedContent, isRootElement, isTextOnly, remove, remove, remove, remove, remove, setAttributes, setAttributeValue, setAttributeValue, setData, setQName
 
Methods inherited from interface org.dom4j.Branch
add, add, add, add, addElement, addElement, addElement, appendContent, clearContent, content, elementByID, indexOf, node, nodeCount, nodeIterator, normalize, processingInstruction, processingInstructions, processingInstructions, remove, remove, remove, remove, removeProcessingInstruction, setContent, setProcessingInstructions
 
Methods inherited from interface org.dom4j.Node
accept, asXPathResult, clone, createXPath, detach, getDocument, getNodeType, getNodeTypeName, getParent, getPath, getPath, getUniquePath, getUniquePath, hasContent, isReadOnly, matches, numberValueOf, selectNodes, selectNodes, selectNodes, selectObject, selectSingleNode, setDocument, setName, setParent, setText, supportsParent, valueOf, write
 

Constructor Detail

XngrElement

public XngrElement(String name)
Constructs a default element with an initial name.

Parameters:
name - the unmutable name.

XngrElement

public XngrElement(XElementType type)
Constructs a default element with an initial type.

Parameters:
type - the unmutable name.

XngrElement

public XngrElement(QName name)
Constructs a default element with a dom4j element.

Method Detail

newExchangerElement

public ExchangerElement newExchangerElement(String name)
Description copied from interface: ExchangerElement
Constructs a default element with an initial name.

Specified by:
newExchangerElement in interface ExchangerElement
Parameters:
name - the unmutable name.

newExchangerElement

public ExchangerElement newExchangerElement(XElementType type)
Description copied from interface: ExchangerElement
Constructs a default element with an initial type.

Specified by:
newExchangerElement in interface ExchangerElement
Parameters:
type - the unmutable name.

newExchangerElement

public ExchangerElement newExchangerElement(QName name)
Description copied from interface: ExchangerElement
Constructs a default element with a dom4j element.

Specified by:
newExchangerElement in interface ExchangerElement

putAttribute

public void putAttribute(String name,
                         String value)
Adds an attribute to the list of attributes or overwrites the attribute if the attribute name already exists.

Specified by:
putAttribute in interface ExchangerElement
Parameters:
name - the name of the attribute.
value - the value of the attribute.

getAttributes

public String[][] getAttributes()
Returns a 2 dimensional array of attributes. where attribute[X][0] = name and where attribute[X][1] = value.

Specified by:
getAttributes in interface ExchangerElement
Returns:
a 2 dimesnional array of Strings.

getAttribute

public String getAttribute(String name)
Returns the value of the attribute with the name.

Specified by:
getAttribute in interface ExchangerElement
Parameters:
name - the name of the attribute.
Returns:
the attribute value.

getElement

public XElement getElement(String name)
Returns the first element for the given name.

Specified by:
getElement in interface ExchangerElement
Parameters:
name - the name of the element.
Returns:
the element.

getElements

public XElement[] getElements()
Returns all the child elements of this element.

Specified by:
getElements in interface ExchangerElement
Returns:
an array of elements.

getElements

public XElement[] getElements(String name)
Returns all the child elements with a given name for this element.

Specified by:
getElements in interface ExchangerElement
Parameters:
name - the name of the element.
Returns:
an array of elements.

namespace

public String namespace()
Returns the namespace for this element.

Specified by:
namespace in interface ExchangerElement
Returns:
a namespace representation.

getUniversalName

public String getUniversalName()
Returns the universal name for this element. The name is in the form: {namespace}localname

Specified by:
getUniversalName in interface ExchangerElement
Returns:
a universal name representation.

getName

public String getName()
Returns the (local)name for this element.

Specified by:
getName in interface ExchangerElement
Returns:
a name for the element.

isRoot

public boolean isRoot()
A check wether this element is the root element.

Specified by:
isRoot in interface ExchangerElement
Returns:
true when the element is the root element.

parent

public XElement parent()
Returns the parent of this element.

Specified by:
parent in interface ExchangerElement
Returns:
the parent element.

getValue

public String getValue()
Gets the text value of this element.

Specified by:
getValue in interface ExchangerElement
Returns:
the value of this element.

setValue

public void setValue(String text)
Sets the text value of this element.

Specified by:
setValue in interface ExchangerElement

add

public void add(XElement child)
Adds a child element to this element.

Specified by:
add in interface ExchangerElement

remove

public void remove(XElement child)
Removes a child element from this element.

Specified by:
remove in interface ExchangerElement

path

public String path()
Returns an XPath result, uniquely identifying this element.

Specified by:
path in interface ExchangerElement
Returns:
the XPath result identifying this element.

document

public void document(XDocument document)
Sets the document for this element.

Specified by:
document in interface ExchangerElement

document

public XDocument document()
Returns the document for this element. Will return null if the element does not have a document.

Specified by:
document in interface ExchangerElement
Returns:
the document.

getType

public XElementType getType()
Returns the type of this element.

Specified by:
getType in interface ExchangerElement
Returns:
the type.

getXUrl

public XUrl getXUrl()
Returns the url of this element.

Specified by:
getXUrl in interface ExchangerElement
Returns:
the xurl.

asXML

public String asXML()
Specified by:
asXML in interface ExchangerElement

toString

public String toString()
Returns the contents of this element as an XML formatted String.

Returns:
the XML formatted String.

SMACS