com.gargoylesoftware.htmlunit.javascript.host
Class TreeWalker

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.TreeWalker
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

public class TreeWalker
extends SimpleScriptable

The JavaScript object that represents a TreeWalker.

Version:
$Revision: 5564 $
Author:
Mike Dirolf
See Also:
DOM-Level-2-Traversal-Range, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
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
TreeWalker()
          Creates an instance.
TreeWalker(Node root, int whatToShow, NodeFilter filter, Boolean expandEntityReferences)
          Creates an instance.
 
Method Summary
 Node jsxFunction_firstChild()
          Moves the TreeWalker to the first visible child of the current node, and returns the new node.
 Node jsxFunction_lastChild()
          Moves the TreeWalker to the last visible child of the current node, and returns the new node.
 Node jsxFunction_nextNode()
          Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node.
 Node jsxFunction_nextSibling()
          Moves the TreeWalker to the next sibling of the current node, and returns the new node.
 Node jsxFunction_parentNode()
          Moves to and returns the closest visible ancestor node of the current node.
 Node jsxFunction_previousNode()
          Moves the TreeWalker to the previous visible node in document order relative to the current node, and returns the new node.
 Node jsxFunction_previousSibling()
          Moves the TreeWalker to the previous sibling of the current node, and returns the new node.
 Node jsxGet_currentNode()
          Gets the node at which the TreeWalker is currently positioned.
 boolean jsxGet_expandEntityReferences()
          Gets the flag specifying wherether or not to reject EntityReference nodes.
 NodeFilter jsxGet_filter()
          Gets the filter used to screen nodes.
 Node jsxGet_root()
          Gets the root node of the TreeWalker, as specified when it was created.
 long jsxGet_whatToShow()
          Gets the whatToShow attribute of the TreeWalker.
 void jsxSet_currentNode(Node currentNode)
          Sets the node at which the TreeWalker is currently positioned.
 
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, 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

TreeWalker

public TreeWalker()
Creates an instance.


TreeWalker

public TreeWalker(Node root,
                  int whatToShow,
                  NodeFilter filter,
                  Boolean expandEntityReferences)
           throws DOMException
Creates an instance.

Parameters:
root - The root node of the TreeWalker. Must not be null.
whatToShow - Flag specifying which types of nodes appear in the logical view of the TreeWalker. See NodeFilter for the set of possible Show_ values.
filter - The NodeFilter to be used with this TreeWalker, or null to indicate no filter.
expandEntityReferences - If false, the contents of EntityReference nodes are not present in the logical view.
Throws:
DOMException - on attempt to create a TreeWalker with a root that is null.
DOMException
Method Detail

jsxGet_root

public Node jsxGet_root()
Gets the root node of the TreeWalker, as specified when it was created.

Returns:
the root node of the TreeWalker

jsxGet_whatToShow

public long jsxGet_whatToShow()
Gets the whatToShow attribute of the TreeWalker. This attribute determines which node types are presented via the TreeWalker. The set of available constants is defined in NodeFilter.

Returns:
the value of the whatToShow attribute of the TreeWalker

jsxGet_filter

public NodeFilter jsxGet_filter()
Gets the filter used to screen nodes.

Returns:
the filter used to screen nodes

jsxGet_expandEntityReferences

public boolean jsxGet_expandEntityReferences()
Gets the flag specifying wherether or not to reject EntityReference nodes.

Returns:
the value of the expandEntityReferences flag

jsxGet_currentNode

public Node jsxGet_currentNode()
Gets the node at which the TreeWalker is currently positioned.

Returns:
the currentNode

jsxSet_currentNode

public void jsxSet_currentNode(Node currentNode)
                        throws DOMException
Sets the node at which the TreeWalker is currently positioned.

Parameters:
currentNode - The node to be used as the current position of the TreeWalker.
Throws:
DOMException - on attempt to set currentNode to null.
DOMException

jsxFunction_parentNode

public Node jsxFunction_parentNode()
Moves to and returns the closest visible ancestor node of the current node. If the search for parentNode attempts to step upward from the TreeWalker's root node, or if it fails to find a visible ancestor node, this method retains the current position and returns null.

Returns:
The new parent node, or null if the current node has no parent in the TreeWalker's logical view.

jsxFunction_firstChild

public Node jsxFunction_firstChild()
Moves the TreeWalker to the first visible child of the current node, and returns the new node. If the current node has no visible children, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no visible children in the TreeWalker's logical view.

jsxFunction_lastChild

public Node jsxFunction_lastChild()
Moves the TreeWalker to the last visible child of the current node, and returns the new node. If the current node has no visible children, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no visible children in the TreeWalker's logical view.

jsxFunction_previousSibling

public Node jsxFunction_previousSibling()
Moves the TreeWalker to the previous sibling of the current node, and returns the new node. If the current node has no visible previous sibling, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no previous sibling in the TreeWalker's logical view.

jsxFunction_nextSibling

public Node jsxFunction_nextSibling()
Moves the TreeWalker to the next sibling of the current node, and returns the new node. If the current node has no visible next sibling, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no next sibling in the TreeWalker's logical view.

jsxFunction_previousNode

public Node jsxFunction_previousNode()
Moves the TreeWalker to the previous visible node in document order relative to the current node, and returns the new node. If the current node has no previous node, or if the search for previousNode attempts to step upward from the TreeWalker's root node, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no previous node in the TreeWalker's logical view.

jsxFunction_nextNode

public Node jsxFunction_nextNode()
Moves the TreeWalker to the next visible node in document order relative to the current node, and returns the new node. If the current node has no next node, or if the search for nextNode attempts to step upward from the TreeWalker's root node, returns null, and retains the current node.

Returns:
The new node, or null if the current node has no next node in the TreeWalker's logical view.


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