org.enhydra.apache.html.dom
Class HTMLElementImpl

java.lang.Object
  |
  +--org.enhydra.apache.xerces.dom.NodeImpl
        |
        +--org.enhydra.apache.xerces.dom.ChildNode
              |
              +--org.enhydra.apache.xerces.dom.ParentNode
                    |
                    +--org.enhydra.apache.xerces.dom.ElementImpl
                          |
                          +--org.enhydra.apache.html.dom.HTMLElementImpl
All Implemented Interfaces:
Cloneable, Element, EventTarget, HTMLElement, Node, NodeList, Serializable
Direct Known Subclasses:
HTMLAnchorElementImpl, HTMLAppletElementImpl, HTMLAreaElementImpl, HTMLBaseElementImpl, HTMLBaseFontElementImpl, HTMLBodyElementImpl, HTMLBRElementImpl, HTMLButtonElementImpl, HTMLDirectoryElementImpl, HTMLDivElementImpl, HTMLDListElementImpl, HTMLFieldSetElementImpl, HTMLFontElementImpl, HTMLFormElementImpl, HTMLFrameElementImpl, HTMLFrameSetElementImpl, HTMLHeadElementImpl, HTMLHeadingElementImpl, HTMLHRElementImpl, HTMLHtmlElementImpl, HTMLIFrameElementImpl, HTMLImageElementImpl, HTMLInputElementImpl, HTMLIsIndexElementImpl, HTMLLabelElementImpl, HTMLLegendElementImpl, HTMLLIElementImpl, HTMLLinkElementImpl, HTMLMapElementImpl, HTMLMenuElementImpl, HTMLMetaElementImpl, HTMLModElementImpl, HTMLObjectElementImpl, HTMLOListElementImpl, HTMLOptGroupElementImpl, HTMLOptionElementImpl, HTMLParagraphElementImpl, HTMLParamElementImpl, HTMLPreElementImpl, HTMLQuoteElementImpl, HTMLScriptElementImpl, HTMLSelectElementImpl, HTMLStyleElementImpl, HTMLTableCaptionElementImpl, HTMLTableCellElementImpl, HTMLTableColElementImpl, HTMLTableElementImpl, HTMLTableRowElementImpl, HTMLTableSectionElementImpl, HTMLTextAreaElementImpl, HTMLTitleElementImpl, HTMLUListElementImpl

public class HTMLElementImpl
extends ElementImpl
implements HTMLElement

Implements an HTML-specific element, an Element that will only appear inside HTML documents. This element extends ElementImpl by adding methods for directly manipulating HTML-specific attributes. All HTML elements gain access to the id, title, lang, dir and class attributes. Other elements add their own specific attributes.

Version:
$Revision: 1.2 $ $Date: 2005/01/26 08:28:44 $
Author:
Assaf Arkin
See Also:
HTMLElement, Serialized Form

Fields inherited from class org.enhydra.apache.xerces.dom.ElementImpl
attributes, name, serialVersionUID
 
Fields inherited from class org.enhydra.apache.xerces.dom.ParentNode
fCachedChild, fCachedChildIndex, fCachedLength, firstChild, ownerDocument
 
Fields inherited from class org.enhydra.apache.xerces.dom.ChildNode
nextSibling, previousSibling
 
Fields inherited from class org.enhydra.apache.xerces.dom.NodeImpl
ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, IGNORABLEWS, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, UNNORMALIZED
 
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
HTMLElementImpl(HTMLDocumentImpl owner, String tagName)
          Constructor required owner document and element tag name.
 
Method Summary
(package private)  String capitalize(String value)
          Convenience method used to capitalize a one-off attribute value before it is returned.
 String getAttribute(String attrName)
          Look up a single Attribute by name.
 Attr getAttributeNode(String attrName)
          Look up a single Attribute by name.
 Attr getAttributeNodeNS(String namespaceURI, String localName)
          Retrieves an Attr node by local name and namespace URI.
 String getAttributeNS(String namespaceURI, String localName)
          Introduced in DOM Level 2.
(package private)  boolean getBinary(String name)
          Convenience method used to translate an attribute value into a boolean value.
(package private)  String getCapitalized(String name)
          Convenience method used to capitalize a one-off attribute value before it is returned.
 String getClassName()
           
 String getDir()
           
 NodeList getElementsByTagName(String tagName)
          Returns a NodeList of all descendent nodes (children, grandchildren, and so on) which are Elements and which have the specified tag name.
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
          Introduced in DOM Level 2.
 HTMLFormElement getForm()
          Convenience method returns the form in which this form element is contained.
 String getId()
           
(package private)  int getInteger(String value)
          Convenience method used to translate an attribute value into an integer value.
 String getLang()
           
 String getTitle()
           
(package private)  void setAttribute(String name, boolean value)
          Convenience method used to set a boolean attribute.
 void setClassName(String className)
           
 void setDir(String dir)
           
 void setId(String id)
           
 void setLang(String lang)
           
 void setTitle(String title)
           
 
Methods inherited from class org.enhydra.apache.xerces.dom.ElementImpl
cloneNode, getAttributes, getDefaultAttributes, getNodeName, getNodeType, getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, hasAttributes, normalize, reconcileDefaultAttributes, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setOwnerDocument, setReadOnly, setupDefaultAttributes, synchronizeData
 
Methods inherited from class org.enhydra.apache.xerces.dom.ParentNode
checkNormalizationAfterInsert, checkNormalizationAfterRemove, getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, getOwnerDocument, hasChildNodes, insertBefore, internalInsertBefore, internalRemoveChild, item, lastChild, lastChild, ownerDocument, removeChild, replaceChild, synchronizeChildren
 
Methods inherited from class org.enhydra.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling, parentNode, previousSibling
 
Methods inherited from class org.enhydra.apache.xerces.dom.NodeImpl
addEventListener, appendChild, changed, changes, compareDocumentPosition, dispatchEvent, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getTextContent, getUserData, getUserData, hasStringValue, hasStringValue, internalIsIgnorableWhitespace, isDefaultNamespace, isEqualNode, isFirstChild, isFirstChild, isIgnorableWhitespace, isNormalized, isNormalized, isOwned, isOwned, isReadOnly, isReadOnly, isSameNode, isSpecified, isSpecified, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, needsSyncChildren, needsSyncData, needsSyncData, removeEventListener, setNodeValue, setPrefix, setTextContent, setUserData, setUserData, 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.Element
getSchemaTypeInfo, getTagName, hasAttribute, hasAttributeNS, removeAttribute, removeAttributeNode, removeAttributeNS, setAttribute, setAttributeNode, setAttributeNodeNS, setAttributeNS, setIdAttribute, setIdAttributeNode, setIdAttributeNS
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
 

Constructor Detail

HTMLElementImpl

public HTMLElementImpl(HTMLDocumentImpl owner,
                       String tagName)
Constructor required owner document and element tag name. Will be called by the constructor of specific element types but with a known tag name. Assures that the owner document is an HTML element.
Parameters:
owner - The owner HTML document
tagName - The element's tag name
Method Detail

getId

public String getId()
Specified by:
getId in interface HTMLElement

setId

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

getTitle

public String getTitle()
Specified by:
getTitle in interface HTMLElement

setTitle

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

getLang

public String getLang()
Specified by:
getLang in interface HTMLElement

setLang

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

getDir

public String getDir()
Specified by:
getDir in interface HTMLElement

setDir

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

getClassName

public String getClassName()
Specified by:
getClassName in interface HTMLElement

setClassName

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

getInteger

int getInteger(String value)
Convenience method used to translate an attribute value into an integer value. Returns the integer value or zero if the attribute is not a valid numeric string.
Parameters:
value - The value of the attribute
Returns:
The integer value, or zero if not a valid numeric string

getBinary

boolean getBinary(String name)
Convenience method used to translate an attribute value into a boolean value. If the attribute has an associated value (even an empty string), it is set and true is returned. If the attribute does not exist, false is returend.
Parameters:
value - The value of the attribute
Returns:
True or false depending on whether the attribute has been set

setAttribute

void setAttribute(String name,
                  boolean value)
Convenience method used to set a boolean attribute. If the value is true, the attribute is set to an empty string. If the value is false, the attribute is removed. HTML 4.0 understands empty strings as set attributes.
Parameters:
name - The name of the attribute
value - The value of the attribute

