com.gargoylesoftware.htmlunit.javascript.host
Class Document

java.lang.Object
  extended by net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
      extended by com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
          extended by com.gargoylesoftware.htmlunit.javascript.host.Node
              extended by com.gargoylesoftware.htmlunit.javascript.host.EventNode
                  extended by com.gargoylesoftware.htmlunit.javascript.host.Document
All Implemented Interfaces:
Serializable, Cloneable, Map, net.sourceforge.htmlunit.corejs.javascript.ConstProperties, net.sourceforge.htmlunit.corejs.javascript.debug.DebuggableObject, net.sourceforge.htmlunit.corejs.javascript.Scriptable
Direct Known Subclasses:
HTMLDocument, XMLDocument

public class Document
extends EventNode

A JavaScript object for a Document.

Version:
$Revision: 5864 $
Author:
Mike Bowler, David K. Taylor, Chen Jun, Christian Sell, Chris Erskine, Marc Guillemot, Daniel Gredler, Michael Ottati, George Murnock, Ahmed Ashour, Rob Di Marco
See Also:
MSDN documentation, W3C Dom Level 1, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class com.gargoylesoftware.htmlunit.javascript.host.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
 
Fields inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface net.sourceforge.htmlunit.corejs.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
Document()
           
 
Method Summary
protected  SgmlPage getPage()
          Returns the page that this document is modeling.
 void jsxFunction_captureEvents(String type)
          Does nothing special anymore...
 Attr jsxFunction_createAttribute(String attributeName)
          Creates a new HTML attribute with the specified name.
 Object jsxFunction_createComment(String comment)
          Creates a new Comment.
 Object jsxFunction_createDocumentFragment()
          Creates a new document fragment.
 Object jsxFunction_createElement(String tagName)
          Create a new HTML element with the given tag name.
 Object jsxFunction_createElementNS(String namespaceURI, String qualifiedName)
          Creates a new HTML element with the given tag name, and name.
 XPathNSResolver jsxFunction_createNSResolver(Node nodeResolver)
          Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated relative to the context of the node where it appeared within the document.
 Object jsxFunction_createTextNode(String newData)
          Create a new DOM text node with the given data.
 XPathResult jsxFunction_evaluate(String expression, Node contextNode, Object resolver, int type, Object result)
          Evaluates an XPath expression string and returns a result of the specified type if possible.
 BoxObject jsxFunction_getBoxObjectFor(HTMLElement element)
          Returns the BoxObject for the specific element.
 HTMLCollection jsxFunction_getElementsByTagName(String tagName)
          Returns all the descendant elements with the specified tag name.
 Object jsxFunction_getElementsByTagNameNS(Object namespaceURI, String localName)
          Returns a list of elements with the given tag name belonging to the given namespace.
 Object jsxFunction_importNode(Node importedNode, boolean deep)
          Imports a node from another document to this document.
 Object jsxGet_defaultView()
          Gets the window in which this document is contained.
 String jsxGet_designMode()
          Returns a value which indicates whether or not the document can be edited.
 SimpleScriptable jsxGet_doctype()
          Gets the JavaScript property "doctype" for the document.
 Element jsxGet_documentElement()
          Gets the JavaScript property "documentElement" for the document.
 DOMImplementation jsxGet_implementation()
          Returns the implementation object of the current document.
 Location jsxGet_location()
          Returns the value of the "location" property.
 String jsxGet_referrer()
          Returns the value of the "referrer" property.
 void jsxSet_designMode(String mode)
          Sets a value which indicates whether or not the document can be edited.
 void jsxSet_location(String location)
          Sets the value of the "location" property.
 void setWindow(Window window)
          Sets the Window JavaScript object that encloses this document.
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.EventNode
jsxFunction_fireEvent, jsxGet_onblur, jsxGet_onclick, jsxGet_oncontextmenu, jsxGet_ondblclick, jsxGet_onerror, jsxGet_onfocus, jsxGet_onfocusin, jsxGet_onfocusout, jsxGet_onkeydown, jsxGet_onkeypress, jsxGet_onkeyup, jsxGet_onmousedown, jsxGet_onmousemove, jsxGet_onmouseout, jsxGet_onmouseover, jsxGet_onmouseup, jsxGet_onpropertychange, jsxGet_onresize, jsxSet_onblur, jsxSet_onclick, jsxSet_oncontextmenu, jsxSet_ondblclick, jsxSet_onerror, jsxSet_onfocus, jsxSet_onfocusin, jsxSet_onfocusout, jsxSet_onkeydown, jsxSet_onkeypress, jsxSet_onkeyup, jsxSet_onmousedown, jsxSet_onmousemove, jsxSet_onmouseout, jsxSet_onmouseover, jsxSet_onmouseup, jsxSet_onpropertychange, jsxSet_onresize
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.host.Node
executeEvent, fireEvent, getEventHandler, getEventHandlerProp, getJavaScriptNode, getParent, hasEventHandlers, jsxFunction_addEventListener, jsxFunction_appendChild, jsxFunction_attachEvent, jsxFunction_cloneNode, jsxFunction_compareDocumentPosition, jsxFunction_detachEvent, jsxFunction_hasChildNodes, jsxFunction_insertBefore, jsxFunction_insertBefore, jsxFunction_isSameNode, jsxFunction_normalize, jsxFunction_removeChild, jsxFunction_removeEventListener, jsxFunction_replaceChild, jsxGet_childNodes, jsxGet_firstChild, jsxGet_lastChild, jsxGet_localName, jsxGet_namespaceURI, jsxGet_nextSibling, jsxGet_nodeName, jsxGet_nodeType, jsxGet_nodeValue, jsxGet_ownerDocument, jsxGet_parentNode, jsxGet_prefix, jsxGet_previousSibling, jsxGet_textContent, jsxGet_xml, jsxSet_nodeValue, jsxSet_textContent, setDomNode, setEventHandler, setEventHandlerProp
 
