org.enhydra.xml.lazydom.html
Class LazyHTMLDocument

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.CoreDocumentImpl
                          |
                          +--org.enhydra.apache.xerces.dom.DocumentImpl
                                |
                                +--org.enhydra.xml.lazydom.LazyDocument
                                      |
                                      +--org.enhydra.xml.lazydom.html.LazyHTMLDocument
All Implemented Interfaces:
java.lang.Cloneable, org.w3c.dom.Document, org.w3c.dom.events.DocumentEvent, org.w3c.dom.ranges.DocumentRange, org.w3c.dom.traversal.DocumentTraversal, org.w3c.dom.events.EventTarget, org.w3c.dom.html.HTMLDocument, LazyNode, LazyParent, org.w3c.dom.Node, org.w3c.dom.NodeList, PreFormattedTextDocument, java.io.Serializable, XMLObjectLink

public class LazyHTMLDocument
extends LazyDocument
implements org.w3c.dom.html.HTMLDocument

Implements an HTML document. Provides access to the top level element in the document, its body and title.

Several methods create new nodes of all basic types (comment, text, element, etc.). These methods create new nodes but do not place them in the document tree. The nodes may be placed in the document tree using Node.appendChild(org.w3c.dom.Node) or Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node), or they may be placed in some other document tree.

Note: <FRAMESET> documents are not supported at the moment, neither are direct document writing (open(), write(java.lang.String)) and HTTP attribute methods (getURL(), getCookie()).

Version:
$Revision$ $Date$
Author:
Assaf Arkin
See Also:
HTMLDocument, Serialized Form

Field Summary
 
Fields inherited from class org.enhydra.apache.xerces.dom.DocumentImpl
eventListeners, iterators, mutationEvents, ranges, userData
 
Fields inherited from class org.enhydra.apache.xerces.dom.CoreDocumentImpl
allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, identifiers, kidOK, standalone, version
 
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_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.enhydra.xml.lazydom.LazyNode
DOCUMENT_NODE_ID, NULL_NODE_ID
 
Constructor Summary
LazyHTMLDocument()
          Constructor with no template.
LazyHTMLDocument(TemplateDOM templateDOM)
          LazyDOM: Constructor with TemplateDOM.
 
Method Summary
 org.w3c.dom.Node cloneNode(boolean deep)
           
 void close()
           
 org.w3c.dom.Attr createAttribute(java.lang.String name)
          Creates an Attribute having this Document as its OwnerDoc.
 LazyElement createElement(int nodeId)
          Create a element from a template given its id.
 org.w3c.dom.Element createElement(LazyElement template, java.lang.String tagName)
           
 org.w3c.dom.Element createElement(java.lang.String tagName)
          LazyDOM: standard createElement method, passes null template element.
 org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
           
 org.w3c.dom.html.HTMLCollection getAnchors()
           
 org.w3c.dom.html.HTMLCollection getApplets()
           
 org.w3c.dom.html.HTMLElement getBody()
           
 java.lang.String getCookie()
           
 org.w3c.dom.Element getDocumentElement()
           
 java.lang.String getDomain()
           
 org.w3c.dom.Element getElementById(java.lang.String elementId)
           
 org.w3c.dom.NodeList getElementsByName(java.lang.String elementName)
           
 org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagName)
           
 org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
           
 org.w3c.dom.html.HTMLCollection getForms()
           
 org.w3c.dom.html.HTMLElement getHead()
          Obtains the <HEAD> element in the document, creating one if does not exist before.
 org.w3c.dom.html.HTMLCollection getImages()
           
 org.w3c.dom.DOMImplementation getImplementation()
           
 org.w3c.dom.html.HTMLCollection getLinks()
           
 java.lang.String getReferrer()
           
 java.lang.String getTitle()
           
 java.lang.String getURL()
           
 void open()
           
 void setBody(org.w3c.dom.html.HTMLElement newBody)
           
 void setCookie(java.lang.String cookie)
           
 void setTitle(java.lang.String newTitle)
           
 void write(java.lang.String text)
           
 void writeln(java.lang.String text)
           
 
