org.apache.excalibur.xml.xpath
Class AbstractProcessorImpl

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.xml.xpath.AbstractProcessorImpl
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, PrefixResolver, XPathProcessor
Direct Known Subclasses:
JaxenProcessorImpl, Saxon8ProcessorImpl, XPathProcessorImpl

public abstract class AbstractProcessorImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements XPathProcessor, org.apache.avalon.framework.configuration.Configurable, PrefixResolver, org.apache.avalon.framework.component.Component

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
private  java.util.HashMap m_mappings
           
 
Fields inherited from interface org.apache.excalibur.xml.xpath.XPathProcessor
ROLE
 
Constructor Summary
AbstractProcessorImpl()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 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
 

Field Detail

m_mappings

private final java.util.HashMap m_mappings
Constructor Detail

AbstractProcessorImpl

public AbstractProcessorImpl()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

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