ice.pilots.html4
Class DElement

java.lang.Object
  extended byice.storm.DynamicObject
      extended byice.pilots.html4.DNode
          extended byice.pilots.html4.DElement
All Implemented Interfaces:
Cloneable, Element, ElementCSSInlineStyle, EventTarget, HTMLElement, Node
Direct Known Subclasses:
DAppletElement, DFormElement, DHrefElement, DIFrameElement, DImageElement, DIsIndexElement, DMapElement, DOptionElement, DXmlElement, ice.pilots.html4.FormTypeElement

public class DElement
extends DNode
implements Element, HTMLElement, ElementCSSInlineStyle

Implementation of DOM Element. Can be used standalone


Field Summary
 
Fields inherited from class ice.pilots.html4.DNode
doc, first, last, next, parent, prev
 
Fields inherited from class ice.storm.DynamicObject
NOT_FOUND, SETD_IGNORE, SETD_NOT_FOUND, SETD_OK
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected DElement(DDocument doc, int id)
           
 
Method Summary
protected  void afterClone(boolean deep)
          This method is meant to be after the Object.clone() call.
protected  int attrNameToId(String name)
           
 Object execDynamicMethod(String name, Object[] args, DynEnv env)
          Perform function-like actions for `name' with the given args.
 String getAttribute(int attrNameId)
           
 String getAttribute(String name)
          Retrieves an attribute value by name.
 int getAttributeAsInt(String name)
          Retrieve the Attribute value as an integer.
 Attr getAttributeNode(String name)
          Retrieves an attribute node by name.
 Attr getAttributeNodeNS(String namespaceURI, String localName)
          Retrieves an Attr node by local name and namespace URI.
 String getAttributeNS(String namespaceURI, String localName)
          Retrieves an attribute value by local name and namespace URI.
 NamedNodeMap getAttributes()
          A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
 String getBgColor()
           
 Viewport getChildViewport()
          Find a viewport that this element holds if any.
 String getClassName()
          The class attribute of the element.
 int getClientLeft()
           
 int getClientTop()
           
 int getClientWidth()
          Retrieve the height of the visible element.
 String getColor()
           
 String getDir()
          Specifies the base direction of directionally neutral text and the directionality of tables.
 Object getDynamicValue(String name, DynEnv env)
          Returns the `key' field or Defs.NOT_FOUND if `name' does not exist.
 NodeList getElementsByTagName(String name)
          Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
          Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
protected  DynamicObject getEmbeddedDocument()
          Apply a default algorithm to check if this element contains embedded subdocumnet
static DElement getEmbeddedViewHolder(Viewport view)
          Get DElement that represent `view' in the parent document if any
 String getId()
          The element's identifier.
 String getInnerHTML()
           
 String getLang()
          Language code defined in RFC 1766.
 String getLocalName()
          Returns the local part of the qualified name of this node.
 String getName()
           
 String getNamespaceURI()
          The namespace URI of this node, or null if it is unspecified.
 String getNodeName()
          The name of this node, depending on its type; see the table above.
 short getNodeType()
          A code representing the type of the underlying object, as defined above.
 String getOuterHTML()
           
 String getPrefix()
          The namespace prefix of this node, or null if it is unspecified.
 CSSStyleDeclaration getStyle()
          The style attribute.
 boolean getSynthetic()
           
 String getTagName()
          The name of the element.
 String getTitle()
          The element's advisory title.
 boolean hasAttribute(String name)
          Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.
 boolean hasAttributeNS(String namespaceURI, String localName)
          Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise.
 void insertAdjacentHTML(String where, String what)
           
protected  void onDAttrValueChange(DAttr attr)
           
 void removeAttribute(String name)
          Removes an attribute by name.
 Attr removeAttributeNode(Attr oldAttr)
          Removes the specified attribute node.
 void removeAttributeNS(String namespaceURI, String localName)
          Removes an attribute by local name and namespace URI.
 Node removeNode(boolean detachChildren)
           
protected  void setAttribute(int attrNameId, String value)
           
 void setAttribute(String name, String value)
          Adds a new attribute.
 Attr setAttributeNode(Attr newAttr)
          Adds a new attribute node.
 Attr setAttributeNodeNS(Attr newAttr)
          Adds a new attribute.
 void setAttributeNS(String namespaceURI, String qualifiedName, String value)
          Adds a new attribute.
 void setBgColor(String value)
           
 void setClassName(String value)
           
 void setColor(String value)
           
 void setCols(String value)
           
 void setDir(String value)
           
 int setDynamicValue(String name, Object value, DynEnv env)
          Set field `name' to `value'.
 void setId(String value)
           
 void setInnerHTML(String html)
           
 void setLang(String value)
           
 void setName(String value)
           
 void setOuterHTML(String html)
           
 void setRows(String value)
           
 void setTitle(String value)
           
