com.google.gwt.dom.client
Class Document

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by com.google.gwt.dom.client.Node
          extended by com.google.gwt.dom.client.Document

public class Document
extends Node

A Document is the root of the HTML hierarchy and holds the entire content. Besides providing access to the hierarchy, it also provides some convenience methods for accessing certain sets of information from the document.


Field Summary
 
Fields inherited from class com.google.gwt.dom.client.Node
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE
 
Constructor Summary
protected Document()
           
 
Method Summary
 AnchorElement createAnchorElement()
          Creates an <a> element.
 AreaElement createAreaElement()
          Creates an <area> element.
 BaseElement createBaseElement()
          Creates a <base> element.
 QuoteElement createBlockQuoteElement()
          Creates a <blockquote> element.
 BRElement createBRElement()
          Creates a <br> element.
 ButtonElement createButtonElement()
          Creates a <button> element.
 TableCaptionElement createCaptionElement()
          Creates a <caption> element.
 InputElement createCheckInputElement()
          Creates an <input type='checkbox'> element.
 TableColElement createColElement()
          Creates a <col> element.
 TableColElement createColGroupElement()
          Creates a <colgroup> element.
 ModElement createDelElement()
          Creates a <del> element.
 DivElement createDivElement()
          Creates a <div> element.
 DListElement createDLElement()
          Creates a <dl> element.
 Element createElement(java.lang.String tagName)
          Creates a new element.
 FieldSetElement createFieldSetElement()
          Creates a <fieldset> element.
 InputElement createFileInputElement()
          Creates an <input type='file'> element.
 FormElement createFormElement()
          Creates a <form> element.
 FrameElement createFrameElement()
          Creates a <frame> element.
 FrameSetElement createFrameSetElement()
          Creates a <frameset> element.
 HeadElement createHeadElement()
          Creates a <head> element.
 HeadingElement createHElement(int n)
          Creates an <h(n)> element.
 InputElement createHiddenInputElement()
          Creates an <input type='hidden'> element.
 HRElement createHRElement()
          Creates an <hr> element.
 IFrameElement createIFrameElement()
          Creates an <iframe> element.
 ImageElement createImageElement()
          Creates an <img> element.
 InputElement createImageInputElement()
          Creates an <input type='image'> element.
 ModElement createInsElement()
          Creates an <ins> element.
 LabelElement createLabelElement()
          Creates a <label> element.
 LegendElement createLegendElement()
          Creates a <legend> element.
 LIElement createLIElement()
          Creates a <li> element.
 LinkElement createLinkElement()
          Creates a <link> element.
 MapElement createMapElement()
          Creates a <map> element.
 MetaElement createMetaElement()
          Creates a <meta> element.
 ObjectElement createObjectElement()
          Creates a <object> element.
 OListElement createOLElement()
          Creates an <ol> element.
 OptGroupElement createOptGroupElement()
          Creates an <optgroup> element.
 OptionElement createOptionElement()
          Creates an <option> element.
 ParamElement createParamElement()
          Creates a <param> element.
 InputElement createPasswordInputElement()
          Creates an <input type='password'> element.
 ParagraphElement createPElement()
          Creates a <p> element.
 PreElement createPreElement()
          Creates a <pre> element.
 QuoteElement createQElement()
          Creates a <q> element.
 InputElement createRadioInputElement(java.lang.String name)
          Creates an <input type='radio'> element.
 ScriptElement createScriptElement()
          Creates a <script> element.
 SelectElement createSelectElement()
          Creates a <select> element.
 SelectElement createSelectElement(boolean multiple)
          Creates a <select> element.
 SpanElement createSpanElement()
          Creates a <span> element.
 StyleElement createStyleElement()
          Creates a <style> element.
 TableElement createTableElement()
          Creates a <table> element.
 TableSectionElement createTBodyElement()
          Creates a <tbody> element.
 TableCellElement createTDElement()
          Creates a <td> element.
 TextAreaElement createTextAreaElement()
          Creates a <textarea> element.
 InputElement createTextInputElement()
          Creates an <input type='text'> element.
 Text createTextNode(java.lang.String data)
          Creates a text node.
 TableSectionElement createTFootElement()
          Creates a <tfoot> element.
 TableSectionElement createTHeadElement()
          Creates a <thead> element.
 TableCellElement createTHElement()
          Creates a <th> element.
 TitleElement createTitleElement()
          Creates a <title> element.
 TableRowElement createTRElement()
          Creates a <tr> element.
 UListElement createULElement()
          Creates a <ul> element.
 java.lang.String createUniqueId()
          Creates an identifier guaranteed to be unique within this document.
