|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | 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
public class 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 FormField Summary |
---|
Constructor Summary | |
---|---|
HTMLDocumentImpl()
|
Method Summary | |
---|---|
Node |
cloneNode(boolean deep)
Deep-clone a document, including fixing ownerDoc for the cloned children. |
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)
Factory method; creates an Element having this Document as its OwnerDoc. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName)
Introduced in DOM Level 2. |
Element |
createElementNS(java.lang.String namespaceURI,
java.lang.String qualifiedName,
java.lang.String localpart)
Xerces-specific constructor. |
HTMLCollection |
getAnchors()
A collection of all the anchor ( A ) elements in a document
with a value for the name attribute.Note. |
HTMLCollection |
getApplets()
A collection of all the OBJECT elements that includeapplets
and APPLET (deprecated) elements ina document. |
HTMLElement |
getBody()
The element that contains the content for the document. |
java.lang.String |
getCookie()
The cookies associated with this document. |
Element |
getDocumentElement()
Convenience method, allowing direct access to the child node which is considered the root of the actual document content. |
java.lang.String |
getDomain()
The domain name of the server that served the document, or a nullstring if the server cannot be identified by a domain name. |
Element |
getElementById(java.lang.String elementId)
Introduced in DOM Level 2 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)
Return a live collection of all descendent Elements (not just immediate children) having the specified tag name. |
NodeList |
getElementsByTagNameNS(java.lang.String namespaceURI,
java.lang.String localName)
Introduced in DOM Level 2. |
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.The
behavior is limited to IMG elements forbackwards
compatibility. |
HTMLCollection |
getLinks()
A collection of all AREA elements andanchor (A )
elements in a documentwith 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.This method and the ones following allow a user to add to or replace the structuremodel of a document using strings of unparsed HTML. |
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 |
---|
createEvent, createNodeIterator, createNodeIterator, createRange, createTreeWalker, createTreeWalker, getImplementation |
Methods inherited from class org.apache.xerces.dom.ParentNode |
---|
getChildNodes, getFirstChild, getLastChild, getLength, hasChildNodes, isEqualNode, item, normalize, setReadOnly |
Methods inherited from class org.apache.xerces.dom.ChildNode |
---|
getNextSibling, getParentNode, getPreviousSibling |
Methods inherited from class org.apache.xerces.dom.NodeImpl |
---|
addEventListener, appendChild, compareDocumentPosition, compareTreePosition, dispatchEvent, getAttributes, getLocalName, getNamespaceURI, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.w3c.dom.Node |
---|
appendChild, 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 |
---|
public HTMLDocumentImpl()
Method Detail |
---|
public Element getDocumentElement()
CoreDocumentImpl
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, and in
frameset documents, this returns the outermostFRAMESET
element.
getBody
in interface HTMLDocument
public void setBody(HTMLElement newBody)
setBody
in interface HTMLDocument
public Element getElementById(java.lang.String elementId)
CoreDocumentImpl
Note: 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 interface HTMLDocument
getElementById
in class CoreDocumentImpl
elementId
- The unique id
value for an element.
null
if there is none.CoreDocumentImpl.getIdentifier(java.lang.String)
public NodeList getElementsByName(java.lang.String elementName)
HTMLDocument
name
value is given by elementName
.
getElementsByName
in interface HTMLDocument
elementName
- The name
attribute value for an element.
public final NodeList getElementsByTagName(java.lang.String tagName)
CoreDocumentImpl
getElementsByTagName
in interface Document
getElementsByTagName
in class CoreDocumentImpl
tagName
- The type of Element we want to gather. "*" will be
taken as a wildcard, meaning "all elements in the document."
NodeList
object containing all the matched
Elements
.DeepNodeListImpl
public final NodeList getElementsByTagNameNS(java.lang.String namespaceURI, java.lang.String localName)
CoreDocumentImpl
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.
getElementsByTagNameNS
in interface Document
getElementsByTagNameNS
in class CoreDocumentImpl
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.
public Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName, java.lang.String localpart) throws DOMException
createElementNS
in class CoreDocumentImpl
namespaceURI
- The namespace URI of the element to
create.qualifiedName
- The qualified name of the element type to
instantiate.localpart
- The local name of the element to instantiate.
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified
name contains an invalid character.public Element createElementNS(java.lang.String namespaceURI, java.lang.String qualifiedName)
CoreDocumentImpl
Creates an element of the given qualified name and namespace URI. If the given namespaceURI is null or an empty string and the qualifiedName has a prefix that is "xml", the created element is bound to the predefined namespace "http://www.w3.org/XML/1998/namespace" [Namespaces].
createElementNS
in interface Document
createElementNS
in class CoreDocumentImpl
namespaceURI
- The namespace URI of the element to
create.qualifiedName
- The qualified name of the element type to
instantiate.
public Element createElement(java.lang.String tagName) throws DOMException
CoreDocumentImpl
createElement
in interface Document
createElement
in class CoreDocumentImpl
tagName
- The 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 is not an XML
name according to the XML version in use specified in the
Document.xmlVersion
attribute.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 attribute
DOMException(INVALID_NAME_ERR)
- if the attribute name
is not acceptable
DOMException
- INVALID_CHARACTER_ERR: Raised if the specified name is not an XML
name according to the XML version in use specified in the
Document.xmlVersion
attribute.public java.lang.String getReferrer()
HTMLDocument
getReferrer
in interface HTMLDocument
public java.lang.String getDomain()
HTMLDocument
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 forbackwards
compatibility.
getImages
in interface HTMLDocument
public HTMLCollection getApplets()
HTMLDocument
OBJECT
elements that includeapplets
and APPLET
(deprecated) elements ina document.
getApplets
in interface HTMLDocument
public HTMLCollection getLinks()
HTMLDocument
AREA
elements andanchor (A
)
elements in a documentwith 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
backwardscompatibility, 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 structuremodel.
write
in interface HTMLDocument
text
- The string to be parsed into some structure in the document
structuremodel.public void writeln(java.lang.String text)
HTMLDocument
open()
. The text is parsed into the
document's structure model.
writeln
in interface HTMLDocument
text
- The string to be parsed into some structure in the document
structuremodel.public Node cloneNode(boolean deep)
DocumentImpl
cloneNode
in interface Node
cloneNode
in class DocumentImpl
deep
- boolean, iff true replicate children
Example: Cloning a Text node will copy both the node and the text it
contains.
Example: Cloning something that has children -- Element or Attr, for
example -- will _not_ clone those children unless a "deep clone"
has been requested. A shallow clone of an Attr node will yield an
empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned
is read-only, to permit applications using only the DOM API to obtain
editable copies of locked portions of the tree.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |