- All Implemented Interfaces:
DOMNode,NonDocumentTypeChildNode,ParentNode,CSSDocument,CSSNode,Serializable,Document,Node,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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappendChild(Node newChild) Adds the nodenewChildto the end of the list of children of this node.cloneNode(boolean deep) shortcompareDocumentPosition(Node other) booleanTest ifnodeis 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 anullnamespace 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 aNodeIteratorobject with the given root node,whatToShowbitmask, andfiltercallback.createProcessingInstruction(String target, String data) createTextNode(String data) createTreeWalker(Node rootNode, int whatToShow, NodeFilter filter) Create aTreeWalkerobject with the given root node,whatToShowbitmask, andfiltercallback.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.voidEnables 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.intGets 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 anElementListof all the elements descending from this context node that have the given tag name, in document order.getElementsByTagNameNS(String namespaceURI, String localName) Gives anElementListof 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 CSSDOMImplementationGet 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.shortGet theDOMDocumentobject 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.booleanGets 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 CSSDOMImplementationA 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.getUserData(String key) Deprecated.booleanDeprecated.Deprecated.booleanbooleanDoes this node have any child nodes ?booleanHas any of the linked or embedded style sheets any error or warning ?importNode(Node importedNode, boolean deep) insertBefore(Node newChild, Node refChild) Inserts the nodenewChildright before noderefChildin the child node list.booleanisAuthorizedOrigin(URL url) Determine whether the retrieval of the given URL is authorized.booleanisDefaultNamespace(String namespaceURI) booleanisEqualNode(Node arg) booleanisSafeOrigin(URL linkedURL) Is the provided URL a safe origin to load certain external resources?booleanisSameNode(Node other) booleanisSupported(String feature, String version) Deprecated.booleanisVisitedURI(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) voidvoidNormalizes the document element, if there is one.voidonMetaAdded(String name, String attribute) Notify the document about the addition of aMETAelement that may affect the inner workings of this document.voidonMetaRemoved(String name, String attribute) Notify the document about the removal of aMETAelement 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) querySelector(String selectors) Returns the first element that is a descendant of this node and matches the given selector list.querySelectorAll(String selectors) Gets a static list of the elements that match any of the specified group of selectors.voidForces the cascade to be rebuilt the next time that a computed style is obtained.voidregisterProperty(CSSPropertyDefinition definition) Registers the definition of a custom property.voidRemoves all the children from this node, if any.removeChild(Node oldChild) Removes the nodeoldChildfrom the children of this node.renameNode(Node n, String namespaceURI, String qualifiedName) Deprecated.replaceChild(Node newChild, Node oldChild) Replaces the nodeoldChildwithnewChild.voidsetDocumentURI(String documentURI) Sets the location of this document.voidsetNodeValue(String nodeValue) voidprotected voidsetReferrerPolicyHeader(String policy) voidSelects a style sheet set, disabling the other non-persistent sheet sets.voidsetStrictErrorChecking(boolean strictErrorChecking) voidsetTargetMedium(String medium) Set the medium that will be used to compute the styles of this document.voidsetTextContent(String textContent) setUserData(String key, Object data, UserDataHandler handler) voidsetXmlStandalone(boolean xmlStandalone) Deprecated.voidsetXmlVersion(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, waitMethods inherited from interface io.sf.carte.doc.style.css.CSSDocument
getURL, openConnectionMethods inherited from interface org.w3c.dom.Document
getElementsByTagName, getElementsByTagNameNSMethods inherited from interface io.sf.carte.doc.dom.DOMNode
appendChild, getFirstChild, getLastChild, getNextSibling, getPreviousSibling, hasChildNodes, removeAllChild, removeChildMethods 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, setUserDataMethods 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:
getCompatModein 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:
STRICTandQUIRKS.QUIRKSandSTRICTdiffer in the matching of class and ID selectors, and the default user agent sheet is slightly different.- Specified by:
getComplianceModein interfaceCSSDocument- Returns:
- the compliance mode.
-
getDocumentElement
Get the child node which is the document element of this document.- Specified by:
getDocumentElementin interfaceCSSDocument- Specified by:
getDocumentElementin interfaceDocument- Returns:
- the document element.
-
getDoctype
- Specified by:
getDoctypein interfaceDocument
-
getNodeName
- Specified by:
getNodeNamein interfaceNode
-
getOwnerDocument
Get theDOMDocumentobject 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:
getOwnerDocumentin interfaceCSSNode- Specified by:
getOwnerDocumentin interfaceDOMNode- Specified by:
getOwnerDocumentin interfaceNode- Returns:
- the
DOMDocumentobject corresponding to this node. When this node is aDOMDocumentor aDocumentTypewhich was not added to anyDOMDocumentyet, this isnull.
-
getParentNode
- Specified by:
getParentNodein interfaceDOMNode- Specified by:
getParentNodein interfaceNode
-
isVisitedURI
Has this URI been visited by the agent ?- Specified by:
isVisitedURIin interfaceCSSDocument- Parameters:
href- the URI.- Returns:
trueif visited,falseif not visited or the agent does not support history.
-
cloneNode
-
getImplementation
Get the DOM implementation that created this document.- Specified by:
getImplementationin interfaceDocument- Returns:
- the DOM implementation that created this document.
-
getStyleSheetFactory
-
createElement
Creates an element of the type specified, with anullnamespace URI.The
tagNameis transformed to lower case.No default attributes are created.
- Specified by:
createElementin interfaceCSSDocument- Specified by:
createElementin 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
namespaceURIisnullor the empty string, thequalifiedNameis transformed to lower case.No default attributes are created.
- Specified by:
createElementNSin interfaceCSSDocument- Specified by:
createElementNSin 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 thequalifiedNameis a malformed qualified name, if thequalifiedNamehas a prefix and thenamespaceURIisnull, or if thequalifiedNamehas a prefix that is"xml"and thenamespaceURIis different from"http://www.w3.org/XML/1998/namespace", or if thequalifiedNameor its prefix is"xmlns"and thenamespaceURIis different from"http://www.w3.org/2000/xmlns/", or if thenamespaceURIis"http://www.w3.org/2000/xmlns/"and neither thequalifiedNamenor its prefix is"xmlns".
-
createDocumentFragment
- Specified by:
createDocumentFragmentin interfaceDocument
-
createTextNode
- Specified by:
createTextNodein interfaceDocument
-
createComment
- Specified by:
createCommentin interfaceDocument
-
createCDATASection
- Specified by:
createCDATASectionin interfaceDocument- Throws:
DOMException
-
createProcessingInstruction
public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException - Specified by:
createProcessingInstructionin interfaceDocument- Throws:
DOMException
-
createEntityReference
- Specified by:
createEntityReferencein interfaceDocument- Throws:
DOMException
-
createAttribute
- Specified by:
createAttributein interfaceDocument- Throws:
DOMException
-
createAttributeNS
- Specified by:
createAttributeNSin interfaceDocument- Throws:
DOMException
-
createNodeIterator
Create aNodeIteratorobject with the given root node,whatToShowbitmask, andfiltercallback.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'sNodeIteratorinterface description for more details). If you need compatibility with the W3C-specified behaviour, never use aNodeFilterthat 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 aTreeWalkerobject with the given root node,whatToShowbitmask, andfiltercallback.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
NodeFilteruses names different to W3C's for the filter values:NodeFilter.FILTER_SKIP_NODE_CHILDinstead of W3C'sNodeFilter.FILTER_REJECT), andNodeFilter.FILTER_SKIP_NODEinstead 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:
getElementsByClassNamein 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:
lookupPrefixin 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 inQUIRKSmode.- Specified by:
getElementByIdin interfaceCSSDocument- Specified by:
getElementByIdin interfaceDocument- Parameters:
elementId- The unique id value for an element.- Returns:
- The matching element or
nullif there is none.
-
getInputEncoding
Give the encoding used when the document was parsed, if known.- Specified by:
getInputEncodingin interfaceDocument- Returns:
null.
-
getXmlEncoding
Deprecated.Now deprecated, this method gave the encoding specified at the XML declaration.- Specified by:
getXmlEncodingin interfaceDocument- Returns:
null.
-
getXmlStandalone
Deprecated.Get whether this document is standalone as specified at the XML declaration.- Specified by:
getXmlStandalonein 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:
setXmlStandalonein interfaceDocument- Parameters:
xmlStandalone- argument is ignored.- Throws:
DOMException
-
getXmlVersion
Deprecated.Get the version for the "XML" feature.- Specified by:
getXmlVersionin interfaceDocument- Returns:
null.
-
setXmlVersion
Deprecated.Set the version for the "XML" feature.- Specified by:
setXmlVersionin interfaceDocument- Parameters:
xmlVersion- this parameter is ignored.- Throws:
DOMException
-
getStrictErrorChecking
public boolean getStrictErrorChecking()- Specified by:
getStrictErrorCheckingin interfaceDocument
-
setStrictErrorChecking
public void setStrictErrorChecking(boolean strictErrorChecking) - Specified by:
setStrictErrorCheckingin interfaceDocument
-
getDocumentURI
Gets the location of this document.- Specified by:
getDocumentURIin interfaceDocument- Returns:
- the location of this document, or
nullif 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 thedocumentURIto a local scheme (file:orjar:) as well.No lexical checking is performed when setting this attribute; this could result in a
nullvalue returned when usinggetBaseURI().- Specified by:
setDocumentURIin interfaceDocument- Parameters:
documentURI- the document URI.
-
importNode
- Specified by:
importNodein interfaceDocument- Throws:
DOMException
-
adoptNode
- Specified by:
adoptNodein interfaceDocument- Throws:
DOMException
-
insertBefore
Inserts the nodenewChildright before noderefChildin the child node list.- If
refChildisnull,newChildis appended at the end of the child list. - If the
newChildis already in the tree, it is first removed. - Inserting a node before itself has no effect.
- Specified by:
insertBeforein interfaceDOMNode- Specified by:
insertBeforein interfaceNode- Parameters:
newChild- the node to put at the child node list, beforerefChild. If it is aDocumentFragmentobject, the entire contents of the document fragment are inserted into the child list of this node.refChild- the node before whichnewChildmust 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 thenewChildnode, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to append a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: ifnewChildwas created from a different document than the one that created this node.
NOT_FOUND_ERR: ifrefChildis not a child of this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChildat this node.
- If
-
replaceChild
Replaces the nodeoldChildwithnewChild. If thenewChildis already in the tree, it is first removed.Replacing a node with itself has no effect.
- Specified by:
replaceChildin interfaceDOMNode- Specified by:
replaceChildin interfaceNode- Parameters:
newChild- the node to put at the child node list, in place ofoldChild. If it is aDocumentFragmentobject, 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 thenewChildnode, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to append a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: ifnewChildwas created from a different document than the one that created this node.
NOT_FOUND_ERR: ifoldChildis not a child of this node.
NOT_SUPPORTED_ERR: if this implementation does not support children of the type ofnewChildat this node.
-
renameNode
@Deprecated public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException Deprecated.- Specified by:
renameNodein interfaceDocument- Throws:
DOMException
-
getDomConfig
Only the
normalize-charactersandcommentsparameters are configurable and can be toggled. Other parameters can only be set to defaults (or cannot be set at all, likesplit-cdata-sectionsbecause the implementation does not allow split CDATA), andwell-formedis just ignored (malformed characters are not allowed in this implementation).Also supports the proprietary:
css-whitespace-processing- Defaults to
trueand 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-spaceCSS property when handlingcss-whitespace-processing.
- Specified by:
getDomConfigin interfaceDocument
-
normalizeDocument
public void normalizeDocument()Normalizes the document element, if there is one.- Specified by:
normalizeDocumentin interfaceDocument
-
lookupNamespaceURI
- Specified by:
lookupNamespaceURIin interfaceNode
-
isDefaultNamespace
- Specified by:
isDefaultNamespacein interfaceNode
-
registerProperty
Description copied from interface:CSSDocumentRegisters the definition of a custom property.- Specified by:
registerPropertyin 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:
getStyleSheetsin interfaceCSSDocument- Specified by:
getStyleSheetsin interfaceDocumentStyle
-
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:
getStyleSheetin interfaceCSSDocument- Returns:
- the merged style sheet that applies to this document.
-
getStyleSheetSets
Gets the list of available alternate styles.- Specified by:
getStyleSheetSetsin interfaceCSSDocument- Returns:
- the list of available alternate style titles.
-
getSelectedStyleSheetSet
Gets the title of the currently selected style sheet set.- Specified by:
getSelectedStyleSheetSetin interfaceCSSDocument- Returns:
- the title of the currently selected style sheet, the empty string if none is
selected, or
nullif 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:
setSelectedStyleSheetSetin interfaceCSSDocument- Parameters:
name- the case-sensitive name of the set to select.
-
getLastStyleSheetSet
Gets the style sheet set that was last selected.- Specified by:
getLastStyleSheetSetin interfaceCSSDocument- Returns:
- the last selected style sheet set, or
nullif none.
-
enableStyleSheetsForSet
Enables a style sheet set. If the name does not match any of the sets, does nothing.- Specified by:
enableStyleSheetsForSetin 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:
getStyleDatabasein interfaceCSSDocument- Returns:
- the style database, or null if no style database has been selected.
-
getTargetMedium
This document's current target medium name.- Specified by:
getTargetMediumin 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:
setTargetMediumin 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:
getCanvasin 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:CSSDocumentForces 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:
rebuildCascadein interfaceCSSDocument
-
getErrorHandler
Description copied from interface:CSSDocumentGets the document-level error handler.- Specified by:
getErrorHandlerin interfaceCSSDocument- Returns:
- the error handler.
-
hasStyleIssues
public boolean hasStyleIssues()Has any of the linked or embedded style sheets any error or warning ?- Specified by:
hasStyleIssuesin interfaceCSSDocument- Returns:
trueif any of the linked or embedded style sheets has any SAC or rule error or warning,falseotherwise.
-
onMetaAdded
Notify the document about the addition of aMETAelement that may affect the inner workings of this document.This method avoids having to rescan
METAelements for each style-related operation.- Parameters:
name- theMETAname.attribute- the attribute.
-
onMetaRemoved
Notify the document about the removal of aMETAelement that may affect the inner workings of this document.This method avoids having to rescan
METAelements for each style-related operation.- Parameters:
name- theMETAname.attribute- the attribute.
-
getBaseURL
Gets the base URL of this Document.If the Document's
headelement has abasechild element, the base URI is computed using the value of the href attribute of thebaseelement.- Specified by:
getBaseURLin 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:
getBaseURIin interfaceNode- Returns:
- the absolute base URI of this node, or null if an absolute URI could not be obtained.
-
isSafeOrigin
Is the provided URL a safe origin to load certain external resources?- Specified by:
isSafeOriginin interfaceCSSDocument- Parameters:
linkedURL- the URL of the external resource.- Returns:
trueif is a safe origin,falseotherwise.
-
isAuthorizedOrigin
Determine whether the retrieval of the given URL is authorized.If the URL's protocol is not
httpnorhttpsand document's base URL's scheme is neitherfilenorjar, it is denied.Developers may want to override this implementation to enforce different restrictions.
- Specified by:
isAuthorizedOriginin interfaceCSSDocument- Parameters:
url- the URL to check.- Returns:
trueif allowed.
-
getReferrerPolicy
Get the referrer policy obtained through the 'Referrer-Policy' header or a meta element.- Specified by:
getReferrerPolicyin 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 stream could not be opened.
-
getChildren
Gets the live ElementList containing all nodes of type Element that are children of this Element.- Specified by:
getChildrenin interfaceParentNode- Returns:
- the ElementList containing all nodes of type Element that are children of this Element.
-
querySelector
Returns the first element that is a descendant of this node and matches the given selector list.- Parameters:
selectors- a comma-separated list of selectors.- Returns:
- the first element matching the selectors.
-
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:
querySelectorAllin 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:
iteratorin 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:
descendingIteratorin 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:
iteratorin interfaceParentNode- Parameters:
whatToShow- a bit set.- Returns:
- an iterator over the child nodes.
-
elementIterator
Creates a new iterator over the child elements.- Specified by:
elementIteratorin interfaceParentNode- Returns:
- an iterator over the child elements.
-
elementIterator
Creates a new iterator over the child elements of the given tagname.- Specified by:
elementIteratorin 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:
elementIteratorNSin 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:
iteratorin interfaceParentNode- Parameters:
whatToShow- the bit field mask to apply to the node types, seeNodeFilter. Do not confuse this argument with theshortargument of theParentNode.typeIterator(short)method.filter- the filter to use in the iteration. ifnull, only thewhatToShowmask filter is applied.- Returns:
- an iterator over the child nodes.
-
typeIterator
Creates a new iterator over the child nodes.Do not confuse the
typeToShowargument with theintargument of theParentNode.iterator(int, NodeFilter)method, which is a bit field.- Specified by:
typeIteratorin 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:
iteratorin 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:
listIteratorin interfaceParentNode- Returns:
- a list iterator over the child nodes.
-
getElementsByTagNameNS
Gives anElementListof 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:
getElementsByTagNameNSin 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
ElementListobject containing all the matched elements.
-
getElementsByTagName
Gives anElementListof 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:
getElementsByTagNamein interfaceParentNode- Parameters:
name- The tag name of the elements to match on. The special value "*" matches all tag names.- Returns:
- the
ElementListobject 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:DOMNodeDoes this node have any child nodes ?- Specified by:
hasChildNodesin interfaceDOMNode- Specified by:
hasChildNodesin interfaceNode- Returns:
trueif this node has child nodes,falseotherwise.
-
getPreviousElementSibling
Description copied from interface:NonDocumentTypeChildNodeGets the first preceding sibling that is an element.- Specified by:
getPreviousElementSiblingin interfaceNonDocumentTypeChildNode- Returns:
- the first preceding sibling that is an element, and
nullotherwise.
-
getNextElementSibling
Description copied from interface:NonDocumentTypeChildNodeGets the first following sibling that is an element.- Specified by:
getNextElementSiblingin interfaceNonDocumentTypeChildNode- Returns:
- the first following sibling that is an element, and
nullotherwise.
-
prependChild
- Throws:
DOMException
-
getNodeValue
- Specified by:
getNodeValuein interfaceNode- Throws:
DOMException
-
setNodeValue
- Specified by:
setNodeValuein interfaceNode- Throws:
DOMException
-
getNodeType
public short getNodeType()- Specified by:
getNodeTypein interfaceNode
-
getLocalName
Gives the local part of the qualified name of this node. For nodes of any type other thanELEMENT_NODEandATTRIBUTE_NODE, this is always null.- Specified by:
getLocalNamein interfaceNode- Returns:
- the local part of the qualified name of this node, or null if this
node is not an
ELEMENT_NODEnor anATTRIBUTE_NODE.
-
getAttributes
- Specified by:
getAttributesin interfaceNode
-
hasAttributes
public boolean hasAttributes()- Specified by:
hasAttributesin interfaceNode
-
getChildNodes
Description copied from interface:DOMNodeGet the children of this node.- Specified by:
getChildNodesin interfaceDOMNode- Specified by:
getChildNodesin interfaceNode- Returns:
- a
DOMNodeListwith the children of this node. If there are no children, an empty list is returned.
-
getFirstChild
Description copied from interface:DOMNodeGet the first child of this node.- Specified by:
getFirstChildin interfaceDOMNode- Specified by:
getFirstChildin interfaceNode- Returns:
- the first child of this node,
nullif has no child nodes.
-
getLastChild
Description copied from interface:DOMNodeGet the last child of this node.- Specified by:
getLastChildin interfaceDOMNode- Specified by:
getLastChildin interfaceNode- Returns:
- the last child of this node,
nullif has no child nodes.
-
getPreviousSibling
Description copied from interface:DOMNodeGet the node immediately preceding this node in its parent's child list.- Specified by:
getPreviousSiblingin interfaceDOMNode- Specified by:
getPreviousSiblingin interfaceNode- Returns:
- the node immediately preceding this node in the child list, or
nullif none.
-
getNextSibling
Description copied from interface:DOMNodeGet the node immediately following this node in its parent's child list.- Specified by:
getNextSiblingin interfaceDOMNode- Specified by:
getNextSiblingin interfaceNode- Returns:
- the node immediately following this node in the child list, or
nullif none.
-
appendChild
Description copied from interface:DOMNodeAdds the nodenewChildto the end of the list of children of this node. If thenewChildis already in the tree, it is first removed.- Specified by:
appendChildin interfaceDOMNode- Specified by:
appendChildin interfaceNode- Parameters:
newChild- the node to append. If it is aDocumentFragmentobject, 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 thenewChildnode, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to append a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: ifnewChildwas 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 ofnewChildat this node.
-
removeChild
Description copied from interface:DOMNodeRemoves the nodeoldChildfrom the children of this node.- Specified by:
removeChildin interfaceDOMNode- Specified by:
removeChildin interfaceNode- Parameters:
oldChild- the node to remove.- Returns:
- the removed node.
- Throws:
DOMException- NOT_FOUND_ERR: ifoldChildis not a child of this node.
-
removeAllChild
public void removeAllChild()Description copied from interface:DOMNodeRemoves all the children from this node, if any.- Specified by:
removeAllChildin interfaceDOMNode
-
setUserData
- Specified by:
setUserDatain interfaceNode
-
getUserData
- Specified by:
getUserDatain interfaceNode
-
normalize
public void normalize() -
getFeature
Deprecated.This method is deprecated and not supported.- Specified by:
getFeaturein interfaceNode- Parameters:
feature- ignored.version- ignored.- Returns:
null.
-
isSupported
Deprecated.This method is not supported.- Specified by:
isSupportedin interfaceNode- Parameters:
feature- ignored.version- ignored.- Returns:
- Always
true.
-
compareDocumentPosition
- Specified by:
compareDocumentPositionin interfaceNode- Throws:
DOMException
-
getTextContent
- Specified by:
getTextContentin interfaceNode- Throws:
DOMException
-
setTextContent
- Specified by:
setTextContentin interfaceNode- Throws:
DOMException
-
getNamespaceURI
- Specified by:
getNamespaceURIin interfaceNode
-
getPrefix
-
setPrefix
- Specified by:
setPrefixin interfaceNode- Throws:
DOMException
-
isEqualNode
- Specified by:
isEqualNodein interfaceNode
-
isSameNode
- Specified by:
isSameNodein interfaceNode
-
contains
Test ifnodeis an inclusive descendant of this node.- Parameters:
node- the node to test.- Returns:
trueifnodeis an inclusive descendant of this node,falseotherwise (includingnodebeingnull).
-