org.apache.cocoon.components.modules.input
Class JXPathMetaModule
java.lang.Object
|
+--org.apache.avalon.framework.logger.AbstractLogEnabled
|
+--org.apache.cocoon.components.modules.input.AbstractInputModule
|
+--org.apache.cocoon.components.modules.input.AbstractMetaModule
|
+--org.apache.cocoon.components.modules.input.JXPathMetaModule
- All Implemented Interfaces:
- org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, InputModule, org.apache.avalon.framework.logger.LogEnabled
- public class JXPathMetaModule
- extends AbstractMetaModule
- implements org.apache.avalon.framework.configuration.Configurable
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. This is based on the AbstractJXPathModule and duplicates
the code since multiple inheritance is not possible. Please keep both
classes in sync.
Configuration example:
<input-module name="request-attr" parameter="foo"/> |
Uses the "request-attr" input module to obtain parameter named "foo" and
applies the given JXPath expression to it. |
<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: JXPathMetaModule.java,v 1.1.2.2 2002/12/06 09:27:30 cziegeler Exp $
- Author:
- Konstantin Piroumian, Christian Haul
Field Summary |
protected org.apache.commons.jxpath.FunctionLibrary |
library
Contains all globally registered extension classes and
packages. |
protected java.lang.String |
parameter
|
Fields inherited from interface org.apache.cocoon.components.modules.input.InputModule |
ROLE |
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 java.lang.Object |
getContextObject(org.apache.avalon.framework.configuration.Configuration modeConf,
java.util.Map objectModel)
Looks up object from configured InputModule. |
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.AbstractMetaModule |
compose, dispose, getNames, getNames, getValue, getValue, getValues, getValues, initialize, obtainModule, releaseModule |
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 |
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.
parameter
protected java.lang.String parameter
JXPathMetaModule
public JXPathMetaModule()
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.
- Specified by:
configure
in interface org.apache.avalon.framework.configuration.Configurable
- 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
valueconf
- 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
valueconf
- 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
valueconf
- 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 java.lang.Object getContextObject(org.apache.avalon.framework.configuration.Configuration modeConf,
java.util.Map objectModel)
- Looks up object from configured InputModule.
- Parameters:
modeConf
- a Configuration
valueobjectModel
- a Map
value- Returns:
- an
Object
value
Copyright � 1999-2002 Apache Software Foundation. All Rights Reserved.