protected  DNode swapDNode(DNode other)
           
 Node swapNode(Node other)
           
 String toString()
           
 
Methods inherited from class ice.pilots.html4.DNode
addEventListener, appendChild, appendDChild, clone, clone, cloneNode, contains, deleteSlot, dispatchEvent, getAll, getChildNodes, getDAttr, getDAttrCount, getDAttrFromIndex, getDAttrListHead, getDAttrValueOrNull, getDParent, getDynamicScopeParent, getFirstChild, getFirstDChild, getInnerText, getLastChild, getLastDChild, getNameId, getNextDSibling, getNextSibling, getNodeValue, getOuterText, getOwnerDDocument, getOwnerDocument, getParentDNode, getParentNode, getPilot, getPreviousDSibling, getPreviousSibling, getRootDNode, getRootNode, getSlot, hasAttributes, hasChildNodes, hasSlot, insertBefore, insertDChildBefore, isSupported, normalize, removeAllDAttrs, removeChild, removeDAttr, removeDAttr, removeDChild, removeEventListener, replaceChild, replaceDChild, setDAttr, setDAttr, setInnerText, setNodeValue, setOuterText, setParent, setPrefix, setSlot, unlinkAllSlots
 
Methods inherited from class ice.storm.DynamicObject
deleteSlot, getEnumeratableIds, getMethodPropertySource, getScriptDataLock, getScriptWrapper, getSlot, hasSlot, javaReflectionTarget, readOnlySlots, script_toSource, script_toString, setScriptWrapperIfAbsent, setSlot
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

DElement

protected DElement(DDocument doc,
                   int id)
Method Detail

afterClone

protected void afterClone(boolean deep)
Description copied from class: DNode
This method is meant to be after the Object.clone() call. This method will clone the attribute list, and if the deep flag is true, this method will clone all child nodes of the original object, and add them to the clone.

Overrides:
afterClone in class DNode
Parameters:
deep - True if the node is intended to be a deep child copy

onDAttrValueChange

protected void onDAttrValueChange(DAttr attr)
Overrides:
onDAttrValueChange in class DNode

getAttribute

public final String getAttribute(int attrNameId)

setAttribute

protected void setAttribute(int attrNameId,
                            String value)

getNodeType

public short getNodeType()
Description copied from interface: Node
A code representing the type of the underlying object, as defined above.

Specified by:
getNodeType in interface Node
Overrides:
getNodeType in class DNode

getNodeName

public String getNodeName()
Description copied from interface: Node
The name of this node, depending on its type; see the table above.

Specified by:
getNodeName in interface Node
Overrides:
getNodeName in class DNode

getTagName

public String getTagName()
Description copied from interface: Element
The name of the element. For example, in:
 <elementExample 
 id="demo"> ... </elementExample> , 
tagName has the value "elementExample". Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the tagName of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.

Specified by:
getTagName in interface Element

attrNameToId

protected int attrNameToId(String name)
Overrides:
attrNameToId in class DNode

getAttribute

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

Specified by:
getAttribute in interface Element
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.

setAttribute

public void setAttribute(String name,
                         String value)
Description copied from interface: Element
Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNode to assign it as the value of an attribute.
To set an attribute with a qualified name and namespace URI, use the setAttributeNS method.

Specified by:
setAttribute in interface Element

removeAttribute

public void removeAttribute(String name)
Description copied from interface: Element
Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.
To remove an attribute by local name and namespace URI, use the removeAttributeNS method.

Specified by:
removeAttribute in interface Element

getAttributeNode

public Attr getAttributeNode(String name)
Description copied from interface: Element
Retrieves an attribute node by name.
To retrieve an attribute node by qualified name and namespace URI, use the getAttributeNodeNS method.

Specified by:
getAttributeNode in interface Element
Returns:
The Attr node with the specified name ( nodeName) or null if there is no such attribute.

setAttributeNode