Methods inherited from class org.enhydra.xml.lazydom.LazyDocument
appendChild, appendChildWhileExpanding, areChildrenExpanded, createAttribute, createAttributeNS, createAttributeNS, createCDATASection, createCDATASection, createComment, createComment, createDocumentType, createDocumentType, createDocumentType, createEntity, createEntity, createEntityReference, createEntityReference, createNotation, createNotation, createProcessingInstruction, createProcessingInstruction, createTemplateAttribute, createTemplateAttributeNS, createTemplateCDATASection, createTemplateComment, createTemplateDocumentType, createTemplateElement, createTemplateElementNS, createTemplateEntity, createTemplateEntityReference, createTemplateNotation, createTemplateProcessingInstruction, createTemplateTextNode, createTextNode, createTextNode, doExpandChildren, doExpandParent, enterExpansion, getChildNodes, getDoctype, getExpandedNode, getFirstChild, getLastChild, getNodeById, getNodeFromTemplate, getNodeId, getPreFormatOutputOptions, getTemplateDocument, getTemplateNode, getTemplateNode, getXMLObject, hasChildNodes, insertBefore, isDocTypeExpanded, isParentExpanded, isTemplateNode, leaveExpansion, makeTemplateNode, normalize, removeChild, replaceChild, setChildrenExpanded, setNodeValue, setParentExpanded, setParentWhileExpanding, setPreFormatOutputOptions, setXMLObject, templateClone
 
Methods inherited from class org.enhydra.apache.xerces.dom.DocumentImpl
addEventListener, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, getEventListeners, getUserData, removeEventListener, saveEnclosingAttr, setEventListeners, setUserData
 
Methods inherited from class org.enhydra.apache.xerces.dom.CoreDocumentImpl
adoptNode, changed, changes, clone, cloneNode, createDocumentFragment, createElementDefinition, getEncoding, getErrorChecking, getIdentifier, getIdentifiers, getNodeName, getNodeType, getOwnerDocument, getStandalone, getStrictErrorChecking, getVersion, importNode, isKidOK, isXMLName, putIdentifier, removeIdentifier, setEncoding, setErrorChecking, setStandalone, setStrictErrorChecking, setVersion
 
Methods inherited from class org.enhydra.apache.xerces.dom.ParentNode
getChildNodesUnoptimized, getLength, item, setReadOnly, synchronizeChildren
 
Methods inherited from class org.enhydra.apache.xerces.dom.ChildNode
getNextSibling, getParentNode, getPreviousSibling
 
Methods inherited from class org.enhydra.apache.xerces.dom.NodeImpl
addEventListener, dispatchEvent, getAttributes, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isSupported, removeEventListener, setPrefix, setUserData, synchronizeData, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Document
createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, importNode
 
Methods inherited from interface org.w3c.dom.Node
appendChild, getAttributes, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Constructor Detail

LazyHTMLDocument

public LazyHTMLDocument()
Constructor with no template.


LazyHTMLDocument

public LazyHTMLDocument(TemplateDOM templateDOM)
LazyDOM: Constructor with TemplateDOM.

Method Detail

getImplementation

public org.w3c.dom.DOMImplementation getImplementation()
Specified by:
getImplementation in interface org.w3c.dom.Document
Overrides:
getImplementation in class LazyDocument
See Also:
Document#DOMImplementation

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Specified by:
getDocumentElement in interface org.w3c.dom.Document
Overrides:
getDocumentElement in class LazyDocument
See Also:
Document.getDocumentElement()

getHead

public org.w3c.dom.html.HTMLElement getHead()
Obtains the <HEAD> element in the document, creating one if does not exist before. The <HEAD> element is the first element in the <HTML> in the document. The <HTML> element is obtained by calling getDocumentElement(). If the element does not exist, one is created.

Called by getTitle(), setTitle(java.lang.String), getBody() and setBody(org.w3c.dom.html.HTMLElement) to assure the document has the <HEAD> element correctly placed.

Returns:
The <HEAD> element

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface org.w3c.dom.html.HTMLDocument

setTitle

public void setTitle(java.lang.String newTitle)
Specified by:
setTitle in interface org.w3c.dom.html.HTMLDocument

getBody

public org.w3c.dom.html.HTMLElement getBody()
Specified by:
getBody in interface org.w3c.dom.html.HTMLDocument

setBody

public void setBody(org.w3c.dom.html.HTMLElement newBody)
Specified by:
setBody in interface org.w3c.dom.html.HTMLDocument

getElementById

public org.w3c.dom.Element getElementById(java.lang.String elementId)
Specified by:
getElementById in interface org.w3c.dom.Document
Overrides:
getElementById in class org.enhydra.apache.xerces.dom.CoreDocumentImpl

getElementsByName

public org.w3c.dom.NodeList getElementsByName(java.lang.String elementName)
Specified by:
getElementsByName in interface org.w3c.dom.html.HTMLDocument

