Class ResourceExistsSelector

  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.selection.ResourceExistsSelector
All Implemented Interfaces:
Disposable, Component, LogEnabled, Serviceable, ThreadSafe, Selector

public class ResourceExistsSelector
extends AbstractLogEnabled
implements ThreadSafe, Serviceable, Disposable, Selector

Selects the first of a set of Resources (usually files) that exists.

A parameter 'prefix',

   <map:parameter src="prefix" value="some/path"/<
may be supplied to the selector instance. This prefix is prepended to all test expressions before evaluation. The default prefix is '' (empty string), meaning that all expressions are relative to the current sitemap, unless explicitly overridden.

NOTE: Provided resource URI is resolved as Source, relative to the current sitemap, which differs from behavior of selector in previous versions. To resolve resource paths relative to the context root, provide prefix parameter:

   <map:parameter name="prefix" value="context://"/<

For example, we could define a ResourceExistsSelector with:

 <map:selector name="resource-exists"
               src="org.apache.cocoon.selection.ResourceExistsSelector" /<
And use it to build a PDF from XSL:FO or a higher-level XML format with:
  <map:match pattern="**.pdf"<
    <map:select type="resource-exists"<
       <map:when test="context/xdocs/{1}.fo"<
          <map:generate src="content/xdocs/{1}.fo" /<
         <map:generate src="content/xdocs/{1}.xml" /<
         <map:transform src="stylesheets/document2fo.xsl" /<
    <map:serialize type="fo2pdf" /<

CVS $Id: ResourceExistsSelector.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Jeff Turner, Vadim Gritsenko

Field Summary
Fields inherited from interface org.apache.cocoon.selection.Selector
Constructor Summary
Method Summary
 void dispose()
 boolean select(String expression, Map objectModel, Parameters parameters)
          Selectors test pattern against some objects in a Map model and signals success with the returned boolean value
 void service(ServiceManager manager)
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


public ResourceExistsSelector()
Method Detail


public void service(ServiceManager manager)
             throws ServiceException
Specified by:
service in interface Serviceable


public void dispose()
Specified by:
dispose in interface Disposable


public boolean select(String expression,
                      Map objectModel,
                      Parameters parameters)
Description copied from interface: Selector
Selectors test pattern against some objects in a Map model and signals success with the returned boolean value

Specified by:
select in interface Selector
expression - The expression to test.
objectModel - The Map containing object of the calling environment which may be used to select values to test the expression.
parameters - The sitemap parameters, as specified by <parameter/> tags.
boolean Signals successfull test.

Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.