static Document get()
          Gets the default document.
 BodyElement getBody()
          The element that contains the content for the document.
 java.lang.String getDomain()
          The domain name of the server that served the document, or null if the server cannot be identified by a domain name.
 Element getElementById(java.lang.String elementId)
          Returns the Element whose id is given by elementId.
 NodeList<Element> getElementsByTagName(java.lang.String tagName)
          Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the document tree.
 java.lang.String getReferrer()
          Returns the URI of the page that linked to this page.
 java.lang.String getTitle()
          Gets the title of a document as specified by the TITLE element in the head of the document.
 java.lang.String getURL()
          Gets the absolute URI of this document.
 void importNode(Node node, boolean deep)
          Imports a node from another document to this document.
 void setTitle(java.lang.String title)
          Sets the title of a document as specified by the TITLE element in the head of the document.
 
Methods inherited from class com.google.gwt.dom.client.Node
appendChild, cloneNode, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasChildNodes, insertBefore, removeChild, replaceChild, setNodeValue
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Document

protected Document()
Method Detail

get

public static Document get()
Gets the default document. This is the document in which the module is running.

Returns:
the default document

createAnchorElement

public final AnchorElement createAnchorElement()
Creates an <a> element.

Returns:
the newly created element

createAreaElement

public final AreaElement createAreaElement()
Creates an <area> element.

Returns:
the newly created element

createBaseElement

public final BaseElement createBaseElement()
Creates a <base> element.

Returns:
the newly created element

createBlockQuoteElement

public final QuoteElement createBlockQuoteElement()
Creates a <blockquote> element.

Returns:
the newly created element

createBRElement

public final BRElement createBRElement()
Creates a <br> element.

Returns:
the newly created element

createButtonElement

public final ButtonElement createButtonElement()
Creates a <button> element.

Returns:
the newly created element

createCaptionElement

public final TableCaptionElement createCaptionElement()
Creates a <caption> element.

Returns:
the newly created element

createCheckInputElement

public final InputElement createCheckInputElement()
Creates an <input type='checkbox'> element.

Returns:
the newly created element

createColElement

public final TableColElement createColElement()
Creates a <col> element.

Returns:
the newly created element

createColGroupElement

public final TableColElement createColGroupElement()
Creates a <colgroup> element.

Returns:
the newly created element

createDelElement

public final ModElement createDelElement()
Creates a <del> element.

Returns:
the newly created element

createDivElement

public final DivElement createDivElement()
Creates a <div> element.

Returns:
the newly created element

createDLElement

public final DListElement createDLElement()
Creates a <dl> element.

Returns:
the newly created element

createElement

public final Element createElement(java.lang.String tagName)
Creates a new element.

Parameters:
tagName - the tag name of the element to be created
Returns:
the newly created element

createFieldSetElement

public final FieldSetElement createFieldSetElement()
Creates a <fieldset> element.

Returns:
the newly created element

createFileInputElement

public final InputElement createFileInputElement()
Creates an <input type='file'> element.

Returns:
the newly created element

createFormElement

public final FormElement createFormElement()
Creates a <form> element.

Returns:
the newly created element

createFrameElement

public final FrameElement createFrameElement()
Creates a <frame> element.

Returns:
the newly created element

createFrameSetElement

public final FrameSetElement createFrameSetElement()
Creates a <frameset> element.

Returns:
the newly created element

createHeadElement

public final HeadElement createHeadElement()
Creates a <head> element.

Returns:
the newly created element

createHElement

public final HeadingElement createHElement(int n)
Creates an <h(n)> element.

Parameters:
n - the type of heading, from 1 to 6 inclusive
Returns:
the newly created element

createHiddenInputElement

public final InputElement createHiddenInputElement()
Creates an <input type='hidden'> element.

Returns:
the newly created element

createHRElement

public final HRElement createHRElement()
Creates an <hr> element.

Returns:
the newly created element

createIFrameElement

public final IFrameElement createIFrameElement()
Creates an <iframe> element.

Returns:
the newly created element

createImageElement

public final ImageElement createImageElement()
Creates an <img> element.

Returns:
the newly created element

createImageInputElement

public final InputElement createImageInputElement()
Creates an <input type='image'> element.

Returns:
the newly created element

createInsElement

public final ModElement createInsElement()
Creates an <ins> element.

Returns:
the newly created element

createLabelElement

public final LabelElement createLabelElement()
Creates a <label> element.

Returns:
the newly created element

createLegendElement

public final LegendElement createLegendElement()
Creates a <legend> element.

Returns:
the newly created element

createLIElement

public final LIElement createLIElement()
Creates a <li> element.

Returns:
the newly created element

createLinkElement

public final LinkElement createLinkElement()
Creates a <link> element.

Returns:
the newly created element

createMapElement

public final MapElement createMapElement()
Creates a <map> element.

Returns:
the newly created element

createMetaElement

public final MetaElement createMetaElement()
Creates a <meta> element.

Returns:
the newly created element

createObjectElement

public final ObjectElement createObjectElement()
Creates a <object> element.

Returns:
the newly created element

createOLElement

public final OListElement createOLElement()
Creates an <ol> element.

Returns:
the newly created element

createOptGroupElement

public final OptGroupElement createOptGroupElement()
Creates an <optgroup> element.

Returns:
the newly created element

createOptionElement

