org.jaxen.dom.html
Class DocumentNavigator

java.lang.Object
  |
  +--org.jaxen.DefaultNavigator
        |
        +--org.jaxen.dom.DocumentNavigator
              |
              +--org.jaxen.dom.html.DocumentNavigator
All Implemented Interfaces:
Navigator, Serializable

public class DocumentNavigator
extends DocumentNavigator

Interface for navigating around the W3C HTML DOM object model.

This class is not intended for direct usage, but is used by the Jaxen engine during evaluation.

XML is case-sensitive. HTML is not. This navigator is an extension of the DOM DocumentNavigator that automatically changes all element, but not attribute, names to lowercase or uppercase to aid in navigating through HTML documents. Note that case modification are bypassed for XHTML documents. XHTML is case sensitive and can be expected to store all elements and atributes in lower case. Also Note that HTML attribute names are stored as lower case in the HTML (and XHTML) DOM already which is why the case of attribute names are not modified.

Author:
David Peterson
See Also:
XPath, DOMXPath, NamespaceNode, Serialized Form

Constructor Summary
DocumentNavigator()
          Constructs a new DocumentNavigator that will convert to lowercase.
DocumentNavigator(boolean toLowerCase)
           
 
Method Summary
 String getElementName(Object object)
          Get the local name of an element.
 String getElementQName(Object object)
          Get the qualified name of an element.
protected  String getHTMLNodeName(org.w3c.dom.Node node, String name)
          Get the name of the node in the case specified for the current object
static Navigator getInstance(boolean toLowerCase)
          Get a singleton DocumentNavigator for efficiency.
 boolean isToLowerCase()
          Returns true if the navigator is converting to lowercase.
 XPath parseXPath(String xpath)
          Returns a parsed form of the given xpath string, which will be suitable for queries on HTML DOM documents.
 
Methods inherited from class org.jaxen.dom.DocumentNavigator
getAttributeAxisIterator, getAttributeName, getAttributeNamespaceUri, getAttributeQName, getAttributeStringValue, getChildAxisIterator, getCommentStringValue, getDocument, getDocumentNode, getElementById, getElementNamespaceUri, getElementStringValue, getFollowingAxisIterator, getFollowingSiblingAxisIterator, getInstance, getNamespaceAxisIterator, getNamespacePrefix, getNamespaceStringValue, getParentAxisIterator, getPrecedingAxisIterator, getPrecedingSiblingAxisIterator, getProcessingInstructionData, getProcessingInstructionTarget, getTextStringValue, isAttribute, isComment, isDocument, isElement, isNamespace, isProcessingInstruction, isText, translateNamespacePrefixToUri
 
Methods inherited from class org.jaxen.DefaultNavigator
getAncestorAxisIterator, getAncestorOrSelfAxisIterator, getDescendantAxisIterator, getDescendantOrSelfAxisIterator, getNodeType, getParentNode, getSelfAxisIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentNavigator

public DocumentNavigator()
Constructs a new DocumentNavigator that will convert to lowercase.


DocumentNavigator

public DocumentNavigator(boolean toLowerCase)
Method Detail

isToLowerCase

public boolean isToLowerCase()
Returns true if the navigator is converting to lowercase.

Returns:

getInstance

public static Navigator getInstance(boolean toLowerCase)
Get a singleton DocumentNavigator for efficiency.

Returns:
A singleton instance of a DocumentNavigator.

parseXPath

public XPath parseXPath(String xpath)
                 throws SAXPathException
Returns a parsed form of the given xpath string, which will be suitable for queries on HTML DOM documents.

Specified by:
parseXPath in interface Navigator
Overrides:
parseXPath in class DocumentNavigator
Parameters:
xpath - The xpath expression.
Returns:
A new XPath expression object.
Throws:
SAXPathException - If an error occurs while parsing the xpath expression.
See Also:
XPath

getHTMLNodeName

protected String getHTMLNodeName(org.w3c.dom.Node node,
                                 String name)
Get the name of the node in the case specified for the current object

Parameters:
node - The target node. Used to avoid case modification of node names in XML documents.
name - the name of the node, presumably in the case natively stored by the DOM.
Returns:
the name of the node, case-modified as desired, if the current document is HTML and not XML.

getElementName

public String getElementName(Object object)
Description copied from class: DocumentNavigator
Get the local name of an element.

Specified by:
getElementName in interface Navigator
Overrides:
getElementName in class DocumentNavigator
Parameters:
object - The target node.
Returns:
A string representing the unqualified local name if the node is an element, or null otherwise.

getElementQName

public String getElementQName(Object object)
Description copied from class: DocumentNavigator
Get the qualified name of an element.

Specified by:
getElementQName in interface Navigator
Overrides:
getElementQName in class DocumentNavigator
Parameters:
object - The target node.
Returns:
A string representing the qualified (i.e. possibly prefixed) name if the node is an element, or null otherwise.


Copyright © 2001-2003 Codehaus. All Rights Reserved.