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

Nested Class Summary
 
Nested classes inherited from class org.jaxen.dom.DocumentNavigator
 
Field Summary
private static DocumentNavigator LOWERCASE
          Constant: lowercase navigator.
private  boolean toLowerCase
           
private static DocumentNavigator UPPERCASE
           
 
Fields inherited from class org.jaxen.dom.DocumentNavigator
 
Constructor Summary
DocumentNavigator()
          Constructs a new DocumentNavigator that will convert to lowercase.
DocumentNavigator(boolean toLowerCase)
           
 
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.
private  boolean isXMLNode(org.w3c.dom.Node node)
          Determine if a node is definately an XML node.
 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, 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
 

Field Detail

LOWERCASE

private static final DocumentNavigator LOWERCASE
Constant: lowercase navigator.


UPPERCASE

private static final DocumentNavigator UPPERCASE

toLowerCase

private final boolean toLowerCase
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(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.

isXMLNode

private boolean isXMLNode(org.w3c.dom.Node node)
Determine if a node is definately an XML node. Note: This will not work if the XML node has not been namespaced. However, since we are dealing with HTML documents, this is a minimal risk.