public final OptionElement createOptionElement()
Creates an <option> element.

Returns:
the newly created element

createParamElement

public final ParamElement createParamElement()
Creates a <param> element.

Returns:
the newly created element

createPasswordInputElement

public final InputElement createPasswordInputElement()
Creates an <input type='password'> element.

Returns:
the newly created element

createPElement

public final ParagraphElement createPElement()
Creates a <p> element.

Returns:
the newly created element

createPreElement

public final PreElement createPreElement()
Creates a <pre> element.

Returns:
the newly created element

createQElement

public final QuoteElement createQElement()
Creates a <q> element.

Returns:
the newly created element

createRadioInputElement

public final InputElement createRadioInputElement(java.lang.String name)
Creates an <input type='radio'> element.

Parameters:
name - the name of the radio input (used for grouping)
Returns:
the newly created element

createScriptElement

public final ScriptElement createScriptElement()
Creates a <script> element.

Returns:
the newly created element

createSelectElement

public final SelectElement createSelectElement()
Creates a <select> element.

Returns:
the newly created element

createSelectElement

public final SelectElement createSelectElement(boolean multiple)
Creates a <select> element.

Parameters:
multiple - true to allow multiple-selection
Returns:
the newly created element

createSpanElement

public final SpanElement createSpanElement()
Creates a <span> element.

Returns:
the newly created element

createStyleElement

public final StyleElement createStyleElement()
Creates a <style> element.

Returns:
the newly created element

createTableElement

public final TableElement createTableElement()
Creates a <table> element.

Returns:
the newly created element

createTBodyElement

public final TableSectionElement createTBodyElement()
Creates a <tbody> element.

Returns:
the newly created element

createTDElement

public final TableCellElement createTDElement()
Creates a <td> element.

Returns:
the newly created element

createTextAreaElement

public final TextAreaElement createTextAreaElement()
Creates a <textarea> element.

Returns:
the newly created element

createTextInputElement

public final InputElement createTextInputElement()
Creates an <input type='text'> element.

Returns:
the newly created element

createTextNode

public final Text createTextNode(java.lang.String data)
Creates a text node.

Parameters:
data - the text node's initial text
Returns:
the newly created element

createTFootElement

public final TableSectionElement createTFootElement()
Creates a <tfoot> element.

Returns:
the newly created element

createTHeadElement

public final TableSectionElement createTHeadElement()
Creates a <thead> element.

Returns:
the newly created element

createTHElement

public final TableCellElement createTHElement()
Creates a <th> element.

Returns:
the newly created element

createTitleElement

public final TitleElement createTitleElement()
Creates a <title> element.

Returns:
the newly created element

createTRElement

public final TableRowElement createTRElement()
Creates a <tr> element.

Returns:
the newly created element

createULElement

public final UListElement createULElement()
Creates a <ul> element.

Returns:
the newly created element

createUniqueId

public final java.lang.String createUniqueId()
Creates an identifier guaranteed to be unique within this document. This is useful for allocating element id's.

Returns:
a unique identifier

getBody

public final BodyElement getBody()
The element that contains the content for the document. In documents with BODY contents, returns the BODY element.

Returns:
the document's body

getDomain

public final java.lang.String getDomain()
The domain name of the server that served the document, or null if the server cannot be identified by a domain name.

Returns:
the document's domain, or null if none exists

getElementById

public final Element getElementById(java.lang.String elementId)
Returns the Element whose id is given by elementId. If no such element exists, returns null. Behavior is not defined if more than one element has this id.

Parameters:
elementId - the unique id value for an element
Returns:
the matching element

getElementsByTagName

public final NodeList<Element> getElementsByTagName(java.lang.String tagName)
Returns a NodeList of all the Elements with a given tag name in the order in which they are encountered in a preorder traversal of the document tree.

Parameters:
tagName - the name of the tag to match on (the special value "*" matches all tags)
Returns:
a list containing all the matched elements

getReferrer

public final java.lang.String getReferrer()
Returns the URI 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).

Returns:
the referrer URI

getTitle

public final java.lang.String getTitle()
Gets the title of a document as specified by the TITLE element in the head of the document.

Returns:
the document's title

getURL

public final java.lang.String getURL()
Gets the absolute URI of this document.

Returns:
the document URI

importNode

public final void importNode(Node node,
                             boolean deep)
Imports a node from another document to this document. The returned node has no parent; (Node.getParentNode() is null). The source node is not altered or removed from the original document; this method creates a new copy of the source node. For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's nodeName and nodeType, plus the attributes related to namespaces (prefix, localName, and namespaceURI). As in the cloneNode operation on a Node, the source node is not altered. Additional information is copied as appropriate to the nodeType, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case.

Parameters:
node - the node to import
deep - If true, recursively import the subtree under the specified node; if false, import only the node itself, as explained above

setTitle

public final void setTitle(java.lang.String title)
Sets the title of a document as specified by the TITLE element in the head of the document.

Parameters:
title - the document's new title