org.jaxen

Class DefaultNavigator

Implemented Interfaces:
Navigator, Serializable
Known Direct Subclasses:
DocumentNavigator, DocumentNavigator, DocumentNavigator, DocumentNavigator, DocumentNavigator

public abstract class DefaultNavigator
extends java.lang.Object
implements Navigator

Default implementation of Navigator.

This implementation is an abstract class, since some required operations cannot be implemented without additional knowledge of the object model.

When possible, default method implementations build upon each other, to reduce the number of methods required to be implemented for each object model. All methods, of course, may be overridden, to provide more-efficient implementations.

Authors:
bob mcwhirter (bob@werken.com)
Erwin Bolwidt (ejb@klomp.org)

Method Summary

Iterator
getAncestorAxisIterator(Object contextNode)
Iterator
getAncestorOrSelfAxisIterator(Object contextNode)
Iterator
getAttributeAxisIterator(Object contextNode)
Throws UnsupportedAxisException.
Iterator
getChildAxisIterator(Object contextNode)
Throws UnsupportedAxisException
Iterator
getDescendantAxisIterator(Object contextNode)
Iterator
getDescendantOrSelfAxisIterator(Object contextNode)
Object
getDocument(String url)
Default implementation that always returns null.
Object
getDocumentNode(Object contextNode)
Object
getElementById(Object contextNode, String elementId)
Default implementation that cannot find elements.
Iterator
getFollowingAxisIterator(Object contextNode)
Iterator
getFollowingSiblingAxisIterator(Object contextNode)
Iterator
getNamespaceAxisIterator(Object contextNode)
Throws UnsupportedAxisException.
short
getNodeType(Object node)
Iterator
getParentAxisIterator(Object contextNode)
Throws UnsupportedAxisException
Object
getParentNode(Object contextNode)
Default inefficient implementation.
Iterator
getPrecedingAxisIterator(Object contextNode)
Iterator
getPrecedingSiblingAxisIterator(Object contextNode)
String
getProcessingInstructionData(Object obj)
String
getProcessingInstructionTarget(Object obj)
Iterator
getSelfAxisIterator(Object contextNode)
String
translateNamespacePrefixToUri(String prefix, Object element)

Method Details

getAncestorAxisIterator

public Iterator getAncestorAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getAncestorAxisIterator in interface Navigator

getAncestorOrSelfAxisIterator

public Iterator getAncestorOrSelfAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getAncestorOrSelfAxisIterator in interface Navigator

getAttributeAxisIterator

public Iterator getAttributeAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Throws UnsupportedAxisException. Subclasses that support the attribute axis must override this method.
Specified by:
getAttributeAxisIterator in interface Navigator
Parameters:
contextNode -
Returns:
never returns

getChildAxisIterator

public Iterator getChildAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Throws UnsupportedAxisException
Specified by:
getChildAxisIterator in interface Navigator
Parameters:
contextNode -
Returns:
never returns
Throws:
UnsupportedAxisException - always

getDescendantAxisIterator

public Iterator getDescendantAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getDescendantAxisIterator in interface Navigator

getDescendantOrSelfAxisIterator

public Iterator getDescendantOrSelfAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getDescendantOrSelfAxisIterator in interface Navigator

getDocument

public Object getDocument(String url)
            throws FunctionCallException
Default implementation that always returns null. Override in subclass if the subclass can load documents.
Specified by:
getDocument in interface Navigator
Parameters:
url - the URL of the document to load
Returns:
null
Throws:
FunctionCallException - if an error occurs while loading the URL; e.g. an I/O error or the document is malformed

getDocumentNode

public Object getDocumentNode(Object contextNode)
Specified by:
getDocumentNode in interface Navigator

getElementById

public Object getElementById(Object contextNode,
                             String elementId)
Default implementation that cannot find elements. Override in subclass if subclass does know about attribute types.
Specified by:
getElementById in interface Navigator
Parameters:
contextNode - a node from the document in which to look for the id
elementId - id to look for
Returns:
null

getFollowingAxisIterator

public Iterator getFollowingAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getFollowingAxisIterator in interface Navigator

getFollowingSiblingAxisIterator

public Iterator getFollowingSiblingAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getFollowingSiblingAxisIterator in interface Navigator

getNamespaceAxisIterator

public Iterator getNamespaceAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Throws UnsupportedAxisException. Subclasses that support the namespace axis must override this method.
Specified by:
getNamespaceAxisIterator in interface Navigator
Parameters:
contextNode -
Returns:
never returns

getNodeType

public short getNodeType(Object node)
Specified by:
getNodeType in interface Navigator

getParentAxisIterator

public Iterator getParentAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Throws UnsupportedAxisException
Specified by:
getParentAxisIterator in interface Navigator
Parameters:
contextNode -
Returns:
never returns

getParentNode

public Object getParentNode(Object contextNode)
            throws UnsupportedAxisException
Default inefficient implementation. Subclasses should override this method.
Specified by:
getParentNode in interface Navigator
Parameters:
contextNode - the node whose parent to return
Returns:
the parent node
Throws:
UnsupportedAxisException - if the parent axis is not supported

getPrecedingAxisIterator

public Iterator getPrecedingAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getPrecedingAxisIterator in interface Navigator

getPrecedingSiblingAxisIterator

public Iterator getPrecedingSiblingAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getPrecedingSiblingAxisIterator in interface Navigator

getProcessingInstructionData

public String getProcessingInstructionData(Object obj)
Specified by:
getProcessingInstructionData in interface Navigator

getProcessingInstructionTarget

public String getProcessingInstructionTarget(Object obj)
Specified by:
getProcessingInstructionTarget in interface Navigator

getSelfAxisIterator

public Iterator getSelfAxisIterator(Object contextNode)
            throws UnsupportedAxisException
Specified by:
getSelfAxisIterator in interface Navigator

translateNamespacePrefixToUri

public String translateNamespacePrefixToUri(String prefix,
                                            Object element)
Specified by:
translateNamespacePrefixToUri in interface Navigator