Methods inherited from class com.gargoylesoftware.htmlunit.javascript.SimpleScriptable
clone, defineFunctionProperties, defineProperty, equivalentValues, get, getBrowserVersion, getClassName, getDefaultValue, getDomNodeOrDie, getDomNodeOrNull, getPrototype, getScriptableFor, getStartingScope, getTransformerScriptableFor, getWindow, getWindow, getWithPreemption, hasInstance, initParentScope, makeScriptableFor, setCaseSensitive, setDomNode, setHtmlElement
 
Methods inherited from class net.sourceforge.htmlunit.corejs.javascript.ScriptableObject
applyDescriptorToAttributeBitset, associateValue, avoidObjectDetection, buildDataDescriptor, callMethod, callMethod, clear, containsKey, containsValue, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineOwnProperties, defineOwnProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, ensureScriptable, ensureScriptableObject, entrySet, get, get, getAllIds, getArrayPrototype, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getOwnPropertyDescriptor, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getSlot, getTopLevelScope, getTopScopeValue, getTypeOf, has, has, hasProperty, hasProperty, isAccessorDescriptor, isConst, isDataDescriptor, isEmpty, isExtensible, isFalse, isGenericDescriptor, isGetterOrSetter, isSealed, isTrue, keySet, preventExtensions, put, put, put, putAll, putConst, putConstProperty, putProperty, putProperty, redefineProperty, remove, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype, size, values
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

Document

public Document()
Method Detail

setWindow

public void setWindow(Window window)
Sets the Window JavaScript object that encloses this document.

Parameters:
window - the Window JavaScript object that encloses this document

jsxGet_location

public Location jsxGet_location()
Returns the value of the "location" property.

Returns:
the value of the "location" property

jsxSet_location

public void jsxSet_location(String location)
                     throws IOException
Sets the value of the "location" property. The location's default property is "href", so setting "document.location='http://www.sf.net'" is equivalent to setting "document.location.href='http://www.sf.net'".

Parameters:
location - the location to navigate to
Throws:
IOException - when location loading fails
See Also:
MSDN documentation

jsxGet_referrer

public String jsxGet_referrer()
Returns the value of the "referrer" property.

Returns:
the value of the "referrer" property

jsxGet_documentElement

public Element jsxGet_documentElement()
Gets the JavaScript property "documentElement" for the document.

Returns:
the root node for the document

jsxGet_doctype

public SimpleScriptable jsxGet_doctype()
Gets the JavaScript property "doctype" for the document.

Returns:
the DocumentType of the document

jsxGet_designMode

public String jsxGet_designMode()
Returns a value which indicates whether or not the document can be edited.

Returns:
a value which indicates whether or not the document can be edited

jsxSet_designMode

public void jsxSet_designMode(String mode)
Sets a value which indicates whether or not the document can be edited.

Parameters:
mode - a value which indicates whether or not the document can be edited

