org.apache.cocoon.components.modules.input
Class AbstractJXPathModule

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLogEnabled
        |
        +--org.apache.cocoon.components.modules.input.AbstractInputModule
              |
              +--org.apache.cocoon.components.modules.input.AbstractJXPathModule
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, InputModule, org.apache.avalon.framework.logger.LogEnabled
Direct Known Subclasses:
RequestModule, SessionModule, SystemPropertyModule

public abstract class AbstractJXPathModule
extends AbstractInputModule

JXPathModule allows to access properties of any object in generic way. JXPath provides APIs for the traversal of graphs of JavaBeans, DOM and other types of objects using the XPath syntax. JXPathMetaModule is based on this class and duplicates the code since multiple inheritance is not possible. Please keep both classes in sync.

Configuration example:

<function name="java.lang.String" prefix="str"/> Imports the class "String" as extension class to the JXPathContext using the prefix "str". Thus "str:length(xpath)" would apply the method "length" to the string object obtained from the xpath expression. Please note that the class needs to be fully qualified.
<package name="java.util" prefix="util"/> Imports all classes in the package "java.util" as extension classes to the JXPathContext using the prefix "util". Thus "util:Date.new()" would create a new java.util.Date object.

Version:
$Id: AbstractJXPathModule.java,v 1.3.2.3 2002/12/06 09:20:01 cziegeler Exp $
Author:
Konstantin Piroumian, Christian Haul

Field Summary
protected  org.apache.commons.jxpath.FunctionLibrary library
          Contains all globally registered extension classes and packages.
 
Fields inherited from class org.apache.cocoon.components.modules.input.AbstractInputModule
settings
 
Fields inherited from interface org.apache.cocoon.components.modules.input.InputModule
ROLE
 
Constructor Summary
AbstractJXPathModule()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration config)
          Configure component.
 java.lang.Object getAttribute(java.lang.String name, org.apache.avalon.framework.configuration.Configuration modeConf, java.util.Map objectModel)
          Standard access to an attribute's value.
 java.util.Iterator getAttributeNames(org.apache.avalon.framework.configuration.Configuration modeConf, java.util.Map objectModel)
          Returns an Iterator of String objects containing the names of the attributes available.
 java.lang.Object[] getAttributeValues(java.lang.String name, org.apache.avalon.framework.configuration.Configuration modeConf, java.util.Map objectModel)
          Returns an array of String objects containing all of the values the given attribute has, or null if the attribute does not exist.
protected abstract  java.lang.Object getContextObject(org.apache.avalon.framework.configuration.Configuration modeConf, java.util.Map objectModel)
          Returns the object which should be used as JXPath context.
protected  void getFunctions(org.apache.commons.jxpath.FunctionLibrary lib, org.apache.avalon.framework.configuration.Configuration conf)
          Register all extension functions listed in the configuration through <function name="fully.qualified.Class" prefix="prefix"/> in the given FunctionLibrary.
protected  void getPackages(org.apache.commons.jxpath.FunctionLibrary lib, org.apache.avalon.framework.configuration.Configuration conf)
          Register all extension packages listed in the configuration through <package name="fully.qualified.package" prefix="prefix"/> in the given FunctionLibrary.
protected  void setupExtensions(org.apache.commons.jxpath.JXPathContext context, org.apache.avalon.framework.configuration.Configuration conf)
          Actually add global functions and packages as well as those listed in the configuration object.
 
Methods inherited from class org.apache.cocoon.components.modules.input.AbstractInputModule
dispose
 
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

library

protected org.apache.commons.jxpath.FunctionLibrary library
Contains all globally registered extension classes and packages. Thus the lookup and loading of globally registered extensions is done only once.
Constructor Detail

AbstractJXPathModule

public AbstractJXPathModule()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration config)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Configure component. Preprocess list of packages and functions to add to JXPath context later.
Overrides:
configure in class AbstractInputModule
Parameters:
conf - a Configuration value
Throws:
org.apache.avalon.framework.configuration.ConfigurationException - if an error occurs

getFunctions

protected void getFunctions(org.apache.commons.jxpath.FunctionLibrary lib,
                            org.apache.avalon.framework.configuration.Configuration conf)
Register all extension functions listed in the configuration through <function name="fully.qualified.Class" prefix="prefix"/> in the given FunctionLibrary.
Parameters:
lib - a FunctionLibrary value
conf - a Configuration value

getPackages

protected void getPackages(org.apache.commons.jxpath.FunctionLibrary lib,
                           org.apache.avalon.framework.configuration.Configuration conf)
Register all extension packages listed in the configuration through <package name="fully.qualified.package" prefix="prefix"/> in the given FunctionLibrary.
Parameters:
lib - a FunctionLibrary value
conf - a Configuration value

setupExtensions

protected void setupExtensions(org.apache.commons.jxpath.JXPathContext context,
                               org.apache.avalon.framework.configuration.Configuration conf)
Actually add global functions and packages as well as those listed in the configuration object.
Parameters:
context - a JXPathContext value
conf - a Configuration value holding local packages and functions.

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     org.apache.avalon.framework.configuration.Configuration modeConf,
                                     java.util.Map objectModel)
                              throws org.apache.avalon.framework.configuration.ConfigurationException
Description copied from interface: InputModule
Standard access to an attribute's value. If more than one value exists, the first is returned. If the value does not exist, null is returned. To get all values, use getAttributeSet or getAttributeNames and getAttribute to get them one by one.
Following copied from interface: org.apache.cocoon.components.modules.input.InputModule
Parameters:
name - a String that specifies what the caller thinks would identify an attribute. This is mainly a fallback if no modeConf is present.
modeConf - column's mode configuration from resource description. This argument is optional.
objectModel -  

getAttributeNames

public java.util.Iterator getAttributeNames(org.apache.avalon.framework.configuration.Configuration modeConf,
                                            java.util.Map objectModel)
                                     throws org.apache.avalon.framework.configuration.ConfigurationException
Description copied from interface: InputModule
Returns an Iterator of String objects containing the names of the attributes available. If no attributes are available, the method returns an empty Iterator.
Following copied from interface: org.apache.cocoon.components.modules.input.InputModule
Parameters:
modeConf - column's mode configuration from resource description. This argument is optional.
objectModel -  

getAttributeValues

public java.lang.Object[] getAttributeValues(java.lang.String name,
                                             org.apache.avalon.framework.configuration.Configuration modeConf,
                                             java.util.Map objectModel)
                                      throws org.apache.avalon.framework.configuration.ConfigurationException
Description copied from interface: InputModule
Returns an array of String objects containing all of the values the given attribute has, or null if the attribute does not exist. As an alternative, getAttributeNames together with getAttribute can be used to get the values one by one.
Following copied from interface: org.apache.cocoon.components.modules.input.InputModule
Parameters:
name - a String that specifies what the caller thinks would identify an attributes. This is mainly a fallback if no modeConf is present.
modeConf - column's mode configuration from resource description. This argument is optional.
objectModel -  

getContextObject

protected abstract java.lang.Object getContextObject(org.apache.avalon.framework.configuration.Configuration modeConf,
                                                     java.util.Map objectModel)
                                              throws org.apache.avalon.framework.configuration.ConfigurationException
Returns the object which should be used as JXPath context. Descendants should override this method to return a specific object that is requried by the implementing class. Examples are: request, session and application context objects.


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.