Class HTMLDocumentImpl

All Implemented Interfaces:
ModelNode, ScriptableDelegate, Document, HTMLDocument, Node, DocumentView

public class HTMLDocumentImpl extends NodeImpl implements HTMLDocument, DocumentView
Implementation of the W3C HTMLDocument interface.
  • Constructor Details

  • Method Details

    • getLocales

      public Set getLocales()
      Gets an immutable set of locales previously set for this document.
    • setLocales

      public void setLocales(Set locales)
      Sets the locales of the document. This helps determine whether specific fonts can display text in the languages of all the locales.
      Parameters:
      locales - An immutable set of java.util.Locale instances.
    • getDocumentURL

      public URL getDocumentURL()
      Overrides:
      getDocumentURL in class NodeImpl
    • getBaseURI

      public String getBaseURI()
      Specified by:
      getBaseURI in interface Node
      Overrides:
      getBaseURI in class NodeImpl
    • setBaseURI

      public void setBaseURI(String value)
    • getDefaultTarget

      public String getDefaultTarget()
    • setDefaultTarget

      public void setDefaultTarget(String value)
    • getDefaultView

      public AbstractView getDefaultView()
      Description copied from interface: DocumentView
      The default AbstractView for this Document, or null if none available.
      Specified by:
      getDefaultView in interface DocumentView
    • getTextContent

      public String getTextContent() throws DOMException
      Description copied from class: NodeImpl
      Gets the text content of this node and its descendents.
      Specified by:
      getTextContent in interface Node
      Overrides:
      getTextContent in class NodeImpl
      Throws:
      DOMException
    • setTextContent

      public void setTextContent(String textContent) throws DOMException
      Specified by:
      setTextContent in interface Node
      Overrides:
      setTextContent in class NodeImpl
      Throws:
      DOMException
    • getTitle

      public String getTitle()
      Description copied from interface: HTMLDocument
      The title of a document as specified by the TITLE element in the head of the document.
      Specified by:
      getTitle in interface HTMLDocument
    • setTitle

      public void setTitle(String title)
      Description copied from interface: HTMLDocument
      The title of a document as specified by the TITLE element in the head of the document.
      Specified by:
      setTitle in interface HTMLDocument
    • getReferrer

      public String getReferrer()
      Description copied from interface: HTMLDocument
      Returns the URI [IETF RFC 2396] of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).
      Specified by:
      getReferrer in interface HTMLDocument
    • setReferrer

      public void setReferrer(String value)
    • getDomain

      public String getDomain()
      Description copied from interface: HTMLDocument
      The domain name of the server that served the document, or null if the server cannot be identified by a domain name.
      Specified by:
      getDomain in interface HTMLDocument
    • setDomain

      public void setDomain(String domain)
    • getBody

      public HTMLElement getBody()
      Description copied from interface: HTMLDocument
      The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.
      Specified by:
      getBody in interface HTMLDocument
    • getImages

      public HTMLCollection getImages()
      Description copied from interface: HTMLDocument
      A collection of all the IMG elements in a document. The behavior is limited to IMG elements for backwards compatibility. As suggested by [HTML 4.01], to include images, authors may use the OBJECT element or the IMG element. Therefore, it is recommended not to use this attribute to find the images in the document but getElementsByTagName with HTML 4.01 or getElementsByTagNameNS with XHTML 1.0.
      Specified by:
      getImages in interface HTMLDocument
    • getApplets

      public HTMLCollection getApplets()
      Description copied from interface: HTMLDocument
      A collection of all the OBJECT elements that include applets and APPLET (deprecated) elements in a document.
      Specified by:
      getApplets in interface HTMLDocument
    • getLinks

      public HTMLCollection getLinks()
      Description copied from interface: HTMLDocument
      A collection of all AREA elements and anchor ( A) elements in a document with a value for the href attribute.
      Specified by:
      getLinks in interface HTMLDocument
    • getForms

      public HTMLCollection getForms()
      Description copied from interface: HTMLDocument
      A collection of all the forms of a document.
      Specified by:
      getForms in interface HTMLDocument
    • getFrames

      public HTMLCollection getFrames()
    • getAnchors

      public HTMLCollection getAnchors()
      Description copied from interface: HTMLDocument
      A collection of all the anchor (A) elements in a document with a value for the name attribute. For reasons of backward compatibility, the returned set of anchors only contains those anchors created with the name attribute, not those created with the id attribute. Note that in [XHTML 1.0], the name attribute (see section 4.10) has no semantics and is only present for legacy user agents: the id attribute is used instead. Users should prefer the iterator mechanisms provided by [DOM Level 2 Traversal] instead.
      Specified by:
      getAnchors in interface HTMLDocument
    • getCookie

      public String getCookie()
      Description copied from interface: HTMLDocument
      This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by the cookies non-terminal of [IETF RFC 2965], Section 4.2.2.
      If no persistent state information is available for the current frame or document document, then this property's value is an empty string.
      When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon).
      When this attribute is set, the value it is set to should be a string that adheres to the cookie non-terminal of [IETF RFC 2965]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [IETF RFC 2396] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [IETF RFC 2396] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [IETF RFC 2965] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.
      Specified by:
      getCookie in interface HTMLDocument
    • setCookie

      public void setCookie(String cookie) throws DOMException
      Description copied from interface: HTMLDocument
      This mutable string attribute denotes persistent state information that (1) is associated with the current frame or document and (2) is composed of information described by the cookies non-terminal of [IETF RFC 2965], Section 4.2.2.
      If no persistent state information is available for the current frame or document document, then this property's value is an empty string.
      When this attribute is read, all cookies are returned as a single string, with each cookie's name-value pair concatenated into a list of name-value pairs, each list item being separated by a ';' (semicolon).
      When this attribute is set, the value it is set to should be a string that adheres to the cookie non-terminal of [IETF RFC 2965]; that is, it should be a single name-value pair followed by zero or more cookie attribute values. If no domain attribute is specified, then the domain attribute for the new value defaults to the host portion of an absolute URI [IETF RFC 2396] of the current frame or document. If no path attribute is specified, then the path attribute for the new value defaults to the absolute path portion of the URI [IETF RFC 2396] of the current frame or document. If no max-age attribute is specified, then the max-age attribute for the new value defaults to a user agent defined value. If a cookie with the specified name is already associated with the current frame or document, then the new value as well as the new attributes replace the old value and attributes. If a max-age attribute of 0 is specified for the new value, then any existing cookies of the specified name are removed from the cookie storage. See [IETF RFC 2965] for the semantics of persistent state item attribute value pairs. The precise nature of a user agent session is not defined by this specification.
      Specified by:
      setCookie in interface HTMLDocument
      Throws:
      DOMException - SYNTAX_ERR: If the new value does not adhere to the cookie syntax specified by [IETF RFC 2965].
    • open

      public void open()
      Description copied from interface: HTMLDocument
      Open a document stream for writing. If a document exists in the target, this method clears it. This method and the ones following allow a user to add to or replace the structure model of a document using strings of unparsed HTML. At the time of writing alternate methods for providing similar functionality for both HTML and XML documents were being considered (see [DOM Level 3 Load and Save]).
      Specified by:
      open in interface HTMLDocument
    • load

      Loads the document from the reader provided when the current instance of HTMLDocumentImpl was constructed. It then closes the reader.
      Throws:
      IOException
      SAXException
      UnsupportedEncodingException
    • load

      public void load(boolean closeReader) throws IOException, SAXException, UnsupportedEncodingException
      Throws:
      IOException
      SAXException
      UnsupportedEncodingException
    • close

      public void close()
      Description copied from interface: HTMLDocument
      Closes a document stream opened by open() and forces rendering.
      Specified by:
      close in interface HTMLDocument
    • write

      public void write(String text)
      Description copied from interface: HTMLDocument
      Write a string of text to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document.
      Specified by:
      write in interface HTMLDocument
      Parameters:
      text - The string to be parsed into some structure in the document structure model.
    • writeln

      public void writeln(String text)
      Description copied from interface: HTMLDocument
      Write a string of text followed by a newline character to a document stream opened by open(). Note that the function will produce a document which is not necessarily driven by a DTD and therefore might be produce an invalid result in the context of the document
      Specified by:
      writeln in interface HTMLDocument
      Parameters:
      text - The string to be parsed into some structure in the document structure model.
    • getElementsByName

      public NodeList getElementsByName(String elementName)
      Gets the collection of elements whose name attribute is elementName.
      Specified by:
      getElementsByName in interface HTMLDocument
      Parameters:
      elementName - The name attribute value for an element.
      Returns:
      The matching elements.
    • getDoctype

      public DocumentType getDoctype()
      Specified by:
      getDoctype in interface Document
    • setDoctype

      public void setDoctype(DocumentType doctype)
    • getDocumentElement

      public Element getDocumentElement()
      Specified by:
      getDocumentElement in interface Document
    • createElement

      public Element createElement(String tagName) throws DOMException
      Specified by:
      createElement in interface Document
      Throws:
      DOMException
    • createDocumentFragment

      public DocumentFragment createDocumentFragment()
      Specified by:
      createDocumentFragment in interface Document
    • createTextNode

      public Text createTextNode(String data)
      Specified by:
      createTextNode in interface Document
    • createComment

      public Comment createComment(String data)
      Specified by:
      createComment in interface Document
    • createCDATASection

      public CDATASection createCDATASection(String data) throws DOMException
      Specified by:
      createCDATASection in interface Document
      Throws:
      DOMException
    • createProcessingInstruction

      public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException
      Specified by:
      createProcessingInstruction in interface Document
      Throws:
      DOMException
    • createAttribute

      public Attr createAttribute(String name) throws DOMException
      Specified by:
      createAttribute in interface Document
      Throws:
      DOMException
    • createEntityReference

      public EntityReference createEntityReference(String name) throws DOMException
      Specified by:
      createEntityReference in interface Document
      Throws:
      DOMException
    • getElementsByTagName

      public NodeList getElementsByTagName(String tagname)
      Gets all elements that match the given tag name.
      Specified by:
      getElementsByTagName in interface Document
      Parameters:
      tagname - The element tag name or an asterisk character (*) to match all elements.
    • importNode

      public Node importNode(Node importedNode, boolean deep) throws DOMException
      Specified by:
      importNode in interface Document
      Throws:
      DOMException
    • createElementNS

      public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException
      Specified by:
      createElementNS in interface Document
      Throws:
      DOMException
    • createAttributeNS

      public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException
      Specified by:
      createAttributeNS in interface Document
      Throws:
      DOMException
    • getElementsByTagNameNS

      public NodeList getElementsByTagNameNS(String namespaceURI, String localName)
      Specified by:
      getElementsByTagNameNS in interface Document
    • getElementById

      public Element getElementById(String elementId)
      Specified by:
      getElementById in interface Document
    • namedItem

      public Element namedItem(String name)
    • getInputEncoding

      public String getInputEncoding()
      Specified by:
      getInputEncoding in interface Document
    • getXmlEncoding

      public String getXmlEncoding()
      Specified by:
      getXmlEncoding in interface Document
    • getXmlStandalone

      public boolean getXmlStandalone()
      Specified by:
      getXmlStandalone in interface Document
    • setXmlStandalone

      public void setXmlStandalone(boolean xmlStandalone) throws DOMException
      Specified by:
      setXmlStandalone in interface Document
      Throws:
      DOMException
    • getXmlVersion

      public String getXmlVersion()
      Specified by:
      getXmlVersion in interface Document
    • setXmlVersion

      public void setXmlVersion(String xmlVersion) throws DOMException
      Specified by:
      setXmlVersion in interface Document
      Throws:
      DOMException
    • getStrictErrorChecking

      public boolean getStrictErrorChecking()
      Specified by:
      getStrictErrorChecking in interface Document
    • setStrictErrorChecking

      public void setStrictErrorChecking(boolean strictErrorChecking)
      Specified by:
      setStrictErrorChecking in interface Document
    • getDocumentURI

      public String getDocumentURI()
      Specified by:
      getDocumentURI in interface Document
    • setDocumentURI

      public void setDocumentURI(String documentURI)
      Specified by:
      setDocumentURI in interface Document
    • adoptNode

      public Node adoptNode(Node source) throws DOMException
      Specified by:
      adoptNode in interface Document
      Throws:
      DOMException
    • getDomConfig

      public DOMConfiguration getDomConfig()
      Specified by:
      getDomConfig in interface Document
    • normalizeDocument

      public void normalizeDocument()
      Specified by:
      normalizeDocument in interface Document
    • renameNode

      public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException
      Specified by:
      renameNode in interface Document
      Throws:
      DOMException
    • getImplementation

      public DOMImplementation getImplementation()
      Specified by:
      getImplementation in interface Document
    • getLocalName

      public String getLocalName()
      Specified by:
      getLocalName in interface Node
      Specified by:
      getLocalName in class NodeImpl
    • getNodeName

      public String getNodeName()
      Specified by:
      getNodeName in interface Node
      Specified by:
      getNodeName in class NodeImpl
    • getNodeType

      public short getNodeType()
      Specified by:
      getNodeType in interface Node
      Specified by:
      getNodeType in class NodeImpl
    • getNodeValue

      public String getNodeValue() throws DOMException
      Specified by:
      getNodeValue in interface Node
      Specified by:
      getNodeValue in class NodeImpl
      Throws:
      DOMException
    • setNodeValue

      public void setNodeValue(String nodeValue) throws DOMException
      Specified by:
      setNodeValue in interface Node
      Specified by:
      setNodeValue in class NodeImpl
      Throws:
      DOMException
    • getHtmlRendererContext

      public final HtmlRendererContext getHtmlRendererContext()
      Overrides:
      getHtmlRendererContext in class NodeImpl
    • getUserAgentContext

      public UserAgentContext getUserAgentContext()
      Overrides:
      getUserAgentContext in class NodeImpl
    • getFullURL

      public final URL getFullURL(String uri)
      Specified by:
      getFullURL in interface ModelNode
      Overrides:
      getFullURL in class NodeImpl
    • getLocation

      public final Location getLocation()
    • setLocation

      public void setLocation(String location)
    • getURL

      public String getURL()
      Description copied from interface: HTMLDocument
      The absolute URI [IETF RFC 2396] of the document.
      Specified by:
      getURL in interface HTMLDocument
    • setBody

      public void setBody(HTMLElement body)
      Description copied from interface: HTMLDocument
      The element that contains the content for the document. In documents with BODY contents, returns the BODY element. In frameset documents, this returns the outermost FRAMESET element.
      Specified by:
      setBody in interface HTMLDocument
    • allInvalidated

      public void allInvalidated(boolean forgetRenderStates)
    • getStyleSheets

      public Collection getStyleSheets()
    • addDocumentNotificationListener

      public void addDocumentNotificationListener(DocumentNotificationListener listener)
      Adds a document notification listener, which is informed about changes to the document.
      Parameters:
      listener - An instance of DocumentNotificationListener.
    • removeDocumentNotificationListener

      public void removeDocumentNotificationListener(DocumentNotificationListener listener)
    • sizeInvalidated

      public void sizeInvalidated(NodeImpl node)
    • lookInvalidated

      public void lookInvalidated(NodeImpl node)
      Called if something such as a color or decoration has changed. This would be something which does not affect the rendered size, and can be revalidated with a simple repaint.
      Parameters:
      node -
    • positionInParentInvalidated

      public void positionInParentInvalidated(NodeImpl node)
      Changed if the position of the node in a parent has changed.
      Parameters:
      node -
    • invalidated

      public void invalidated(NodeImpl node)
      This is called when the node has changed, but it is unclear if it's a size change or a look change. An attribute change should trigger this.
      Parameters:
      node -
    • structureInvalidated

      public void structureInvalidated(NodeImpl node)
      This is called when children of the node might have changed.
      Parameters:
      node -
    • nodeLoaded

      public void nodeLoaded(NodeImpl node)
    • externalScriptLoading

      public void externalScriptLoading(NodeImpl node)
    • allInvalidated

      public void allInvalidated()
      Informs listeners that the whole document has been invalidated.
    • createRenderState

      protected RenderState createRenderState(RenderState prevRenderState)
      Overrides:
      createRenderState in class NodeImpl
    • loadImage

      protected void loadImage(String relativeUri, ImageListener imageListener)
      Loads images asynchronously such that they are shared if loaded simultaneously from the same URI. Informs the listener immediately if an image is already known.
      Parameters:
      relativeUri -
      imageListener -
    • getOnloadHandler

      public org.mozilla.javascript.Function getOnloadHandler()
    • setOnloadHandler

      public void setOnloadHandler(org.mozilla.javascript.Function onloadHandler)
    • setUserData

      public Object setUserData(String key, Object data, UserDataHandler handler)
      Specified by:
      setUserData in interface Node
      Overrides:
      setUserData in class NodeImpl
    • createSimilarNode

      protected Node createSimilarNode()
      Description copied from class: NodeImpl
      Should create a node with some cloned properties, like the node name, but not attributes or children.
      Specified by:
      createSimilarNode in class NodeImpl