Package org.jaxen
Class DefaultNavigator
- java.lang.Object
-
- org.jaxen.DefaultNavigator
-
- All Implemented Interfaces:
Serializable,Navigator
- Direct Known Subclasses:
DocumentNavigator,DocumentNavigator,DocumentNavigator,DocumentNavigator
public abstract class DefaultNavigator extends Object implements Navigator
Default implementation ofNavigator.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.
- Author:
- bob mcwhirter (bob@werken.com), Erwin Bolwidt (ejb@klomp.org)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultNavigator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IteratorgetAncestorAxisIterator(Object contextNode)Retrieve anIteratormatching theancestorXPath axis.IteratorgetAncestorOrSelfAxisIterator(Object contextNode)Retrieve anIteratormatching theancestor-or-selfXPath axis.IteratorgetAttributeAxisIterator(Object contextNode)ThrowsUnsupportedAxisException.IteratorgetChildAxisIterator(Object contextNode)ThrowsUnsupportedAxisExceptionIteratorgetDescendantAxisIterator(Object contextNode)Retrieve anIteratormatching thedescendantXPath axis.IteratorgetDescendantOrSelfAxisIterator(Object contextNode)Retrieve anIteratormatching thedescendant-or-selfXPath axis.ObjectgetDocument(String url)Default implementation that always returns null.ObjectgetDocumentNode(Object contextNode)Returns the document node that contains the given context node.ObjectgetElementById(Object contextNode, String elementId)Default implementation that cannot find elements.IteratorgetFollowingAxisIterator(Object contextNode)Retrieve anIteratormatching thefollowingXPath axis.IteratorgetFollowingSiblingAxisIterator(Object contextNode)Retrieve anIteratormatching thefollowing-siblingXPath axis.IteratorgetNamespaceAxisIterator(Object contextNode)ThrowsUnsupportedAxisException.shortgetNodeType(Object node)Returns a number that identifies the type of node that the given object represents in this navigator.IteratorgetParentAxisIterator(Object contextNode)ThrowsUnsupportedAxisExceptionObjectgetParentNode(Object contextNode)Default inefficient implementation.IteratorgetPrecedingAxisIterator(Object contextNode)Retrieve anIteratormatching theprecedingXPath axis.IteratorgetPrecedingSiblingAxisIterator(Object contextNode)Retrieve anIteratormatching thepreceding-siblingXPath axis.StringgetProcessingInstructionData(Object obj)Retrieve the data of a processing-instruction.StringgetProcessingInstructionTarget(Object obj)Retrieve the target of a processing-instruction.IteratorgetSelfAxisIterator(Object contextNode)Retrieve anIteratormatching theselfXPath axis.StringtranslateNamespacePrefixToUri(String prefix, Object element)Translate a namespace prefix to a namespace URI, possibly considering a particular element node.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jaxen.Navigator
getAttributeName, getAttributeNamespaceUri, getAttributeQName, getAttributeStringValue, getCommentStringValue, getElementName, getElementNamespaceUri, getElementQName, getElementStringValue, getNamespacePrefix, getNamespaceStringValue, getTextStringValue, isAttribute, isComment, isDocument, isElement, isNamespace, isProcessingInstruction, isText, parseXPath
-
-
-
-
Method Detail
-
getChildAxisIterator
public Iterator getChildAxisIterator(Object contextNode) throws UnsupportedAxisException
ThrowsUnsupportedAxisException- Specified by:
getChildAxisIteratorin interfaceNavigator- Parameters:
contextNode-- Returns:
- never returns
- Throws:
UnsupportedAxisException- always
-
getDescendantAxisIterator
public Iterator getDescendantAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching thedescendantXPath axis.- Specified by:
getDescendantAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the desscendant axis are not supported by this object model
-
getParentAxisIterator
public Iterator getParentAxisIterator(Object contextNode) throws UnsupportedAxisException
ThrowsUnsupportedAxisException- Specified by:
getParentAxisIteratorin interfaceNavigator- Parameters:
contextNode-- Returns:
- never returns
- Throws:
UnsupportedAxisException
-
getAncestorAxisIterator
public Iterator getAncestorAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching theancestorXPath axis.- Specified by:
getAncestorAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the ancestor axis are not supported by this object model
-
getFollowingSiblingAxisIterator
public Iterator getFollowingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching thefollowing-siblingXPath axis.- Specified by:
getFollowingSiblingAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the following-sibling axis are not supported by this object model
-
getPrecedingSiblingAxisIterator
public Iterator getPrecedingSiblingAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching thepreceding-siblingXPath axis.- Specified by:
getPrecedingSiblingAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the preceding-sibling axis are not supported by this object model
-
getFollowingAxisIterator
public Iterator getFollowingAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching thefollowingXPath axis.- Specified by:
getFollowingAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the following axis are not supported by this object model
-
getPrecedingAxisIterator
public Iterator getPrecedingAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching theprecedingXPath axis.- Specified by:
getPrecedingAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the preceding axis are not supported by this object model
-
getAttributeAxisIterator
public Iterator getAttributeAxisIterator(Object contextNode) throws UnsupportedAxisException
ThrowsUnsupportedAxisException. Subclasses that support the attribute axis must override this method.- Specified by:
getAttributeAxisIteratorin interfaceNavigator- Parameters:
contextNode-- Returns:
- never returns
- Throws:
UnsupportedAxisException
-
getNamespaceAxisIterator
public Iterator getNamespaceAxisIterator(Object contextNode) throws UnsupportedAxisException
ThrowsUnsupportedAxisException. Subclasses that support the namespace axis must override this method.- Specified by:
getNamespaceAxisIteratorin interfaceNavigator- Parameters:
contextNode-- Returns:
- never returns
- Throws:
UnsupportedAxisException
-
getSelfAxisIterator
public Iterator getSelfAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching theselfXPath axis.- Specified by:
getSelfAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the self axis are not supported by this object model
-
getDescendantOrSelfAxisIterator
public Iterator getDescendantOrSelfAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching thedescendant-or-selfXPath axis.- Specified by:
getDescendantOrSelfAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the descendant-or-self axis are not supported by this object model
-
getAncestorOrSelfAxisIterator
public Iterator getAncestorOrSelfAxisIterator(Object contextNode) throws UnsupportedAxisException
Description copied from interface:NavigatorRetrieve anIteratormatching theancestor-or-selfXPath axis.- Specified by:
getAncestorOrSelfAxisIteratorin interfaceNavigator- Parameters:
contextNode- the original context node- Returns:
- an Iterator capable of traversing the axis, not null
- Throws:
UnsupportedAxisException- if the semantics of the ancestor-or-self axis are not supported by this object model
-
getDocumentNode
public Object getDocumentNode(Object contextNode)
Description copied from interface:NavigatorReturns the document node that contains the given context node.- Specified by:
getDocumentNodein interfaceNavigator- Parameters:
contextNode- the context node- Returns:
- the document of the context node
- See Also:
Navigator.isDocument(Object)
-
translateNamespacePrefixToUri
public String translateNamespacePrefixToUri(String prefix, Object element)
Description copied from interface:NavigatorTranslate a namespace prefix to a namespace URI, possibly considering a particular element node.Strictly speaking, prefix-to-URI translation should occur irrespective of any element in the document. This method is provided to allow a non-conforming ease-of-use enhancement.
- Specified by:
translateNamespacePrefixToUriin interfaceNavigator- Parameters:
prefix- the prefix to translateelement- the element to consider during translation- Returns:
- the namespace URI associated with the prefix
- See Also:
NamespaceContext
-
getProcessingInstructionTarget
public String getProcessingInstructionTarget(Object obj)
Description copied from interface:NavigatorRetrieve the target of a processing-instruction.- Specified by:
getProcessingInstructionTargetin interfaceNavigator- Parameters:
obj- the context processing-instruction node- Returns:
- the target of the processing-instruction node
-
getProcessingInstructionData
public String getProcessingInstructionData(Object obj)
Description copied from interface:NavigatorRetrieve the data of a processing-instruction.- Specified by:
getProcessingInstructionDatain interfaceNavigator- Parameters:
obj- the context processing-instruction node- Returns:
- the data of the processing-instruction node
-
getNodeType
public short getNodeType(Object node)
Description copied from interface:NavigatorReturns a number that identifies the type of node that the given object represents in this navigator.- Specified by:
getNodeTypein interfaceNavigator- Parameters:
node- ????- Returns:
- ????
- See Also:
Pattern
-
getParentNode
public Object getParentNode(Object contextNode) throws UnsupportedAxisException
Default inefficient implementation. Subclasses should override this method.- Specified by:
getParentNodein interfaceNavigator- Parameters:
contextNode- the node whose parent to return- Returns:
- the parent node
- Throws:
UnsupportedAxisException- if the parent axis is not supported- See Also:
Navigator.isDocument(java.lang.Object),Navigator.isElement(java.lang.Object)
-
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:
getDocumentin interfaceNavigator- 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
-
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:
getElementByIdin interfaceNavigator- Parameters:
contextNode- a node from the document in which to look for the idelementId- id to look for- Returns:
- null
-
-