EAF 7.6 Util

org.enhydra.xml
Class HashMapElement

java.lang.Object
  extended by org.enhydra.xml.NodeImpl
      extended by org.enhydra.xml.ElementImpl
          extended by org.enhydra.xml.HashMapElement
All Implemented Interfaces:
org.w3c.dom.Element, org.w3c.dom.Node, org.w3c.dom.NodeList
Direct Known Subclasses:
SearchElement

public class HashMapElement
extends ElementImpl

Version:
1.0
Author:
Tweety A class representing a node in a meta-data tree, which implements the

Namespaces are ignored in this implementation. The terms "tag name" and "node name" are always considered to be synonymous.


Field Summary
protected  java.util.HashMap children
          All Element type children of this Element
 
Fields inherited from class org.enhydra.xml.ElementImpl
attributes, MASK_NAME, MASK_NAME_START
 
Fields inherited from class org.enhydra.xml.NodeImpl
firstChild, lastChild, nextSibling, nodeName, nodeValue, numChildren, ownerDocument, parent, previousSibling, type
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
  HashMapElement()
          Constructs an empty HashMapElement.
  HashMapElement(org.w3c.dom.Document ownerDoc, java.lang.String name)
          Constructs an HashMapElement with the given document owner and node name.
protected HashMapElement(org.w3c.dom.Document ownerDoc, java.lang.String nodeName, short type, java.lang.String value)
          Constructs an HashMapElement with the given document owner, node name, node type and node value.
  HashMapElement(HashMapElement element)
          Constructs a HashMapElement from the given node, without creating entire children subtree.
  HashMapElement(org.w3c.dom.Node node)
          Constructs an HashMapElement from a given node (creates the children subtree too), as a Node
  HashMapElement(org.w3c.dom.Node node, boolean deep)
          Constructs an HashMapElement from a given node, as a Node, and deep as boolean.
 
Method Summary
 org.w3c.dom.Node cloneNode(boolean deep)
          Returns a duplicate of this node.
 org.w3c.dom.NodeList getChildrenByTagName(java.lang.String name)
          Returns the list of all children nodes with the given tag name.
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
          Returns all Element nodes with given name, searching by all sub nodes from this node.
 org.w3c.dom.Element getFirstChildByTagName(java.lang.String name)
          Returns the first child Element with the given tag name.
 org.w3c.dom.Element getNextSameNameNode()
          Returns the next Element node (if exists) with the same tag name.
 java.lang.String getText()
          Returns the concatenation of values of all text type children.
 boolean hasElementChildNodes()
          Returns true if this node has child nodes.
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Inserts the node newChild before the existing child node refChild.
protected  org.w3c.dom.Node newElementInstance(org.w3c.dom.Node node)
          Creates new instance of the HashMapElement class from the given Node.
static org.w3c.dom.Element newInstance(org.w3c.dom.Document document)
          Creates new instance of HashMapElement from a given document as a Document.
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Removes the child node indicated by oldChild from the list of children, and returns it.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
 void setText(java.lang.String text)
          Set the value of the first text child node to the given text, and remove all other text child nodes.
 
Methods inherited from class org.enhydra.xml.ElementImpl
beginToString, compareDocumentPosition, endToString, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getBaseURI, getElementsByTagNameNS, getFeature, getNamespaceURI, getSchemaTypeInfo, getTagName, getTextContent, getUserData, hasAttribute, hasAttributeNS, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isValidName, lookupNamespaceURI, lookupPrefix, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setTextContent, setUserData
 
Methods inherited from class org.enhydra.xml.NodeImpl
appendChild, getChildNodes, getFirstChild, getLastChild, getLength, getLocalName, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, initNodeImplChildren, isSupported, item, newCommentInstance, newDefaultInstance, newTextInstance, normalize, setNodeValue, setPrefix, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getChildNodes, getFirstChild, getLastChild, getLocalName, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasChildNodes, isSupported, normalize, setNodeValue, setPrefix
 

Field Detail

children

protected java.util.HashMap children
All Element type children of this Element

Constructor Detail

HashMapElement

public HashMapElement()
Constructs an empty HashMapElement.


HashMapElement

public HashMapElement(HashMapElement element)
Constructs a HashMapElement from the given node, without creating entire children subtree.

Parameters:
element, - as a HashMapElement.

HashMapElement

public HashMapElement(org.w3c.dom.Document ownerDoc,
                      java.lang.String name)
Constructs an HashMapElement with the given document owner and node name.

