|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.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.apache.html.dom.HTMLDocumentImpl
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()
).
HTMLDocument
, Serialized FormFields inherited from class org.apache.xerces.dom.DocumentImpl |
---|
eventListeners, iterators, mutationEvents, ranges, userData |
Fields inherited from class org.apache.xerces.dom.CoreDocumentImpl |
---|
allowGrammarAccess, changes, docElement, docType, encoding, errorChecking, identifiers, kidOK, standalone, version |
Fields inherited from class org.apache.xerces.dom.ParentNode |
---|
fCachedChild, fCachedChildIndex, fCachedLength, firstChild, ownerDocument |
Fields inherited from class org.apache.xerces.dom.ChildNode |
---|
nextSibling, previousSibling |
Fields inherited from class org.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 |
Constructor Summary | |
---|---|
HTMLDocumentImpl()
|
Method Summary | |
---|---|
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. |
Attr |
createAttribute(java.lang.String name)
Creates an Attribute having this Document as its OwnerDoc. |
Element |
createElement(java.lang.String tagName)
Creates an element of the type specified. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Creates an element of the given qualified name and namespace URI. |
HTMLCollection |
getAnchors()
A collection of all the anchor ( A ) elements in a document
with a value for the name attribute. |
HTMLCollection |
getApplets()
A collection of all the OBJECT elements that include
applets and APPLET ( deprecated ) elements in a document. |
HTMLElement |
getBody()
The element that contains the content for the document. |
java.lang.String |
getCookie()
The cookies associated with this document. |
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. |
Element |
getElementById(java.lang.String elementId)
Returns the Element whose ID is given by
elementId . |
NodeList |
getElementsByName(java.lang.String elementName)
Returns the (possibly empty) collection of elements whose name value is given by elementName . |
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. |
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. |
HTMLCollection |
getForms()
A collection of all the forms of a document. |
HTMLElement |
getHead()
Obtains the <HEAD> element in the document, creating one if does not exist before. |
HTMLCollection |
getImages()
A collection of all the IMG elements in a document. |
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. |
void |
setBody(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, createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, dispatchAggregateEvents, dispatchAggregateEvents, dispatchEvent, dispatchEventToSubtree, getEventListeners, getImplementation, getUserData, removeEventListener, saveEnclosingAttr, setEventListeners, setUserData |
Methods inherited from class org.apache.xerces.dom.ParentNode |
---|
getChildNodes, getChildNodesUnoptimized, getFirstChild, getLastChild, getLength, hasChildNodes, item, normalize, setReadOnly, synchronizeChildren |
Methods inherited from class org.apache.xerces.dom.ChildNode |
---|
getNextSibling, getParentNode, getPreviousSibling |
Methods inherited from class org.apache.xerces.dom.NodeImpl |
---|
addEventListener, appendChild, dispatchEvent, getAttributes, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, hasAttributes, isSupported, removeEventListener, setNodeValue, 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 |
---|
adoptNode, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getEncoding, getImplementation, getStandalone, getStrictErrorChecking, getVersion, importNode, setEncoding, setStandalone, setStrictErrorChecking, setVersion |
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 |
public HTMLDocumentImpl()
Method Detail |
public Element getDocumentElement()
Document
getDocumentElement
in interface Document
getDocumentElement
in class CoreDocumentImpl
public HTMLElement getHead()
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.
public java.lang.String getTitle()
HTMLDocument
TITLE
element
in the head of the document.getTitle
in interface HTMLDocument
public void setTitle(java.lang.String newTitle)
setTitle
in interface HTMLDocument
public HTMLElement getBody()
HTMLDocument
BODY
contents, returns the BODY
element. In frameset documents, this returns the outermost
FRAMESET
element.getBody
in interface HTMLDocument
public void setBody(HTMLElement newBody)
setBody
in interface HTMLDocument
public Element getElementById(java.lang.String elementId)
Document
Element
whose ID
is given by
elementId
. If no such element exists, returns
null
. Behavior is not defined if more than one element
has this ID
. 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 return null
.getElementById
in interface Document
getElementById
in class CoreDocumentImpl
org.w3c.dom.Document
elementIdThe
- unique id
value for an element.public NodeList getElementsByName(java.lang.String elementName)
HTMLDocument
name
value is given by elementName
.getElementsByName
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
elementName
- The name
attribute value for an
element.public final NodeList getElementsByTagName(java.lang.String tagName)
Document
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.getElementsByTagName
in interface Document
getElementsByTagName
in class CoreDocumentImpl
org.w3c.dom.Document
tagnameThe
- name of the tag to match on. The special value "*"
matches all tags.NodeList
object containing all the matched
Elements
.public final NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
Document
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.getElementsByTagNameNS
in interface Document
getElementsByTagNameNS
in class CoreDocumentImpl
org.w3c.dom.Document
namespaceURIThe
- namespace URI of the elements to match on. The
special value "*" matches all namespaces.localNameThe
- local name of the elements to match on. The
special value "*" matches all local names.NodeList
object containing all the matched
Elements
.public Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
Document
createElementNS
in interface Document
createElementNS
in class CoreDocumentImpl
org.w3c.dom.Document
namespaceURIThe
- namespace URI of the element to create.qualifiedNameThe
- qualified name of the element type to
instantiate.Element
object with the following
attributes:AttributeValueNode.nodeName
qualifiedName
Node.namespaceURI
namespaceURI
Node.prefix
prefix, extracted
from qualifiedName
, or null
if there is
no prefixNode.localName
local name, extracted from
qualifiedName
Element.tagName
qualifiedName
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified qualified name
contains an illegal character.
qualifiedName
is
malformed, if the qualifiedName
has a prefix and the
namespaceURI
is null
, or if the
qualifiedName
has a prefix that is "xml" and the
namespaceURI
is different from "
http://www.w3.org/XML/1998/namespace" .public Element createElement(java.lang.String tagName) throws DOMException
Document
Element
interface, so attributes
can be specified directly on the returned object.
Attr
nodes representing them are automatically created
and attached to the element.
createElementNS
method.createElement
in interface Document
createElement
in class CoreDocumentImpl
org.w3c.dom.Document
tagNameThe
- name of the element type to instantiate. For XML,
this is case-sensitive. For HTML, the tagName
parameter may be provided in any case, but it must be mapped to the
canonical uppercase form by the DOM implementation.Element
object with the
nodeName
attribute set to tagName
, and
localName
, prefix
, and
namespaceURI
set to null
.DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name contains an
illegal character.public Attr createAttribute(java.lang.String name) throws DOMException
CoreDocumentImpl.createAttribute(java.lang.String)
and returns
and attribute whose name is lower case.createAttribute
in interface Document
createAttribute
in class CoreDocumentImpl
name
- The name of the attributeDOMException(INVALID_NAME_ERR)
- if the attribute name
is not acceptablepublic java.lang.String getReferrer()
HTMLDocument
getReferrer
in interface HTMLDocument
public java.lang.String getDomain()
HTMLDocument
null
if the server cannot be identified by a domain name.getDomain
in interface HTMLDocument
public java.lang.String getURL()
HTMLDocument
getURL
in interface HTMLDocument
public java.lang.String getCookie()
HTMLDocument
name=value;expires=date
.getCookie
in interface HTMLDocument
public void setCookie(java.lang.String cookie)
setCookie
in interface HTMLDocument
public HTMLCollection getImages()
HTMLDocument
IMG
elements in a document. The
behavior is limited to IMG
elements for backwards
compatibility.getImages
in interface HTMLDocument
public HTMLCollection getApplets()
HTMLDocument
OBJECT
elements that include
applets and APPLET
( deprecated ) elements in a document.getApplets
in interface HTMLDocument
public HTMLCollection getLinks()
HTMLDocument
AREA
elements and anchor (
A
) elements in a document with a value for the
href
attribute.getLinks
in interface HTMLDocument
public HTMLCollection getForms()
HTMLDocument
getForms
in interface HTMLDocument
public HTMLCollection getAnchors()
HTMLDocument
A
) elements in a document
with a value for the name
attribute. Note. For reasons
of backwards compatibility, the returned set of anchors only contains
those anchors created with the name
attribute, not those
created with the id
attribute.getAnchors
in interface HTMLDocument
public void open()
HTMLDocument
open
in interface HTMLDocument
public void close()
HTMLDocument
open()
and forces
rendering.close
in interface HTMLDocument
public void write(java.lang.String text)
HTMLDocument
open()
. The text is parsed into the document's structure
model.write
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
text
- The string to be parsed into some structure in the
document structure model.public void writeln(java.lang.String text)
HTMLDocument
open()
. The text is parsed into the
document's structure model.writeln
in interface HTMLDocument
org.w3c.dom.html.HTMLDocument
text
- The string to be parsed into some structure in the
document structure model.public Node cloneNode(boolean deep)
Node
parentNode
is null
.).
Element
copies 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
child Text
node. Cloning an Attribute
directly, as opposed to be cloned as part of an Element
cloning operation, returns a specified attribute (
specified
is true
). Cloning any other type
of node simply returns a copy of this node.
EntityReference
clone are readonly
. In addition, clones of unspecified Attr
nodes are
specified. And, cloning Document
,
DocumentType
, Entity
, and
Notation
nodes is implementation dependent.cloneNode
in interface Node
cloneNode
in class DocumentImpl
org.w3c.dom.Node
deepIf
- true
, recursively clone the subtree under
the specified node; if false
, clone only the node
itself (and its attributes, if it is an Element
).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |