org.apache.excalibur.xml.xpath
Class AbstractProcessorImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.xml.xpath.AbstractProcessorImpl
All Implemented Interfaces:
Configurable, LogEnabled, PrefixResolver, XPathProcessor
Direct Known Subclasses:
JaxenProcessorImpl, Saxon6ProcessorImpl, Saxon7ProcessorImpl, XPathProcessorImpl

public abstract class AbstractProcessorImpl
extends AbstractLogEnabled
implements XPathProcessor, Configurable, PrefixResolver

This class defines base class for the implementations of the XPathProcessor component. Provides implementation of the PrefixResolver and common implementation of five selectXXX methods.

Version:
CVS $Revision: 1.4 $ $Date: 2004/02/28 11:47:15 $ $Author: cziegeler $
Author:
Avalon Development Team

Field Summary
 
Fields inherited from interface org.apache.excalibur.xml.xpath.XPathProcessor
ROLE
 
Constructor Summary
AbstractProcessorImpl()
           
 
Method Summary
 void configure(Configuration configuration)
          Pass the Configuration to the Configurable class.
 boolean evaluateAsBoolean(org.w3c.dom.Node contextNode, java.lang.String str)
          Evaluate XPath expression within a context.
abstract  boolean evaluateAsBoolean(org.w3c.dom.Node contextNode, java.lang.String str, PrefixResolver resolver)
          Evaluate XPath expression within a context.
 java.lang.Number evaluateAsNumber(org.w3c.dom.Node contextNode, java.lang.String str)
          Evaluate XPath expression within a context.
abstract  java.lang.Number evaluateAsNumber(org.w3c.dom.Node contextNode, java.lang.String str, PrefixResolver resolver)
          Evaluate XPath expression within a context.
 java.lang.String evaluateAsString(org.w3c.dom.Node contextNode, java.lang.String str)
          Evaluate XPath expression within a context.
abstract  java.lang.String evaluateAsString(org.w3c.dom.Node contextNode, java.lang.String str, PrefixResolver resolver)
          Evaluate XPath expression within a context.
 java.lang.String prefixToNamespace(java.lang.String prefix)
          Given a namespace prefix, return the corresponding namespace URI, or null if the namespace prefix is not known.
 org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextNode, java.lang.String str)
          Use an XPath string to select a nodelist.
abstract  org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextNode, java.lang.String str, PrefixResolver resolver)
          Use an XPath string to select a nodelist.
 org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String str)
          Use an XPath string to select a single node.
abstract  org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode, java.lang.String str, PrefixResolver resolver)
          Use an XPath string to select a single node.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractProcessorImpl

public AbstractProcessorImpl()
Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException
Description copied from interface: Configurable
Pass the Configuration to the Configurable class.

Specified by:
configure in interface Configurable
Parameters:
configuration - the class configurations. Must not be null.
Throws:
ConfigurationException - if an error occurs

selectSingleNode

public org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode,
                                         java.lang.String str)
Use an XPath string to select a single node. XPath namespace prefixes are resolved from the context node, which may not be what you want (see the next method).

Specified by:
selectSingleNode in interface XPathProcessor
Parameters:
contextNode - The node to start searching from.
str - A valid XPath string.
Returns:
The first node found that matches the XPath, or null.

selectNodeList

public org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextNode,
                                           java.lang.String str)
Use an XPath string to select a nodelist. XPath namespace prefixes are resolved from the contextNode.

Specified by:
selectNodeList in interface XPathProcessor
Parameters:
contextNode - The node to start searching from.
str - A valid XPath string.
Returns:
A NodeList, should never be null.

evaluateAsBoolean

public boolean evaluateAsBoolean(org.w3c.dom.Node contextNode,
                                 java.lang.String str)
Evaluate XPath expression within a context.

Specified by:
evaluateAsBoolean in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
Returns:
expression result as boolean.

evaluateAsNumber

public java.lang.Number evaluateAsNumber(org.w3c.dom.Node contextNode,
                                         java.lang.String str)
Evaluate XPath expression within a context.

Specified by:
evaluateAsNumber in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
Returns:
expression result as number.

evaluateAsString

public java.lang.String evaluateAsString(org.w3c.dom.Node contextNode,
                                         java.lang.String str)
Evaluate XPath expression within a context.

Specified by:
evaluateAsString in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
Returns:
expression result as string.

evaluateAsBoolean

public abstract boolean evaluateAsBoolean(org.w3c.dom.Node contextNode,
                                          java.lang.String str,
                                          PrefixResolver resolver)
Evaluate XPath expression within a context.

Specified by:
evaluateAsBoolean in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
resolver - a PrefixResolver, used for resolving namespace prefixes
Returns:
expression result as boolean.

evaluateAsNumber

public abstract java.lang.Number evaluateAsNumber(org.w3c.dom.Node contextNode,
                                                  java.lang.String str,
                                                  PrefixResolver resolver)
Evaluate XPath expression within a context.

Specified by:
evaluateAsNumber in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
resolver - a PrefixResolver, used for resolving namespace prefixes
Returns:
expression result as number.

evaluateAsString

public abstract java.lang.String evaluateAsString(org.w3c.dom.Node contextNode,
                                                  java.lang.String str,
                                                  PrefixResolver resolver)
Evaluate XPath expression within a context.

Specified by:
evaluateAsString in interface XPathProcessor
Parameters:
contextNode - The context node.
str - A valid XPath string.
resolver - a PrefixResolver, used for resolving namespace prefixes
Returns:
expression result as string.

selectSingleNode

public abstract org.w3c.dom.Node selectSingleNode(org.w3c.dom.Node contextNode,
                                                  java.lang.String str,
                                                  PrefixResolver resolver)
Use an XPath string to select a single node.

Specified by:
selectSingleNode in interface XPathProcessor
Parameters:
contextNode - The node to start searching from.
str - A valid XPath string.
resolver - a PrefixResolver, used for resolving namespace prefixes
Returns:
The first node found that matches the XPath, or null.

selectNodeList

public abstract org.w3c.dom.NodeList selectNodeList(org.w3c.dom.Node contextNode,
                                                    java.lang.String str,
                                                    PrefixResolver resolver)
Use an XPath string to select a nodelist.

Specified by:
selectNodeList in interface XPathProcessor
Parameters:
contextNode - The node to start searching from.
str - A valid XPath string.
resolver - a PrefixResolver, used for resolving namespace prefixes
Returns:
A List, should never be null.

prefixToNamespace

public java.lang.String prefixToNamespace(java.lang.String prefix)
Description copied from interface: PrefixResolver
Given a namespace prefix, return the corresponding namespace URI, or null if the namespace prefix is not known.

Specified by:
prefixToNamespace in interface PrefixResolver


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.