|
|||||||||
| Home >> All >> org >> enhydra >> xml >> lazydom >> [ html overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.enhydra.xml.lazydom.html
Class LazyHTMLDocument

java.lang.Objectorg.apache.xerces.dom.NodeImpl
org.apache.xerces.dom.ChildNode
org.apache.xerces.dom.ParentNode
org.apache.xerces.dom.CoreDocumentImpl
org.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, org.enhydra.xml.lazydom.LazyNode, org.enhydra.xml.lazydom.LazyParent, org.w3c.dom.Node, org.w3c.dom.NodeList, org.enhydra.xml.io.PreFormattedTextDocument, java.io.Serializable
- public class LazyHTMLDocument
- extends org.enhydra.xml.lazydom.LazyDocument
- implements org.w3c.dom.html.HTMLDocument
- extends org.enhydra.xml.lazydom.LazyDocument
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)>Node.appendChild(org.w3c.dom.Node) 55 or Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)>Node.insertBefore(org.w3c.dom.Node, org.w3c.dom.Node) 55 , 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() 55 , write(java.lang.String) 55 ) and HTTP attribute
methods (getURL() 55 , getCookie() 55 ).
- Version:
- $Revision$ $Date$
| Nested Class Summary |
| Nested classes inherited from class org.apache.xerces.dom.DocumentImpl |
|
| Nested classes inherited from class org.apache.xerces.dom.CoreDocumentImpl |
|
| Field Summary | |
private HTMLCollectionImpl |
_anchors
Holds HTMLCollectionImpl object with live collection of all
anchors in document. |
private HTMLCollectionImpl |
_applets
Holds HTMLCollectionImpl object with live collection of all
applets in document. |
private static java.lang.Class[] |
_elemClassSigHTML
Signature used to locate constructor of HTML element classes. |
private static java.util.Hashtable |
_elementTypesHTML
Holds names and classes of HTML element types. |
private HTMLCollectionImpl |
_forms
Holds HTMLCollectionImpl object with live collection of all
forms in document. |
private HTMLCollectionImpl |
_images
Holds HTMLCollectionImpl object with live collection of all
images in document. |
private HTMLCollectionImpl |
_links
Holds HTMLCollectionImpl object with live collection of all
links in document. |
private java.io.StringWriter |
_writer
Holds string writer used by direct manipulation operation ( open() 55 . |
| Fields inherited from class org.enhydra.xml.lazydom.LazyDocument |
|
| Fields inherited from class org.apache.xerces.dom.DocumentImpl |
eventListeners, iterators, mutationEvents, ranges |
| Fields inherited from class org.apache.xerces.dom.CoreDocumentImpl |
actualEncoding, allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, fDocumentURI, identifiers, standalone, userData, version, xmlVersionChanged |
| Fields inherited from class org.apache.xerces.dom.ParentNode |
firstChild, fNodeListCache, ownerDocument |
| Fields inherited from class org.apache.xerces.dom.ChildNode |
nextSibling, previousSibling |
| 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()
|
|
LazyHTMLDocument(org.enhydra.xml.lazydom.TemplateDOM templateDOM)
LazyDOM: Constructor with TemplateDOM. |
|
| Method Summary | |
org.w3c.dom.Node |
cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. |
void |
close()
Closes a document stream opened by open() and forces
rendering. |
org.w3c.dom.Attr |
createAttribute(java.lang.String name)
Creates an Attribute having this Document as its OwnerDoc. |
org.enhydra.xml.lazydom.LazyElement |
createElement(int nodeId)
Create a element from a template given its id. |
org.w3c.dom.Element |
createElement(org.enhydra.xml.lazydom.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)
Creates an element of the given qualified name and namespace URI. |
private org.w3c.dom.html.HTMLElement |
findBody(org.w3c.dom.Element html)
Find a BODY or FRAMESET element. |
org.w3c.dom.html.HTMLCollection |
getAnchors()
A collection of all the anchor ( A ) elements in a document
with a value for the name attribute. |
org.w3c.dom.html.HTMLCollection |
getApplets()
A collection of all the OBJECT elements that include
applets and APPLET ( deprecated ) elements in a document. |
org.w3c.dom.html.HTMLElement |
getBody()
The element that contains the content for the document. |
java.lang.String |
getCookie()
The cookies associated with this document. |
private org.w3c.dom.Node |
getDirectChildElement(java.lang.String name,
org.w3c.dom.Node root)
Find the direct child element of a node given its name. |
org.w3c.dom.Element |
getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document. |
java.lang.String |
getDomain()
The domain name of the server that served the document, or null if the server cannot be identified by a domain name. |
org.w3c.dom.Element |
getElementById(java.lang.String elementId)
Returns the Element whose ID is given by
elementId. |
private org.w3c.dom.Element |
getElementById(java.lang.String elementId,
org.w3c.dom.Node node)
Recursive method retreives an element by its id attribute. |
org.w3c.dom.NodeList |
getElementsByName(java.lang.String elementName)
Returns the (possibly empty) collection of elements whose name value is given by elementName . |
org.w3c.dom.NodeList |
getElementsByTagName(java.lang.String tagName)
Returns a NodeList of all the Elements with a
given tag name in the order in which they are encountered in a
preorder traversal of the Document tree. |
org.w3c.dom.NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
Returns a NodeList of all the Elements with a
given local name and namespace URI in the order in which they are
encountered in a preorder traversal of the Document tree. |
org.w3c.dom.html.HTMLCollection |
getForms()
A collection of all the forms of a document. |
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()
A collection of all the IMG elements in a document. |
org.w3c.dom.DOMImplementation |
getImplementation()
The DOMImplementation object that handles this document. |
org.w3c.dom.html.HTMLCollection |
getLinks()
A collection of all AREA elements and anchor (
A ) elements in a document with a value for the
href attribute. |
java.lang.String |
getReferrer()
Returns the URI of the page that linked to this page. |
java.lang.String |
getTitle()
The title of a document as specified by the TITLE element
in the head of the document. |
java.lang.String |
getURL()
The complete URI of the document. |
void |
open()
Note. |
private static void |
populateElementType(java.lang.String tagName,
java.lang.String className)
|
private static void |
populateElementTypes()
Called by the constructor to populate the element types list (see _elementTypesHTML 55 ). |
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)
Write a string of text to a document stream opened by open() . |
void |
writeln(java.lang.String text)
Write a string of text followed by a newline character to a document stream opened by open() . |
| Methods inherited from class org.apache.xerces.dom.DocumentImpl |
addEventListener, copyEventListeners, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, getEventListeners, removeEventListener, saveEnclosingAttr, setEventListeners |
| Methods inherited from class org.apache.xerces.dom.ParentNode |
getChildNodesUnoptimized, getLength, isEqualNode, item, setReadOnly, synchronizeChildren |
| Methods inherited from class org.apache.xerces.dom.ChildNode |
getNextSibling, getParentNode, getPreviousSibling |
| Methods inherited from class org.apache.xerces.dom.NodeImpl |
addEventListener, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getContainer, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setPrefix, setUserData, 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 |
| Field Detail |
_anchors
private HTMLCollectionImpl _anchors
- Holds
HTMLCollectionImplobject with live collection of all anchors in document. This reference is on demand only once.
_forms
private HTMLCollectionImpl _forms
- Holds
HTMLCollectionImplobject with live collection of all forms in document. This reference is on demand only once.
_images
private HTMLCollectionImpl _images
- Holds
HTMLCollectionImplobject with live collection of all images in document. This reference is on demand only once.
_links
private HTMLCollectionImpl _links
- Holds
HTMLCollectionImplobject with live collection of all links in document. This reference is on demand only once.
_applets
private HTMLCollectionImpl _applets
- Holds
HTMLCollectionImplobject with live collection of all applets in document. This reference is on demand only once.
_writer
private java.io.StringWriter _writer
- Holds string writer used by direct manipulation operation (
open()55 .write(java.lang.String)55 , etc) to write new contents into the document and parse that text into a document tree.
_elementTypesHTML
private static java.util.Hashtable _elementTypesHTML
- Holds names and classes of HTML element types. When an element with a
particular tag name is created, the matching java.lang.Class
is used to create the element object. For example, <A> matches
HTMLAnchorElementImpl. This static table is shared across all HTML documents.
_elemClassSigHTML
private static final java.lang.Class[] _elemClassSigHTML
- Signature used to locate constructor of HTML element classes. This
static array is shared across all HTML documents.
| Constructor Detail |
LazyHTMLDocument
public LazyHTMLDocument()
LazyHTMLDocument
public LazyHTMLDocument(org.enhydra.xml.lazydom.TemplateDOM templateDOM)
- LazyDOM: Constructor with TemplateDOM.
| Method Detail |
getImplementation
public org.w3c.dom.DOMImplementation getImplementation()
- Description copied from interface:
org.w3c.dom.Document - The
DOMImplementationobject that handles this document. A DOM application may use objects from multiple implementations.- Specified by:
getImplementationin interfaceorg.w3c.dom.Document
getDirectChildElement
private org.w3c.dom.Node getDirectChildElement(java.lang.String name, org.w3c.dom.Node root)
- Find the direct child element of a node given its name.
getDocumentElement
public org.w3c.dom.Element getDocumentElement()
- Description copied from interface:
org.w3c.dom.Document - This is a convenience attribute that allows direct access to the child
node that is the root element of the document. For HTML documents,
this is the element with the tagName "HTML".
- Specified by:
getDocumentElementin interfaceorg.w3c.dom.Document
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()55 . If the element does not exist, one is created.Called by
getTitle()55 ,setTitle(java.lang.String)55 ,getBody()55 andsetBody(org.w3c.dom.html.HTMLElement)55 to assure the document has the <HEAD> element correctly placed.
getTitle
public java.lang.String getTitle()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - The title of a document as specified by the
TITLEelement in the head of the document.- Specified by:
getTitlein interfaceorg.w3c.dom.html.HTMLDocument
setTitle
public void setTitle(java.lang.String newTitle)
- Specified by:
setTitlein interfaceorg.w3c.dom.html.HTMLDocument
findBody
private org.w3c.dom.html.HTMLElement findBody(org.w3c.dom.Element html)
- Find a BODY or FRAMESET element.
getBody
public org.w3c.dom.html.HTMLElement getBody()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - The element that contains the content for the document. In documents
with
BODYcontents, returns theBODYelement. In frameset documents, this returns the outermostFRAMESETelement.- Specified by:
getBodyin interfaceorg.w3c.dom.html.HTMLDocument
setBody
public void setBody(org.w3c.dom.html.HTMLElement newBody)
- Specified by:
setBodyin interfaceorg.w3c.dom.html.HTMLDocument
getElementById
public org.w3c.dom.Element getElementById(java.lang.String elementId)
- Description copied from interface:
org.w3c.dom.Document - Returns the
ElementwhoseIDis given byelementId. If no such element exists, returnsnull. Behavior is not defined if more than one element has thisID. The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to returnnull.- Specified by:
getElementByIdin interfaceorg.w3c.dom.Document
getElementsByName
public org.w3c.dom.NodeList getElementsByName(java.lang.String elementName)
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Returns the (possibly empty) collection of elements whose
namevalue is given byelementName.- Specified by:
getElementsByNamein interfaceorg.w3c.dom.html.HTMLDocument
getElementsByTagName
public final org.w3c.dom.NodeList getElementsByTagName(java.lang.String tagName)
- Description copied from interface:
org.w3c.dom.Document - Returns a
NodeListof all theElementswith a given tag name in the order in which they are encountered in a preorder traversal of theDocumenttree.- Specified by:
getElementsByTagNamein interfaceorg.w3c.dom.Document
getElementsByTagNameNS
public final org.w3c.dom.NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
- Description copied from interface:
org.w3c.dom.Document - Returns a
NodeListof all theElementswith a given local name and namespace URI in the order in which they are encountered in a preorder traversal of theDocumenttree.- Specified by:
getElementsByTagNameNSin interfaceorg.w3c.dom.Document
createElementNS
public org.w3c.dom.Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
- Description copied from interface:
org.w3c.dom.Document - Creates an element of the given qualified name and namespace URI.
HTML-only DOM implementations do not need to implement this method.
- Specified by:
createElementNSin interfaceorg.w3c.dom.Document
createElement
public org.w3c.dom.Element createElement(org.enhydra.xml.lazydom.LazyElement template, java.lang.String tagName) throws 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#createAttributeand returns and attribute whose name is lower case.- Specified by:
createAttributein interfaceorg.w3c.dom.Document
getReferrer
public java.lang.String getReferrer()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Returns the URI of the page that linked to this page. The value is an
empty string if the user navigated to the page directly (not through a
link, but, for example, via a bookmark).
- Specified by:
getReferrerin interfaceorg.w3c.dom.html.HTMLDocument
getDomain
public java.lang.String getDomain()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - The domain name of the server that served the document, or
nullif the server cannot be identified by a domain name.- Specified by:
getDomainin interfaceorg.w3c.dom.html.HTMLDocument
getURL
public java.lang.String getURL()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - The complete URI of the document.
- Specified by:
getURLin interfaceorg.w3c.dom.html.HTMLDocument
getCookie
public java.lang.String getCookie()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - The cookies associated with this document. If there are none, the
value is an empty string. Otherwise, the value is a string: a
semicolon-delimited list of "name, value" pairs for all the cookies
associated with the page. For example,
name=value;expires=date.- Specified by:
getCookiein interfaceorg.w3c.dom.html.HTMLDocument
setCookie
public void setCookie(java.lang.String cookie)
- Specified by:
setCookiein interfaceorg.w3c.dom.html.HTMLDocument
getImages
public org.w3c.dom.html.HTMLCollection getImages()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - A collection of all the
IMGelements in a document. The behavior is limited toIMGelements for backwards compatibility.- Specified by:
getImagesin interfaceorg.w3c.dom.html.HTMLDocument
getApplets
public org.w3c.dom.html.HTMLCollection getApplets()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - A collection of all the
OBJECTelements that include applets andAPPLET( deprecated ) elements in a document.- Specified by:
getAppletsin interfaceorg.w3c.dom.html.HTMLDocument
getLinks
public org.w3c.dom.html.HTMLCollection getLinks()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - A collection of all
AREAelements and anchor (A) elements in a document with a value for thehrefattribute.- Specified by:
getLinksin interfaceorg.w3c.dom.html.HTMLDocument
getForms
public org.w3c.dom.html.HTMLCollection getForms()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - A collection of all the forms of a document.
- Specified by:
getFormsin interfaceorg.w3c.dom.html.HTMLDocument
getAnchors
public org.w3c.dom.html.HTMLCollection getAnchors()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - A collection of all the anchor (
A) elements in a document with a value for thenameattribute. Note. For reasons of backwards compatibility, the returned set of anchors only contains those anchors created with thenameattribute, not those created with theidattribute.- Specified by:
getAnchorsin interfaceorg.w3c.dom.html.HTMLDocument
open
public void open()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Note. This method and the ones following allow a user to add to or
replace the structure model of a document using strings of unparsed
HTML. At the time of writing alternate methods for providing similar
functionality for both HTML and XML documents were being considered.
The following methods may be deprecated at some point in the future in
favor of a more general-purpose mechanism.
Open a document stream for writing. If a document exists in the target, this method clears it.- Specified by:
openin interfaceorg.w3c.dom.html.HTMLDocument
close
public void close()
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Closes a document stream opened by
open()and forces rendering.- Specified by:
closein interfaceorg.w3c.dom.html.HTMLDocument
write
public void write(java.lang.String text)
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Write a string of text to a document stream opened by
open(). The text is parsed into the document's structure model.- Specified by:
writein interfaceorg.w3c.dom.html.HTMLDocument
writeln
public void writeln(java.lang.String text)
- Description copied from interface:
org.w3c.dom.html.HTMLDocument - Write a string of text followed by a newline character to a document
stream opened by
open(). The text is parsed into the document's structure model.- Specified by:
writelnin interfaceorg.w3c.dom.html.HTMLDocument
cloneNode
public org.w3c.dom.Node cloneNode(boolean deep)
- Description copied from interface:
org.w3c.dom.Node - Returns a duplicate of this node, i.e., serves as a generic copy
constructor for nodes. The duplicate node has no parent; (
parentNodeisnull.).
Cloning anElementcopies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a childTextnode. Cloning anAttributedirectly, as opposed to be cloned as part of anElementcloning operation, returns a specified attribute (specifiedistrue). Cloning any other type of node simply returns a copy of this node.
Note that cloning an immutable subtree results in a mutable copy, but the children of anEntityReferenceclone are readonly . In addition, clones of unspecifiedAttrnodes are specified. And, cloningDocument,DocumentType,Entity, andNotationnodes is implementation dependent.- Specified by:
cloneNodein interfaceorg.w3c.dom.Node
getElementById
private org.w3c.dom.Element getElementById(java.lang.String elementId, org.w3c.dom.Node node)
- Recursive method retreives an element by its
idattribute. This is LazyDOM aware and will not expand elements during search.
populateElementTypes
private static void populateElementTypes()
- Called by the constructor to populate the element types list (see
_elementTypesHTML55 ). Will be called multiple times but populate the list only the first time. Replacement for static constructor.
populateElementType
private static void populateElementType(java.lang.String tagName, java.lang.String className)
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:
createElementin interfaceorg.w3c.dom.Document
createElement
public org.enhydra.xml.lazydom.LazyElement createElement(int nodeId) throws org.w3c.dom.DOMException
- Description copied from class:
org.enhydra.xml.lazydom.LazyDocument - Create a element from a template given its id.
|
|||||||||
| Home >> All >> org >> enhydra >> xml >> lazydom >> [ html overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC