org.jaxen.dom.html
Class DocumentNavigator

java.lang.Object
  extended byorg.jaxen.DefaultNavigator
      extended byorg.jaxen.dom.DocumentNavigator
          extended byorg.jaxen.dom.html.DocumentNavigator
All Implemented Interfaces:
Navigator, java.io.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 attributes 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)
          Constructs a new DocumentNavigator that will convert to lowercase.
 
Method Summary
 java.lang.String getElementName(java.lang.Object object)
          Get the local name of an element.
 java.lang.String getElementQName(java.lang.Object object)
          Get the qualified name of an element.
protected  java.lang.String getHTMLNodeName(org.w3c.dom.Node node, java.lang.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(java.lang.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, 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, getPrecedingAxisIterator, 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)
Constructs a new DocumentNavigator that will convert to lowercase.

Parameters:
toLowerCase - whether to convert all names to lowercase
Method Detail

isToLowerCase

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

Returns:
true if the navigator is converting to lowercase; false otherwise

getInstance

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

Returns:
a singleton instance of a DocumentNavigator

parseXPath

public XPath parseXPath(java.lang.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
Throws:
SAXPathException

getHTMLNodeName

protected java.lang.String getHTMLNodeName(org.w3c.dom.Node node,
                                           java.lang.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 java.lang.String getElementName(java.lang.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 java.lang.String getElementQName(java.lang.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-2005 Codehaus. All Rights Reserved.