public Attr setAttributeNode(Attr newAttr)
Description copied from interface: Element
Adds a new attribute node. If an attribute with that name ( nodeName) is already present in the element, it is replaced by the new one.
To add a new attribute node with a qualified name and namespace URI, use the setAttributeNodeNS method.

Specified by:
setAttributeNode in interface Element
Returns:
If the newAttr attribute replaces an existing attribute, the replaced Attr node is returned, otherwise null is returned.

removeAttributeNode

public Attr removeAttributeNode(Attr oldAttr)
Description copied from interface: Element
Removes the specified attribute node. If the removed Attr has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.

Specified by:
removeAttributeNode in interface Element
Returns:
The Attr node that was removed.

getElementsByTagName

public NodeList getElementsByTagName(String name)
Description copied from interface: Element
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

Specified by:
getElementsByTagName in interface Element
Returns:
A list of matching Element nodes.

getAttributes

public NamedNodeMap getAttributes()
Description copied from interface: Node
A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.

Specified by:
getAttributes in interface Node
Overrides:
getAttributes in class DNode

getLocalName

public String getLocalName()
Description copied from interface: Node
Returns the local part of the qualified name of this node.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getLocalName in interface Node
Overrides:
getLocalName in class DNode

getPrefix

public String getPrefix()
Description copied from interface: Node
The namespace prefix of this node, or null if it is unspecified.
Note that setting this attribute, when permitted, changes the nodeName attribute, which holds the qualified name, as well as the tagName and name attributes of the Element and Attr interfaces, when applicable.
Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the namespaceURI and localName do not change.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.

Specified by:
getPrefix in interface Node
Overrides:
getPrefix in class DNode

getNamespaceURI

public String getNamespaceURI()
Description copied from interface: Node
The namespace URI of this node, or null if it is unspecified.
This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created with a DOM Level 1 method, such as createElement from the Document interface, this is always null.Per the Namespaces in XML Specification an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.

Specified by:
getNamespaceURI in interface Node
Overrides:
getNamespaceURI in class DNode

getBgColor

public String getBgColor()

setBgColor

public void setBgColor(String value)

getColor

public String getColor()

setColor

public void setColor(String value)

getId

public String getId()
Description copied from interface: HTMLElement
The element's identifier. See the id attribute definition in HTML 4.0.

Specified by:
getId in interface HTMLElement

setId

public void setId(String value)
Specified by:
setId in interface HTMLElement

setRows

public void setRows(String value)

setCols

public void setCols(String value)

getName

public String getName()

setName

public void setName(String value)

getClassName

public String getClassName()
Description copied from interface: HTMLElement
The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages. See the class attribute definition in HTML 4.0.

Specified by:
getClassName in interface HTMLElement

setClassName

public void setClassName(String value)
Specified by:
setClassName in interface HTMLElement

getTitle

public String getTitle()
Description copied from interface: HTMLElement
The element's advisory title. See the title attribute definition in HTML 4.0.

Specified by:
getTitle in interface HTMLElement

setTitle

public void setTitle(String value)
Specified by:
setTitle in interface HTMLElement

getLang

public String getLang()
Description copied from interface: HTMLElement
Language code defined in RFC 1766. See the lang attribute definition in HTML 4.0.

Specified by:
getLang in interface HTMLElement

setLang

public void setLang(String value)
Specified by:
setLang in interface HTMLElement

getDir

public String getDir()
Description copied from interface: HTMLElement
Specifies the base direction of directionally neutral text and the directionality of tables. See the dir attribute definition in HTML 4.0.

Specified by:
getDir in interface HTMLElement

setDir

public void setDir(String value)
Specified by:
setDir in interface HTMLElement

getStyle

public CSSStyleDeclaration getStyle()
Description copied from interface: ElementCSSInlineStyle
The style attribute.

Specified by:
getStyle in interface ElementCSSInlineStyle

toString

public String toString()

getSynthetic

public boolean getSynthetic()

getAttributeAsInt

public int getAttributeAsInt(String name)
Retrieve the Attribute value as an integer. This method returns -1 in two cases
  1. If the named attribute was not found
  2. If the value of the named attribute was negative

Parameters:
name - The attribute name.
Returns:
The value of the attribute, or -1 if not found or negative.

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Description copied from interface: Element
Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
getAttributeNS in interface Element
Returns:
The Attr value as a string, or the empty string if that attribute does not have a specified or default value.