getElementsByTagName

public final org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagName)
Specified by:
getElementsByTagName in interface org.w3c.dom.Document
Overrides:
getElementsByTagName in class org.enhydra.apache.xerces.dom.CoreDocumentImpl

getElementsByTagNameNS

public final org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI,
                                                         java.lang.String localName)
Specified by:
getElementsByTagNameNS in interface org.w3c.dom.Document
Overrides:
getElementsByTagNameNS in class org.enhydra.apache.xerces.dom.CoreDocumentImpl

createElementNS

public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI,
                                           java.lang.String qualifiedName)
Specified by:
createElementNS in interface org.w3c.dom.Document
Overrides:
createElementNS in class LazyDocument
See Also:
Document.createElementNS(java.lang.String, java.lang.String)

createElement

public org.w3c.dom.Element createElement(LazyElement template,
                                         java.lang.String tagName)
                                  throws org.w3c.dom.DOMException
org.w3c.dom.DOMException

createAttribute

public org.w3c.dom.Attr createAttribute(java.lang.String name)
                                 throws org.w3c.dom.DOMException
Creates an Attribute having this Document as its OwnerDoc. Overrides DocumentImpl#createAttribute and returns and attribute whose name is lower case.

Specified by:
createAttribute in interface org.w3c.dom.Document
Overrides:
createAttribute in class LazyDocument
Parameters:
name - The name of the attribute
Returns:
An attribute whose name is all lower case
Throws:
DOMException(INVALID_NAME_ERR) - if the attribute name is not acceptable
org.w3c.dom.DOMException
See Also:
Document.createAttribute(java.lang.String)

getReferrer

public java.lang.String getReferrer()
Specified by:
getReferrer in interface org.w3c.dom.html.HTMLDocument

getDomain

public java.lang.String getDomain()
Specified by:
getDomain in interface org.w3c.dom.html.HTMLDocument

getURL

public java.lang.String getURL()
Specified by:
getURL in interface org.w3c.dom.html.HTMLDocument

getCookie

public java.lang.String getCookie()
Specified by:
getCookie in interface org.w3c.dom.html.HTMLDocument

setCookie

public void setCookie(java.lang.String cookie)
Specified by:
setCookie in interface org.w3c.dom.html.HTMLDocument

getImages

public org.w3c.dom.html.HTMLCollection getImages()
Specified by:
getImages in interface org.w3c.dom.html.HTMLDocument

getApplets

public org.w3c.dom.html.HTMLCollection getApplets()
Specified by:
getApplets in interface org.w3c.dom.html.HTMLDocument

getLinks

public org.w3c.dom.html.HTMLCollection getLinks()
Specified by:
getLinks in interface org.w3c.dom.html.HTMLDocument

getForms

public org.w3c.dom.html.HTMLCollection getForms()
Specified by:
getForms in interface org.w3c.dom.html.HTMLDocument

getAnchors

public org.w3c.dom.html.HTMLCollection getAnchors()
Specified by:
getAnchors in interface org.w3c.dom.html.HTMLDocument

open

public void open()
Specified by:
open in interface org.w3c.dom.html.HTMLDocument

close

public void close()
Specified by:
close in interface org.w3c.dom.html.HTMLDocument

write

public void write(java.lang.String text)
Specified by:
write in interface org.w3c.dom.html.HTMLDocument

writeln

public void writeln(java.lang.String text)
Specified by:
writeln in interface org.w3c.dom.html.HTMLDocument

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Specified by:
cloneNode in interface org.w3c.dom.Node
Overrides:
cloneNode in class LazyDocument
See Also:
Node.cloneNode(boolean)

createElement

public org.w3c.dom.Element createElement(java.lang.String tagName)
                                  throws org.w3c.dom.DOMException
LazyDOM: standard createElement method, passes null template element.

Specified by:
createElement in interface org.w3c.dom.Document
Overrides:
createElement in class LazyDocument
org.w3c.dom.DOMException
See Also:
Document.createElement(java.lang.String)

createElement

public LazyElement createElement(int nodeId)
                          throws org.w3c.dom.DOMException
Description copied from class: LazyDocument
Create a element from a template given its id.

Overrides:
createElement in class LazyDocument
org.w3c.dom.DOMException
See Also:
Document.createElement(java.lang.String)


Copyright © 1999-2002 enhydra.org (Mark Diekhans, David Li, Richard Kunze). All Rights reserved.