getAttributeNode

public Attr getAttributeNode(String attrName)
Description copied from class: ElementImpl
Look up a single Attribute by name. Returns the Attribute Node, so its complete child tree is available. This could be important in XML, where the string rendering may not be sufficient information.

If no matching attribute is available, returns null.

Specified by:
getAttributeNode in interface Element
Overrides:
getAttributeNode in class ElementImpl

getAttributeNodeNS

public Attr getAttributeNodeNS(String namespaceURI,
                               String localName)
Description copied from class: ElementImpl
Retrieves an Attr node by local name and namespace URI.
Specified by:
getAttributeNodeNS in interface Element
Overrides:
getAttributeNodeNS in class ElementImpl
Following copied from class: org.enhydra.apache.xerces.dom.ElementImpl
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
Attr The Attr node with the specified attribute local name and namespace URI or null if there is no such attribute.

getAttribute

public String getAttribute(String attrName)
Description copied from class: ElementImpl
Look up a single Attribute by name. Returns the Attribute's string value, or an empty string (NOT null!) to indicate that the name did not map to a currently defined attribute.

Note: Attributes may contain complex node trees. This method returns the "flattened" string obtained from Attribute.getValue(). If you need the structure information, see getAttributeNode().

Specified by:
getAttribute in interface Element
Overrides:
getAttribute in class ElementImpl

getAttributeNS

public String getAttributeNS(String namespaceURI,
                             String localName)
Description copied from class: ElementImpl
Introduced in DOM Level 2.

Retrieves an attribute value by local name and namespace URI.

Specified by:
getAttributeNS in interface Element
Overrides:
getAttributeNS in class ElementImpl
Following copied from class: org.enhydra.apache.xerces.dom.ElementImpl
Parameters:
namespaceURI - The namespace URI of the attribute to retrieve.
localName - The local name of the attribute to retrieve.
Returns:
String The Attr value as a string, or empty string if that attribute does not have a specified or default value.

getElementsByTagName

public final NodeList getElementsByTagName(String tagName)
Description copied from class: ElementImpl
Returns a NodeList of all descendent nodes (children, grandchildren, and so on) which are Elements and which have the specified tag name.

Note: NodeList is a "live" view of the DOM. Its contents will change as the DOM changes, and alterations made to the NodeList will be reflected in the DOM.

Specified by:
getElementsByTagName in interface Element
Overrides:
getElementsByTagName in class ElementImpl
Following copied from class: org.enhydra.apache.xerces.dom.ElementImpl
Parameters:
tagname - The type of element to gather. To obtain a list of all elements no matter what their names, use the wild-card tag name "*".
See Also:
DeepNodeListImpl

getElementsByTagNameNS

public final NodeList getElementsByTagNameNS(String namespaceURI,
                                             String localName)
Description copied from class: ElementImpl
Introduced in DOM Level 2.

Returns a NodeList of all the Elements with a given local name and namespace URI in the order in which they would be encountered in a preorder traversal of the Document tree, starting from this node.

Specified by:
getElementsByTagNameNS in interface Element
Overrides:
getElementsByTagNameNS in class ElementImpl
Following copied from class: org.enhydra.apache.xerces.dom.ElementImpl
Parameters:
namespaceURI - The namespace URI of the elements to match on. The special value "*" matches all namespaces. When it is null or an empty string, this method behaves like getElementsByTagName.
localName - The local name of the elements to match on. The special value "*" matches all local names.
Returns:
NodeList A new NodeList object containing all the matched Elements.

capitalize

String capitalize(String value)
Convenience method used to capitalize a one-off attribute value before it is returned. For example, the align values "LEFT" and "left" will both return as "Left".
Parameters:
value - The value of the attribute
Returns:
The capitalized value

getCapitalized

String getCapitalized(String name)
Convenience method used to capitalize a one-off attribute value before it is returned. For example, the align values "LEFT" and "left" will both return as "Left".
Parameters:
name - The name of the attribute
Returns:
The capitalized value

getForm

public HTMLFormElement getForm()
Convenience method returns the form in which this form element is contained. This method is exposed for form elements through the DOM API, but other elements have no access to it through the API.


Copyright © 1999 The Apache Software Foundation. All Rights reserved.