Class DOMDocument
- All Implemented Interfaces:
DOMNode
,NonDocumentTypeChildNode
,ParentNode
,CSSDocument
,CSSNode
,Serializable
,Document
,Node
,org.w3c.dom.stylesheets.DocumentStyle
- Direct Known Subclasses:
HTMLDocument
Implementation of a DOM Document
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.sf.carte.doc.style.css.CSSDocument
CSSDocument.ComplianceMode
-
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescriptionappendChild
(Node newChild) Adds the nodenewChild
to the end of the list of children of this node.cloneNode
(boolean deep) short
compareDocumentPosition
(Node other) boolean
Test ifnode
is an inclusive descendant of this node.createAttribute
(String name) createAttributeNS
(String namespaceURI, String qualifiedName) createCDATASection
(String data) createComment
(String data) createElement
(String tagName) Creates an element of the type specified, with anull
namespace URI.createElementNS
(String namespaceURI, String qualifiedName) Creates an element with the given qualified name and namespace URI.createEntityReference
(String name) createNodeIterator
(Node rootNode, int whatToShow, NodeFilter filter) Create aNodeIterator
object with the given root node,whatToShow
bitmask, andfilter
callback.createProcessingInstruction
(String target, String data) createTextNode
(String data) createTreeWalker
(Node rootNode, int whatToShow, NodeFilter filter) Create aTreeWalker
object with the given root node,whatToShow
bitmask, andfilter
callback.Creates a new iterator descending over the child nodes, starting from the last child node.Creates a new iterator over the child elements.elementIterator
(String tagname) Creates a new iterator over the child elements of the given tagname.elementIteratorNS
(String namespaceURI, String localName) Creates a new iterator over the child elements of the given namespaceURI and localName.void
Enables a style sheet set.Gets the absolute base URI of this node.Gets the base URL of this Document.Gets the document's canvas for the current target medium.int
Gets the number of child nodes of type Element that this parent node has.Get the children of this node.Gets the live ElementList containing all nodes of type Element that are children of this Element.Get the compatibility mode (compatMode
) attribute.Get the compliance mode of this document.Get the child node which is the document element of this document.Gets the location of this document.getElementById
(String elementId) Returns the Element that has an ID attribute with the given value.getElementsByClassName
(String names) Gives a live NodeList containing all child elements which have all of the given class names under this reference element.getElementsByTagName
(String name) Gives anElementList
of all the elements descending from this context node that have the given tag name, in document order.getElementsByTagNameNS
(String namespaceURI, String localName) Gives anElementList
of all the elements descending from this context node that have the given local name and namespace URI, in document order.Gets the document-level error handler.getFeature
(String feature, String version) Deprecated.Get the first child of this node.Gets the Element that is the first child of this ParentNode.abstract CSSDOMImplementation
Get the DOM implementation that created this document.Give the encoding used when the document was parsed, if known.Get the last child of this node.Gets the DOMElement that is the last child of this ParentNode.Gets the style sheet set that was last selected.Gives the local part of the qualified name of this node.Gets the first following sibling that is an element.Get the node immediately following this node in its parent's child list.short
Get theDOMDocument
object related to this node (for all nodes exceptDocumentType
, it is the document that created it), which is also the object that should be used to create new nodes for the document.Gets the first preceding sibling that is an element.Get the node immediately preceding this node in its parent's child list.Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.Gets the title of the currently selected style sheet set.boolean
Gets the style database currently used to apply specific styles to this document.Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet.protected abstract CSSDOMImplementation
A list containing all the style sheets explicitly linked into or embedded in a document.Gets the list of available alternate styles.This document's current target medium name.Gets an URL for the given URI, taking into account the Base URL if appropriate.getUserData
(String key) Deprecated.boolean
Deprecated.Deprecated.boolean
boolean
Does this node have any child nodes ?boolean
Has any of the linked or embedded style sheets any error or warning ?importNode
(Node importedNode, boolean deep) insertBefore
(Node newChild, Node refChild) Inserts the nodenewChild
right before noderefChild
in the child node list.boolean
isAuthorizedOrigin
(URL url) Determine whether the retrieval of the given URL is authorized.boolean
isDefaultNamespace
(String namespaceURI) boolean
isEqualNode
(Node arg) boolean
isSafeOrigin
(URL linkedURL) Is the provided URL a safe origin to load certain external resources?boolean
isSameNode
(Node other) boolean
isSupported
(String feature, String version) Deprecated.boolean
isVisitedURI
(String href) Has this URI been visited by the agent ?iterator()
Creates a new iterator over the child nodes.iterator
(int whatToShow, NodeFilter filter) Creates a new iterator over the child nodes.iterator
(NodeFilter filter) Creates a new iterator over the child nodes.Creates a new iterator over the child nodes.Creates a new list iterator over the child nodes.lookupNamespaceURI
(String prefix) lookupPrefix
(String namespaceURI) void
void
Normalizes the document element, if there is one.void
onMetaAdded
(String name, String attribute) Notify the document about the addition of aMETA
element that may affect the inner workings of this document.void
onMetaRemoved
(String name, String attribute) Notify the document about the removal of aMETA
element that may affect the inner workings of this document.openStream
(String uri) Opens an InputStream for the given URI, taking into account the Base URL if needed.prependChild
(Node newChild) querySelectorAll
(String selectors) Gets a static list of the elements that match any of the specified group of selectors.void
Forces the cascade to be rebuilt the next time that a computed style is obtained.void
registerProperty
(CSSPropertyDefinition definition) Registers the definition of a custom property.void
Removes all the children from this node, if any.removeChild
(Node oldChild) Removes the nodeoldChild
from the children of this node.renameNode
(Node n, String namespaceURI, String qualifiedName) Deprecated.replaceChild
(Node newChild, Node oldChild) Replaces the nodeoldChild
withnewChild
.void
setDocumentURI
(String documentURI) Sets the location of this document.void
setNodeValue
(String nodeValue) void
protected void
setReferrerPolicyHeader
(String policy) void
Selects a style sheet set, disabling the other non-persistent sheet sets.void
setStrictErrorChecking
(boolean strictErrorChecking) void
setTargetMedium
(String medium) Set the medium that will be used to compute the styles of this document.void
setTextContent
(String textContent) setUserData
(String key, Object data, UserDataHandler handler) void
setXmlStandalone
(boolean xmlStandalone) Deprecated.void
setXmlVersion
(String xmlVersion) Deprecated.toString()
typeIterator
(short typeToShow) Creates a new iterator over the child nodes.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.sf.carte.doc.style.css.CSSDocument
openConnection
Methods inherited from interface org.w3c.dom.Document
getElementsByTagName, getElementsByTagNameNS
Methods inherited from interface io.sf.carte.doc.dom.DOMNode
appendChild, getFirstChild, getLastChild, getNextSibling, getPreviousSibling, hasChildNodes, removeAllChild, removeChild
Methods inherited from interface org.w3c.dom.Node
compareDocumentPosition, getAttributes, getFeature, getLocalName, getNamespaceURI, getNodeType, getNodeValue, getPrefix, getTextContent, getUserData, hasAttributes, isEqualNode, isSameNode, isSupported, normalize, setNodeValue, setPrefix, setTextContent, setUserData
Methods inherited from interface io.sf.carte.doc.dom.ParentNode
getChildElementCount, getChildNodes, getFirstElementChild, getLastElementChild, prependChild
-
Constructor Details
-
DOMDocument
-
-
Method Details
-
getCompatMode
Get the compatibility mode (compatMode
) attribute.- Specified by:
getCompatMode
in interfaceCSSDocument
- Returns:
- the string "BackCompat" if document’s mode is
QUIRKS
, otherwise "CSS1Compat".
-
getComplianceMode
Get the compliance mode of this document.The styling in this document operate under a compliance mode. Two modes are supported:
STRICT
andQUIRKS
.QUIRKS
andSTRICT
differ in the matching of class and ID selectors, and the default user agent sheet is slightly different.- Specified by:
getComplianceMode
in interfaceCSSDocument
- Returns:
- the compliance mode.
-
getDocumentElement
Get the child node which is the document element of this document.- Specified by:
getDocumentElement
in interfaceCSSDocument
- Specified by:
getDocumentElement
in interfaceDocument
- Returns:
- the document element.
-
getDoctype
- Specified by:
getDoctype
in interfaceDocument
-
getNodeName
- Specified by:
getNodeName
in interfaceNode
-
getOwnerDocument
Get theDOMDocument
object related to this node (for all nodes exceptDocumentType
, it is the document that created it), which is also the object that should be used to create new nodes for the document.- Specified by:
getOwnerDocument
in interfaceCSSNode
- Specified by:
getOwnerDocument
in interfaceDOMNode
- Specified by:
getOwnerDocument
in interfaceNode
- Returns:
- the
DOMDocument
object corresponding to this node. When this node is aDOMDocument
or aDocumentType
which was not added to anyDOMDocument
yet, this isnull
.
-
getParentNode
- Specified by:
getParentNode
in interfaceDOMNode
- Specified by:
getParentNode
in interfaceNode
-
isVisitedURI
Has this URI been visited by the agent ?- Specified by:
isVisitedURI
in interfaceCSSDocument
- Parameters:
href
- the URI.- Returns:
true
if visited,false
if not visited or the agent does not support history.
-
cloneNode
-
getImplementation
Get the DOM implementation that created this document.- Specified by:
getImplementation
in interfaceDocument
- Returns:
- the DOM implementation that created this document.
-
getStyleSheetFactory
-
createElement
Creates an element of the type specified, with anull
namespace URI.The
tagName
is transformed to lower case.No default attributes are created.
- Specified by:
createElement
in interfaceCSSDocument
- Specified by:
createElement
in interfaceDocument
- Parameters:
tagName
- the tag name of the element to create.- Returns:
- the new
DOMElement
. - Throws:
DOMException
- INVALID_CHARACTER_ERR if the name is not an XML valid name.
-
createElementNS
Creates an element with the given qualified name and namespace URI.If
namespaceURI
isnull
or the empty string, thequalifiedName
is transformed to lower case.No default attributes are created.
- Specified by:
createElementNS
in interfaceCSSDocument
- Specified by:
createElementNS
in interfaceDocument
- Parameters:
namespaceURI
- the namespace URI of the element to create.qualifiedName
- the qualified name of the element to create. The namespace prefix, if any, is extracted from this name.- Returns:
- the new
DOMElement
. - Throws:
DOMException
- INVALID_CHARACTER_ERR if the name is not an XML valid name.
NAMESPACE_ERR: if thequalifiedName
is a malformed qualified name, if thequalifiedName
has a prefix and thenamespaceURI
isnull
, or if thequalifiedName
has a prefix that is"xml"
and thenamespaceURI
is different from"http://www.w3.org/XML/1998/namespace"
, or if thequalifiedName
or its prefix is"xmlns"
and thenamespaceURI
is different from"http://www.w3.org/2000/xmlns/"
, or if thenamespaceURI
is"http://www.w3.org/2000/xmlns/"
and neither thequalifiedName
nor its prefix is"xmlns"
.
-
createDocumentFragment
- Specified by:
createDocumentFragment
in interfaceDocument
-
createTextNode
- Specified by:
createTextNode
in interfaceDocument
-
createComment
- Specified by:
createComment
in interfaceDocument
-
createCDATASection
- Specified by:
createCDATASection
in interfaceDocument
- Throws:
DOMException
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException - Specified by:
createProcessingInstruction
in interfaceDocument
- Throws:
DOMException
-
createEntityReference
- Specified by:
createEntityReference
in interfaceDocument
- Throws:
DOMException
-
createAttribute
- Specified by:
createAttribute
in interfaceDocument
- Throws:
DOMException
-
createAttributeNS
- Specified by:
createAttributeNS
in interfaceDocument
- Throws:
DOMException
-
createNodeIterator
Create aNodeIterator
object with the given root node,whatToShow
bitmask, andfilter
callback.Example:
NodeIterator it = document.createNodeIterator(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null);
Based on the
createNodeIterator()
method in DOM Level 4.The returned object can be cast to
NodeIterator
, but the behaviour is not exactly what that interface documents (see this library'sNodeIterator
interface description for more details). If you need compatibility with the W3C-specified behaviour, never use aNodeFilter
that returnsNodeFilter.FILTER_SKIP_NODE_CHILD
(that is, W3C'sNodeFilter.FILTER_REJECT
).- Parameters:
rootNode
- the root node.whatToShow
- a bitmask specifying what types of nodes to show.filter
- an optional filter callback, seeNodeFilter
.- Returns:
- the node iterator.
-
createTreeWalker
Create aTreeWalker
object with the given root node,whatToShow
bitmask, andfilter
callback.Example:
TreeWalker tw = document.createTreeWalker(document.getDocumentElement(), NodeFilter.SHOW_ELEMENT, null);
Based on the
createTreeWalker()
method in DOM Level 4.Beware that this library's
NodeFilter
uses names different to W3C's for the filter values:NodeFilter.FILTER_SKIP_NODE_CHILD
instead of W3C'sNodeFilter.FILTER_REJECT
), andNodeFilter.FILTER_SKIP_NODE
instead ofNodeFilter.FILTER_SKIP
. But the defined numeric values are the same, so they can be used interchangeably in theTreeWalker
.- Parameters:
rootNode
- the root node.whatToShow
- a bitmask specifying what types of nodes to show.filter
- an optional filter callback, seeNodeFilter
.- Returns:
- the tree walker.
-
getElementsByClassName
Gives a live NodeList containing all child elements which have all of the given class names under this reference element.- Specified by:
getElementsByClassName
in interfaceParentNode
- Parameters:
names
- the names of the classes, separated by whitespace.- Returns:
- the live NodeList containing all child elements which have all of the given class names under this reference element.
-
lookupPrefix
- Specified by:
lookupPrefix
in interfaceNode
-
getElementById
Returns the Element that has an ID attribute with the given value.If no such element exists, this returns
null
. If more than one element has an ID attribute with that value, what is returned is undefined.This implementation uses
'id'
as the ID attribute, case insensitively inQUIRKS
mode.- Specified by:
getElementById
in interfaceCSSDocument
- Specified by:
getElementById
in interfaceDocument
- Parameters:
elementId
- The unique id value for an element.- Returns:
- The matching element or
null
if there is none.
-
getInputEncoding
Give the encoding used when the document was parsed, if known.- Specified by:
getInputEncoding
in interfaceDocument
- Returns:
null
.
-
getXmlEncoding
Deprecated.Now deprecated, this method gave the encoding specified at the XML declaration.- Specified by:
getXmlEncoding
in interfaceDocument
- Returns:
null
.
-
getXmlStandalone
Deprecated.Get whether this document is standalone as specified at the XML declaration.- Specified by:
getXmlStandalone
in interfaceDocument
- Returns:
null
.
-
setXmlStandalone
Deprecated.Set whether this document is standalone as specified at the XML declaration.Calling this method has no effect.
- Specified by:
setXmlStandalone
in interfaceDocument
- Parameters:
xmlStandalone
- argument is ignored.- Throws:
DOMException
-
getXmlVersion
Deprecated.Get the version for the "XML" feature.- Specified by:
getXmlVersion
in interfaceDocument
- Returns:
null
.
-
setXmlVersion
Deprecated.Set the version for the "XML" feature.- Specified by:
setXmlVersion
in interfaceDocument
- Parameters:
xmlVersion
- this parameter is ignored.- Throws:
DOMException
-
getStrictErrorChecking
public boolean getStrictErrorChecking()- Specified by:
getStrictErrorChecking
in interfaceDocument
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking) - Specified by:
setStrictErrorChecking
in interfaceDocument
-
getDocumentURI
Gets the location of this document.- Specified by:
getDocumentURI
in interfaceDocument
- Returns:
- the location of this document, or
null
if not set.
-
setDocumentURI
Sets the location of this document.For security reasons, if you want to retrieve linked style sheets from local URLs (like
file:
), you need to set thedocumentURI
to a local scheme (file:
orjar:
) as well.No lexical checking is performed when setting this attribute; this could result in a
null
value returned when usinggetBaseURI()
.- Specified by:
setDocumentURI
in interfaceDocument
- Parameters:
documentURI
- the document URI.
-
importNode
- Specified by:
importNode
in interfaceDocument
- Throws:
DOMException
-
adoptNode
- Specified by:
adoptNode
in interfaceDocument
- Throws:
DOMException
-
insertBefore
Inserts the nodenewChild
right before noderefChild
in the child node list.- If
refChild
isnull
,newChild
is appended at the end of the child list. - If the
newChild
is already in the tree, it is first removed. - Inserting a node before itself has no effect.
- Specified by:
insertBefore
in interfaceDOMNode
- Specified by:
insertBefore
in interfaceNode
- Parameters:
newChild
- the node to put at the child node list, beforerefChild
. If it is aDocumentFragment
object, the entire contents of the document fragment are inserted into the child list of this node.refChild
- the node before whichnewChild
must be inserted.- Returns:
- the inserted node.
- Throws:
DOMException
- HIERARCHY_REQUEST_ERR: raised if this node is of a type that does not allow children of the type of thenewChild
node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocument
and the DOM application attempts to append a secondDocumentType
orElement
node.
WRONG_DOCUMENT_ERR: ifnewChild
was created from a different document than the one that created this node.
NOT_FOUND_ERR: ifrefChild
is not a child of this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChild
at this node.
- If
-
replaceChild
Replaces the nodeoldChild
withnewChild
. If thenewChild
is already in the tree, it is first removed.Replacing a node with itself has no effect.
- Specified by:
replaceChild
in interfaceDOMNode
- Specified by:
replaceChild
in interfaceNode
- Parameters:
newChild
- the node to put at the child node list, in place ofoldChild
. If it is aDocumentFragment
object, the entire contents of the document fragment are inserted into the child list of this node.oldChild
- the node being replaced.- Returns:
- the replaced (old) node.
- Throws:
DOMException
- HIERARCHY_REQUEST_ERR: raised if this node is of a type that does not allow children of the type of thenewChild
node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocument
and the DOM application attempts to append a secondDocumentType
orElement
node.
WRONG_DOCUMENT_ERR: ifnewChild
was created from a different document than the one that created this node.
NOT_FOUND_ERR: ifoldChild
is not a child of this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChild
at this node.
-
renameNode
@Deprecated public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException Deprecated.- Specified by:
renameNode
in interfaceDocument
- Throws:
DOMException
-
getDomConfig
Only the
normalize-characters
andcomments
parameters are configurable and can be toggled. Other parameters can only be set to defaults (or cannot be set at all, likesplit-cdata-sections
because the implementation does not allow split CDATA), andwell-formed
is just ignored (malformed characters are not allowed in this implementation).Also supports the proprietary:
css-whitespace-processing
- Defaults to
true
and enables CSS-like whitespace processing, much safer than just removing element content whitespace. use-computed-styles
- If
true
-defaults tofalse
-, uses computed styles to determine the value of thewhite-space
CSS property when handlingcss-whitespace-processing
.
- Specified by:
getDomConfig
in interfaceDocument
-
normalizeDocument
public void normalizeDocument()Normalizes the document element, if there is one.- Specified by:
normalizeDocument
in interfaceDocument
-
lookupNamespaceURI
- Specified by:
lookupNamespaceURI
in interfaceNode
-
isDefaultNamespace
- Specified by:
isDefaultNamespace
in interfaceNode
-
registerProperty
Description copied from interface:CSSDocument
Registers the definition of a custom property.- Specified by:
registerProperty
in interfaceCSSDocument
- Parameters:
definition
- the definition.- See Also:
-
getStyleSheets
A list containing all the style sheets explicitly linked into or embedded in a document. For HTML documents, this includes external style sheets, included via the HTML LINK element, and inline STYLE elements. In XML, this includes external style sheets, included via style sheet processing instructions (see [XML StyleSheet]).- Specified by:
getStyleSheets
in interfaceCSSDocument
- Specified by:
getStyleSheets
in interfaceorg.w3c.dom.stylesheets.DocumentStyle
-
getStyleSheet
Gets the merged style sheet that applies to this document, resulting from the merge of the document's default style sheet, the document linked or embedded style sheets, and the non-important part of the user style sheet. Does not include overriden styles nor the 'important' part of the user-defined style sheet.The style sheet is lazily built.
- Specified by:
getStyleSheet
in interfaceCSSDocument
- Returns:
- the merged style sheet that applies to this document.
-
getStyleSheetSets
Gets the list of available alternate styles.- Specified by:
getStyleSheetSets
in interfaceCSSDocument
- Returns:
- the list of available alternate style titles.
-
getSelectedStyleSheetSet
Gets the title of the currently selected style sheet set.- Specified by:
getSelectedStyleSheetSet
in interfaceCSSDocument
- Returns:
- the title of the currently selected style sheet, the empty string if none is
selected, or
null
if there are style sheets from different style sheet sets that have their style sheet disabled flag unset.
-
setSelectedStyleSheetSet
Selects a style sheet set, disabling the other non-persistent sheet sets. If the name is the empty string, all non-persistent sheets will be disabled. Otherwise, if the name does not match any of the sets, does nothing.- Specified by:
setSelectedStyleSheetSet
in interfaceCSSDocument
- Parameters:
name
- the case-sensitive name of the set to select.
-
getLastStyleSheetSet
Gets the style sheet set that was last selected.- Specified by:
getLastStyleSheetSet
in interfaceCSSDocument
- Returns:
- the last selected style sheet set, or
null
if none.
-
enableStyleSheetsForSet
Enables a style sheet set. If the name does not match any of the sets, does nothing.- Specified by:
enableStyleSheetsForSet
in interfaceCSSDocument
- Parameters:
name
- the case-sensitive name of the set to enable.
-
getStyleDatabase
Gets the style database currently used to apply specific styles to this document.- Specified by:
getStyleDatabase
in interfaceCSSDocument
- Returns:
- the style database, or null if no style database has been selected.
-
getTargetMedium
This document's current target medium name.- Specified by:
getTargetMedium
in interfaceCSSDocument
- Returns:
- the target medium name of this document.
-
setTargetMedium
Set the medium that will be used to compute the styles of this document.- Specified by:
setTargetMedium
in interfaceCSSDocument
- Parameters:
medium
- the name of the target medium, like 'screen' or 'print'.- Throws:
CSSMediaException
- if the document is unable to target the given medium.
-
getCanvas
Gets the document's canvas for the current target medium.- Specified by:
getCanvas
in interfaceCSSDocument
- Returns:
- the canvas, or null if no target medium has been set, or the DeviceFactory does not support canvas for the target medium.
-
rebuildCascade
public void rebuildCascade()Description copied from interface:CSSDocument
Forces the cascade to be rebuilt the next time that a computed style is obtained.This method should be called after you modify the styles in a way that is not detected by the library (like modifying a value).
- Specified by:
rebuildCascade
in interfaceCSSDocument
-
getErrorHandler
Description copied from interface:CSSDocument
Gets the document-level error handler.- Specified by:
getErrorHandler
in interfaceCSSDocument
- Returns:
- the error handler.
-
hasStyleIssues
public boolean hasStyleIssues()Has any of the linked or embedded style sheets any error or warning ?- Specified by:
hasStyleIssues
in interfaceCSSDocument
- Returns:
true
if any of the linked or embedded style sheets has any SAC or rule error or warning,false
otherwise.
-
onMetaAdded
Notify the document about the addition of aMETA
element that may affect the inner workings of this document.This method avoids having to rescan
META
elements for each style-related operation.- Parameters:
name
- theMETA
name.attribute
- the attribute.
-
onMetaRemoved
Notify the document about the removal of aMETA
element that may affect the inner workings of this document.This method avoids having to rescan
META
elements for each style-related operation.- Parameters:
name
- theMETA
name.attribute
- the attribute.
-
getBaseURL
Gets the base URL of this Document.If the Document's
head
element has abase
child element, the base URI is computed using the value of the href attribute of thebase
element.- Specified by:
getBaseURL
in interfaceCSSDocument
- Returns:
- the base URL, or null if no base URL could be found.
-
getBaseURI
Gets the absolute base URI of this node.- Specified by:
getBaseURI
in interfaceNode
- Returns:
- the absolute base URI of this node, or null if an absolute URI could not be obtained.
-
getURL
Gets an URL for the given URI, taking into account the Base URL if appropriate.- Specified by:
getURL
in interfaceCSSDocument
- Parameters:
uri
- the uri.- Returns:
- the absolute URL.
- Throws:
MalformedURLException
- if the uri was wrong.
-
isSafeOrigin
Is the provided URL a safe origin to load certain external resources?- Specified by:
isSafeOrigin
in interfaceCSSDocument
- Parameters:
linkedURL
- the URL of the external resource.- Returns:
true
if is a safe origin,false
otherwise.
-
isAuthorizedOrigin
Determine whether the retrieval of the given URL is authorized.If the URL's protocol is not
http
norhttps
and document's base URL's scheme is neitherfile
norjar
, it is denied.Developers may want to override this implementation to enforce different restrictions.
- Specified by:
isAuthorizedOrigin
in interfaceCSSDocument
- Parameters:
url
- the URL to check.- Returns:
true
if allowed.
-
getReferrerPolicy
Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.- Specified by:
getReferrerPolicy
in interfaceCSSDocument
- Returns:
- the referrer policy, or the empty string if none was specified.
-
setReferrerPolicyHeader
-
toString
-
openStream
Opens an InputStream for the given URI, taking into account the Base URL if needed.- Parameters:
uri
- the uri to open a connection.- Returns:
- the InputStream.
- Throws:
IOException
- if the uri was wrong, or the stream could not be opened.
-
getChildren
Gets the live ElementList containing all nodes of type Element that are children of this Element.- Specified by:
getChildren
in interfaceParentNode
- Returns:
- the ElementList containing all nodes of type Element that are children of this Element.
-
querySelectorAll
Gets a static list of the elements that match any of the specified group of selectors.Unlike methods like
ParentNode.getElementsByTagName(String)
orParentNode.getElementsByClassName(String)
, this is not a live list but a static one, representing the state of the document when the method was called. If no elements match, the list will be empty.- Specified by:
querySelectorAll
in interfaceParentNode
- Parameters:
selectors
- a comma-separated list of selectors.- Returns:
- an ElementList with the elements that match any of the specified group of selectors.
-
iterator
Creates a new iterator over the child nodes.- Specified by:
iterator
in interfaceParentNode
- Returns:
- an iterator over the child nodes.
-
descendingIterator
Creates a new iterator descending over the child nodes, starting from the last child node.- Specified by:
descendingIterator
in interfaceParentNode
- Returns:
- an iterator descending over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow bit field.
Example:
BitSet mask = new BitSet(32); mask.set(Node.ELEMENT_NODE); Iterator<Node> it = node.iterator(mask);
- Specified by:
iterator
in interfaceParentNode
- Parameters:
whatToShow
- a bit set.- Returns:
- an iterator over the child nodes.
-
elementIterator
Creates a new iterator over the child elements.- Specified by:
elementIterator
in interfaceParentNode
- Returns:
- an iterator over the child elements.
-
elementIterator
Creates a new iterator over the child elements of the given tagname.- Specified by:
elementIterator
in interfaceParentNode
- Parameters:
tagname
- The tag name of the child elements to match on.- Returns:
- an iterator over the child elements.
-
elementIteratorNS
Creates a new iterator over the child elements of the given namespaceURI and localName.- Specified by:
elementIteratorNS
in interfaceParentNode
- Parameters:
namespaceURI
- the namespace URI of the elements to match on.localName
- The local name of the elements to match on.- Returns:
- an iterator over the child elements.
-
iterator
Creates a new iterator over the child nodes.It only iterates over types set in the whatToShow mask that satisfy the custom
NodeFilter
.Example:
Iterator<Node> it = node.iterator(NodeFilter.SHOW_ELEMENT, null);
- Specified by:
iterator
in interfaceParentNode
- Parameters:
whatToShow
- the bit field mask to apply to the node types, seeNodeFilter
. Do not confuse this argument with theshort
argument of theParentNode.typeIterator(short)
method.filter
- the filter to use in the iteration. ifnull
, only thewhatToShow
mask filter is applied.- Returns:
- an iterator over the child nodes.
-
typeIterator
Creates a new iterator over the child nodes.Do not confuse the
typeToShow
argument with theint
argument of theParentNode.iterator(int, NodeFilter)
method, which is a bit field.- Specified by:
typeIterator
in interfaceParentNode
- Parameters:
typeToShow
- the node type to show (fromNode.getNodeType()
).- Returns:
- an iterator over the child nodes.
-
iterator
Creates a new iterator over the child nodes.It only iterates over nodes accepted by the filter.
- Specified by:
iterator
in interfaceParentNode
- Parameters:
filter
- a filter, seeNodeFilter
.- Returns:
- an iterator over the child nodes.
-
listIterator
Creates a new list iterator over the child nodes.- Specified by:
listIterator
in interfaceParentNode
- Returns:
- a list iterator over the child nodes.
-
getElementsByTagNameNS
Gives anElementList
of all the elements descending from this context node that have the given local name and namespace URI, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList
.The most efficient way to browse the returned list is to iterate it.
- Specified by:
getElementsByTagNameNS
in interfaceParentNode
- Parameters:
namespaceURI
- the namespace URI of the elements to match on. The special value "*
" matches all namespaces.localName
- The local name of the elements to match on. The special value "*
" matches all local names.- Returns:
- the
ElementList
object containing all the matched elements.
-
getElementsByTagName
Gives anElementList
of all the elements descending from this context node that have the given tag name, in document order.The list is a live collection, and changes to the document made after calling this method are reflected in the
ElementList
.The most efficient way to browse the returned list is to iterate it.
- Specified by:
getElementsByTagName
in interfaceParentNode
- Parameters:
name
- The tag name of the elements to match on. The special value "*
" matches all tag names.- Returns:
- the
ElementList
object containing all the matched elements.
-
getFirstElementChild
Gets the Element that is the first child of this ParentNode.- Returns:
- the Element that is the first child of this ParentNode, or null if there is none.
-
getLastElementChild
Gets the DOMElement that is the last child of this ParentNode.- Returns:
- the DOMElement that is the last child of this ParentNode, or null if there is none.
-
getChildElementCount
public int getChildElementCount()Gets the number of child nodes of type Element that this parent node has.- Returns:
- the number of child nodes of type Element that this ParentNode has.
-
hasChildNodes
public boolean hasChildNodes()Description copied from interface:DOMNode
Does this node have any child nodes ?- Specified by:
hasChildNodes
in interfaceDOMNode
- Specified by:
hasChildNodes
in interfaceNode
- Returns:
true
if this node has child nodes,false
otherwise.
-
getPreviousElementSibling
Description copied from interface:NonDocumentTypeChildNode
Gets the first preceding sibling that is an element.- Specified by:
getPreviousElementSibling
in interfaceNonDocumentTypeChildNode
- Returns:
- the first preceding sibling that is an element, and
null
otherwise.
-
getNextElementSibling
Description copied from interface:NonDocumentTypeChildNode
Gets the first following sibling that is an element.- Specified by:
getNextElementSibling
in interfaceNonDocumentTypeChildNode
- Returns:
- the first following sibling that is an element, and
null
otherwise.
-
prependChild
- Throws:
DOMException
-
getNodeValue
- Specified by:
getNodeValue
in interfaceNode
- Throws:
DOMException
-
setNodeValue
- Specified by:
setNodeValue
in interfaceNode
- Throws:
DOMException
-
getNodeType
public short getNodeType()- Specified by:
getNodeType
in interfaceNode
-
getLocalName
Gives the local part of the qualified name of this node. For nodes of any type other thanELEMENT_NODE
andATTRIBUTE_NODE
, this is always null.- Specified by:
getLocalName
in interfaceNode
- Returns:
- the local part of the qualified name of this node, or null if this
node is not an
ELEMENT_NODE
nor anATTRIBUTE_NODE
.
-
getAttributes
- Specified by:
getAttributes
in interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributes
in interfaceNode
-
getChildNodes
Description copied from interface:DOMNode
Get the children of this node.- Specified by:
getChildNodes
in interfaceDOMNode
- Specified by:
getChildNodes
in interfaceNode
- Returns:
- a
DOMNodeList
with the children of this node. If there are no children, an empty list is returned.
-
getFirstChild
Description copied from interface:DOMNode
Get the first child of this node.- Specified by:
getFirstChild
in interfaceDOMNode
- Specified by:
getFirstChild
in interfaceNode
- Returns:
- the first child of this node,
null
if has no child nodes.
-
getLastChild
Description copied from interface:DOMNode
Get the last child of this node.- Specified by:
getLastChild
in interfaceDOMNode
- Specified by:
getLastChild
in interfaceNode
- Returns:
- the last child of this node,
null
if has no child nodes.
-
getPreviousSibling
Description copied from interface:DOMNode
Get the node immediately preceding this node in its parent's child list.- Specified by:
getPreviousSibling
in interfaceDOMNode
- Specified by:
getPreviousSibling
in interfaceNode
- Returns:
- the node immediately preceding this node in the child list, or
null
if none.
-
getNextSibling
Description copied from interface:DOMNode
Get the node immediately following this node in its parent's child list.- Specified by:
getNextSibling
in interfaceDOMNode
- Specified by:
getNextSibling
in interfaceNode
- Returns:
- the node immediately following this node in the child list, or
null
if none.
-
appendChild
Description copied from interface:DOMNode
Adds the nodenewChild
to the end of the list of children of this node. If thenewChild
is already in the tree, it is first removed.- Specified by:
appendChild
in interfaceDOMNode
- Specified by:
appendChild
in interfaceNode
- Parameters:
newChild
- the node to append. If it is aDocumentFragment
object, the entire contents of the document fragment are moved into the child list of this node.- Returns:
- the appended node.
- Throws:
DOMException
- HIERARCHY_REQUEST_ERR: raised if this node is of a type that does not allow children of the type of thenewChild
node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocument
and the DOM application attempts to append a secondDocumentType
orElement
node.
WRONG_DOCUMENT_ERR: ifnewChild
was created from a different document than the one that created this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChild
at this node.
-
removeChild
Description copied from interface:DOMNode
Removes the nodeoldChild
from the children of this node.- Specified by:
removeChild
in interfaceDOMNode
- Specified by:
removeChild
in interfaceNode
- Parameters:
oldChild
- the node to remove.- Returns:
- the removed node.
- Throws:
DOMException
- NOT_FOUND_ERR: ifoldChild
is not a child of this node.
-
removeAllChild
public void removeAllChild()Description copied from interface:DOMNode
Removes all the children from this node, if any.- Specified by:
removeAllChild
in interfaceDOMNode
-
setUserData
- Specified by:
setUserData
in interfaceNode
-
getUserData
- Specified by:
getUserData
in interfaceNode
-
normalize
public void normalize() -
getFeature
Deprecated.This method is deprecated and not supported.- Specified by:
getFeature
in interfaceNode
- Parameters:
feature
- ignored.version
- ignored.- Returns:
null
.
-
isSupported
Deprecated.This method is not supported.- Specified by:
isSupported
in interfaceNode
- Parameters:
feature
- ignored.version
- ignored.- Returns:
- Always
true
.
-
compareDocumentPosition
- Specified by:
compareDocumentPosition
in interfaceNode
- Throws:
DOMException
-
getTextContent
- Specified by:
getTextContent
in interfaceNode
- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContent
in interfaceNode
- Throws:
DOMException
-
getNamespaceURI
- Specified by:
getNamespaceURI
in interfaceNode
-
getPrefix
-
setPrefix
- Specified by:
setPrefix
in interfaceNode
- Throws:
DOMException
-
isEqualNode
- Specified by:
isEqualNode
in interfaceNode
-
isSameNode
- Specified by:
isSameNode
in interfaceNode
-
contains
Test ifnode
is an inclusive descendant of this node.- Parameters:
node
- the node to test.- Returns:
true
ifnode
is an inclusive descendant of this node,false
otherwise (includingnode
beingnull
).
-