getPage

protected SgmlPage getPage()
Returns the page that this document is modeling.

Returns:
the page that this document is modeling

jsxGet_defaultView

public Object jsxGet_defaultView()
Gets the window in which this document is contained.

Returns:
the window

jsxFunction_createDocumentFragment

public Object jsxFunction_createDocumentFragment()
Creates a new document fragment.

Returns:
a newly created document fragment

jsxFunction_createAttribute

public Attr jsxFunction_createAttribute(String attributeName)
Creates a new HTML attribute with the specified name.

Parameters:
attributeName - the name of the attribute to create
Returns:
an attribute with the specified name

jsxFunction_getBoxObjectFor

public BoxObject jsxFunction_getBoxObjectFor(HTMLElement element)
Returns the BoxObject for the specific element.

Parameters:
element - target for BoxObject
Returns:
the BoxObject

jsxFunction_importNode

public Object jsxFunction_importNode(Node importedNode,
                                     boolean deep)
Imports a node from another document to this document. The source node is not altered or removed from the original document; this method creates a new copy of the source node.

Parameters:
importedNode - the node to import
deep - Whether to recursively import the subtree under the specified node; or not
Returns:
the imported node that belongs to this Document

jsxGet_implementation

public DOMImplementation jsxGet_implementation()
Returns the implementation object of the current document.

Returns:
implementation-specific object

jsxFunction_captureEvents

public void jsxFunction_captureEvents(String type)
Does nothing special anymore... just like FF.

Parameters:
type - the type of events to capture
See Also:
Window.jsxFunction_captureEvents(String)

jsxFunction_createNSResolver

public XPathNSResolver jsxFunction_createNSResolver(Node nodeResolver)
Adapts any DOM node to resolve namespaces so that an XPath expression can be easily evaluated relative to the context of the node where it appeared within the document.

Parameters:
nodeResolver - the node to be used as a context for namespace resolution
Returns:
an XPathNSResolver which resolves namespaces with respect to the definitions in scope for a specified node

jsxFunction_createTextNode

public Object jsxFunction_createTextNode(String newData)
Create a new DOM text node with the given data.

Parameters:
newData - the string value for the text node
Returns:
the new text node or NOT_FOUND if there is an error

jsxFunction_createComment

public Object jsxFunction_createComment(String comment)
Creates a new Comment.

Parameters:
comment - the comment text
Returns:
the new Comment

jsxFunction_evaluate

public XPathResult jsxFunction_evaluate(String expression,
                                        Node contextNode,
                                        Object resolver,
                                        int type,
                                        Object result)
Evaluates an XPath expression string and returns a result of the specified type if possible.

Parameters:
expression - the XPath expression string to be parsed and evaluated
contextNode - the context node for the evaluation of this XPath expression
resolver - the resolver permits translation of all prefixes, including the XML namespace prefix, within the XPath expression into appropriate namespace URIs.
type - If a specific type is specified, then the result will be returned as the corresponding type
result - the result object which may be reused and returned by this method
Returns:
the result of the evaluation of the XPath expression

jsxFunction_createElement

public Object jsxFunction_createElement(String tagName)
Create a new HTML element with the given tag name.

Parameters:
tagName - the tag name
Returns:
the new HTML element, or NOT_FOUND if the tag is not supported

jsxFunction_createElementNS

public Object jsxFunction_createElementNS(String namespaceURI,
                                          String qualifiedName)
Creates a new HTML element with the given tag name, and name.

Parameters:
namespaceURI - the URI that identifies an XML namespace
qualifiedName - the qualified name of the element type to instantiate
Returns:
the new HTML element, or NOT_FOUND if the tag is not supported

jsxFunction_getElementsByTagName

public HTMLCollection jsxFunction_getElementsByTagName(String tagName)
Returns all the descendant elements with the specified tag name.

Parameters:
tagName - the name to search for
Returns:
all the descendant elements with the specified tag name

jsxFunction_getElementsByTagNameNS

public Object jsxFunction_getElementsByTagNameNS(Object namespaceURI,
                                                 String localName)
Returns a list of elements with the given tag name belonging to the given namespace.

Parameters:
namespaceURI - the namespace URI of elements to look for
localName - is either the local name of elements to look for or the special value "*", which matches all elements.
Returns:
a live NodeList of found elements in the order they appear in the tree


Copyright © 2002-2011 Gargoyle Software Inc.. All Rights Reserved.