setAttributeNS

public void setAttributeNS(String namespaceURI,
                           String qualifiedName,
                           String value)
Description copied from interface: Element
Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute.
HTML-only DOM implementations do not need to implement this method.

Specified by:
setAttributeNS in interface Element

removeAttributeNS

public void removeAttributeNS(String namespaceURI,
                              String localName)
Description copied from interface: Element
Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.
HTML-only DOM implementations do not need to implement this method.

Specified by:
removeAttributeNS in interface Element

getAttributeNodeNS

public Attr getAttributeNodeNS(String namespaceURI,
                               String localName)
Description copied from interface: Element
Retrieves an Attr node by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.

Specified by:
getAttributeNodeNS in interface Element
Returns:
The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.

setAttributeNodeNS

public Attr setAttributeNodeNS(Attr newAttr)
Description copied from interface: Element
Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.
HTML-only DOM implementations do not need to implement this method.

Specified by:
setAttributeNodeNS in interface Element
Returns:
If the newAttr attribute replaces an existing attribute with the same local name and namespace URI, the replaced Attr node is returned, otherwise null is returned.

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Description copied from interface: Element
Returns a NodeList of all the descendant Elements with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this Element tree.
HTML-only DOM implementations do not need to implement this method.

Specified by:
getElementsByTagNameNS in interface Element
Returns:
A new NodeList object containing all the matched Elements.

hasAttribute

public boolean hasAttribute(String name)
Description copied from interface: Element
Returns true when an attribute with a given name is specified on this element or has a default value, false otherwise.

Specified by:
hasAttribute in interface Element
Returns:
true if an attribute with the given name is specified on this element or has a default value, false otherwise.

hasAttributeNS

public boolean hasAttributeNS(String namespaceURI,
                              String localName)
Description copied from interface: Element
Returns true when an attribute with a given local name and namespace URI is specified on this element or has a default value, false otherwise. HTML-only DOM implementations do not need to implement this method.

Specified by:
hasAttributeNS in interface Element
Returns:
true if an attribute with the given local name and namespace URI is specified or has a default value on this element, false otherwise.

getClientTop

public int getClientTop()

getClientLeft

public int getClientLeft()

getClientWidth

public int getClientWidth()
Retrieve the height of the visible element. If this element is contained in a scrollBox, this method will return the inner, visible, area of the scrollBox. (offsetHeight - width of horizontal scrollbar)

Returns:
The client width in pixels

insertAdjacentHTML

public void insertAdjacentHTML(String where,
                               String what)

setInnerHTML

public void setInnerHTML(String html)

getInnerHTML

public String getInnerHTML()

setOuterHTML

public void setOuterHTML(String html)

getOuterHTML

public String getOuterHTML()

removeNode

public Node removeNode(boolean detachChildren)

swapNode

public final Node swapNode(Node other)

swapDNode

protected DNode swapDNode(DNode other)

getEmbeddedViewHolder

public static DElement getEmbeddedViewHolder(Viewport view)
Get DElement that represent `view' in the parent document if any


getChildViewport

public Viewport getChildViewport()
Find a viewport that this element holds if any.


getEmbeddedDocument

protected DynamicObject getEmbeddedDocument()
Apply a default algorithm to check if this element contains embedded subdocumnet


getDynamicValue

public Object getDynamicValue(String name,
                              DynEnv env)
Description copied from class: DynamicObject
Returns the `key' field or Defs.NOT_FOUND if `name' does not exist. Returns `FUNCTION_MARK' if `name' represent a function that can be invoke via execDynamicMethod. Note that returned `null' indicates that value is present but set to null.

Overrides:
getDynamicValue in class DNode

setDynamicValue

public int setDynamicValue(String name,
                           Object value,
                           DynEnv env)
Description copied from class: DynamicObject
Set field `name' to `value'. Use `env' to unwrap `value' to a particular type or store it as is

Overrides:
setDynamicValue in class DNode

execDynamicMethod

public Object execDynamicMethod(String name,
                                Object[] args,
                                DynEnv env)
Description copied from class: DynamicObject
Perform function-like actions for `name' with the given args. Returns the result or Defs.NOT_FOUND if name is not associated with function action. Should return result of env.wrapVoid() to indicate method without return value. Use `env' to unwrap `args' elements to a particular type.

Overrides:
execDynamicMethod in class DNode