Parameters:
ownerDoc - the document owner of the node, as a Document.
nodeName - the name of the node, as a String.

HashMapElement

protected HashMapElement(org.w3c.dom.Document ownerDoc,
                         java.lang.String nodeName,
                         short type,
                         java.lang.String value)
Constructs an HashMapElement with the given document owner, node name, node type and node value.

Parameters:
ownerDoc - the document owner of the node, as a Document.
nodeName - the name of the node, as a String.
type - the type of the node, as a short.
value - the value of the node, as a String.

HashMapElement

public HashMapElement(org.w3c.dom.Node node)
Constructs an HashMapElement from a given node (creates the children subtree too), as a Node

Parameters:
node, - as a Node.

HashMapElement

public HashMapElement(org.w3c.dom.Node node,
                      boolean deep)
Constructs an HashMapElement from a given node, as a Node, and deep as boolean.

Parameters:
node, - as a Node.
deep - if true, recursively clone the subtree under the specified node; if false, clone only the node itself.
Method Detail

newElementInstance

protected org.w3c.dom.Node newElementInstance(org.w3c.dom.Node node)
Creates new instance of the HashMapElement class from the given Node.

Overrides:
newElementInstance in class NodeImpl
Parameters:
node, - as a Node.
Returns:
new instance of the HashMapElement class.

newInstance

public static org.w3c.dom.Element newInstance(org.w3c.dom.Document document)
Creates new instance of HashMapElement from a given document as a Document.

Parameters:
document - document.
Returns:
new Element node as a root of the Document.

insertBefore

public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node refChild)
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children.

Specified by:
insertBefore in interface org.w3c.dom.Node
Overrides:
insertBefore in class ElementImpl
Parameters:
newChild - the Node to insert.
refChild - the reference Node.
Returns:
the node being inserted.
Throws:
java.lang.IllegalArgumentException - if newChild is null.

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.

Specified by:
replaceChild in interface org.w3c.dom.Node
Overrides:
replaceChild in class ElementImpl
Parameters:
newChild - the Node to insert.
oldChild - the Node to be replaced.
Returns:
the node replaced.
Throws:
java.lang.IllegalArgumentException - if newChild is null.

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.

Specified by:
removeChild in interface org.w3c.dom.Node
Overrides:
removeChild in class ElementImpl
Parameters:
oldChild - the Node to be removed.
Returns:
the node removed.
Throws:
java.lang.IllegalArgumentException - if oldChild is null.

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Returns a duplicate of this node. The duplicate node has no parent (getParentNode returns null). If a shallow clone is being performed (deep is false), the new node will not have any children or siblings. If a deep clone is being performed, the new node will form the root of a complete cloned subtree.

Specified by:
cloneNode in interface org.w3c.dom.Node
Overrides:
cloneNode in class ElementImpl
Parameters:
deep - if true, recursively clone the subtree under the specified node; if false, clone only the node itself.
Returns:
the duplicate node.

getElementsByTagName

public org.w3c.dom.NodeList getElementsByTagName(java.lang.String name)
Returns all Element nodes with given name, searching by all sub nodes from this node.

Specified by:
getElementsByTagName in interface org.w3c.dom.Element
Overrides:
getElementsByTagName in class ElementImpl
Parameters:
name - tag name.
Returns:
all Element vith given name as NodeList.

hasElementChildNodes

public boolean hasElementChildNodes()
Returns true if this node has child nodes.

Overrides:
hasElementChildNodes in class ElementImpl
Returns:
true if this node has children.

getChildrenByTagName

public org.w3c.dom.NodeList getChildrenByTagName(java.lang.String name)
Returns the list of all children nodes with the given tag name.

Parameters:
name - tag name.
Returns:
the list of all children nodes with the given tag name.

getFirstChildByTagName

public org.w3c.dom.Element getFirstChildByTagName(java.lang.String name)
Returns the first child Element with the given tag name.

Parameters:
name - tag name.
Returns:
the first child Element with the given tag name.

getNextSameNameNode

public org.w3c.dom.Element getNextSameNameNode()
Returns the next Element node (if exists) with the same tag name.

Returns:
the next Element node (if exists) with the same tag name.

getText

public java.lang.String getText()
Returns the concatenation of values of all text type children.

Returns:
the concatenation of values of all text type children.

setText

public void setText(java.lang.String text)
Set the value of the first text child node to the given text, and remove all other text child nodes.

Parameters:
text - new text.

EAF 7.6 Util