cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [49/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/LocaleMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/LocaleMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/LocaleMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/LocaleMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,363 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import org.apache.cocoon.i18n.I18nUtils;
+import org.apache.cocoon.sitemap.PatternException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * A matcher that locates and identifies to the pipeline a source document to
+ * be used as the content for an i18n site, based upon a locale provided in a
+ * range of ways.
+ *
+ * <h1>Configuration</h1>
+ * <p>A sample configuration (given in the &lt;map:matchers&gt; section of the
+ * sitemap) is given below. This configuration shows default values.
+ * </p>
+ * <pre>
+ *   &lt;map:matcher name="i18n" src="org.apache.cocoon.matching.LocaleMatcher"&gt;
+ *     &lt;locale-attribute&gt;locale&lt;/locale-attribute&gt;
+ *     &lt;negotiate&gt;false&lt;/negotiate&gt;
+ *     &lt;use-locale&gt;true&lt;/use-locale&gt;
+ *     &lt;use-locales&gt;false&lt;/use-locales&gt;
+ *     &lt;use-blank-locale&gt;true&lt;/use-blank-locale&gt;
+ *     &lt;default-locale language="en" country="US"/&gt;
+ *     &lt;store-in-request&gt;false&lt;store-in-request&gt;
+ *     &lt;create-session&gt;false&lt;create-session&gt;
+ *     &lt;store-in-session&gt;false&lt;store-in-session&gt;
+ *     &lt;store-in-cookie&gt;false&lt;store-in-cookie&gt;
+ *   &lt;/map:matcher&gt;
+ * </pre>
+ *
+ * <p>Above configuration parameters mean:
+ *   <ul>
+ *     <li><b>locale-attribute</b> specifies the name of the request
+ *     parameter / session attribute / cookie that is to be used as a locale
+ *     (defaults to <code>locale</code>)</li>
+ *     <li><b>negotiate</b> specifies whether matcher should check that
+ *     resource exists. If set to true, matcher will look for the locale
+ *     till matching resource is found. If no resource found even with
+ *     default or blank locale, matcher will not match.</li>
+ *     <li><b>use-locale</b> specifies whether the primary locale provided
+ *     by the user agent (or server default, is no locale passed by the agent)
+ *     is to be used</li>
+ *     <li><b>use-locales</b> specifies whether each locale provided by the
+ *     user agent should be tested in turn (makes sense only when
+ *     <code>negotiate</code> is set to <code>true</code>)</li>
+ *     <li><b>default-locale</b> specifies the default locale to be used when
+ *     none matches any of the previous ones.</li>
+ *     <li><b>use-blank-locale</b> specifies whether a file should be looked
+ *     for without a locale in its filename or filepath (e.g. after looking
+ *     for index.en.html, try index.html) if none matches any of the previous
+ *     locales.</li>
+ *     <li><b>store-in-request</b> specifies whether found locale should be
+ *     stored as request attribute.</li>
+ *     <li><b>create-session</b> specifies whether session should be created
+ *     when storing found locale as session attribute.</li>
+ *     <li><b>store-in-session</b> specifies whether found locale should be
+ *     stored as session attribute.</li>
+ *     <li><b>store-in-cookie</b> specifies whether found locale should be
+ *     stored as cookie.</li>
+ *   </ul>
+ * </p>
+ *
+ * <h1>Usage</h1>
+ * <p>This matcher will be used in a pipeline like so:</p>
+ * <pre>
+ *   &lt;map:match pattern="*.html"&gt;
+ *     &lt;map:match type="i18n" pattern="xml/{1}.*.xml"&gt;
+ *       &lt;map:generate src="{source}"/&gt;
+ *       ...
+ *     &lt;/map:match&gt;
+ *   &lt;/map:match&gt;
+ * </pre>
+ * <p><code>*</code> in the pattern identifies the place where locale should
+ * be inserted. In case of a blank locale, if character before and after
+ * <code>*</code> is the same (like in example above), duplicate will
+ * be removed (<code>xml/{1}.*.xml</code> becomes <code>xml/{1}.xml</code>).</p>
+ *
+ * <h1>Locale Identification</h1>
+ * <p>Locales will be tested in following order:</p>
+ * <ul>
+ *   <li>Locale provided as a request parameter</li>
+ *   <li>Locale provided as a session attribute</li>
+ *   <li>Locale provided as a cookie</li>
+ *   <li>Locale provided using a sitemap parameter<br>
+ *   (&lt;map:parameter name="locale" value="{1}"/&gt; style parameter within
+ *   the &lt;map:match&gt; node)</li>
+ *   <li>Locale provided by the user agent, or server default,
+ *   if <code>use-locale</code> is set to <code>true</code></li>
+ *   <li>Locales provided by the user agent, if <code>use-locales</code>
+ *   is set to <code>true</code>.</li>
+ *   <li>The default locale, if specified in the matcher's configuration</li>
+ *   <li>Resources with no defined locale (blank locale)</li>
+ * </ul>
+ * <p>If <code>negotiate</code> mode is set to <code>true</code>, a source will
+ * be looked up using each locale. Where the full locale (language, country,
+ * variant) doesn't match, it will fall back first to language and country,
+ * and then just language, before moving on to the next locale.</p>
+ * <p>If <code>negotiate</code> mode is set to <code>false</code> (default),
+ * first found locale will be returned.</p>
+ *
+ * <h1>Sitemap Variables</h1>
+ * <p>Once a matching locale has been found, the following sitemap variables
+ * will be available to sitemap elements contained within the matcher:</p>
+ * <ul>
+ *   <li>{source}: The URI of the source that matched</li>
+ *   <li>{locale}: The locale that matched that resource</li>
+ *   <li>{matched-locale}: The part of the locale that matched the resource</li>
+ *   <li>{language}: The language of the matching resource</li>
+ *   <li>{country}: The country of the matching resource</li>
+ *   <li>{variant}: The variant of the matching resource</li>
+ * </ul>
+ *
+ * @since 2.1.6
+ * @author <a href="mailto:uv@upaya.co.uk">Upayavira</a>
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: LocaleMatcher.java 264801 2005-08-30 15:57:49Z vgritsenko $
+ */
+public class LocaleMatcher extends AbstractLogEnabled
+                           implements Matcher, ThreadSafe, Serviceable, Configurable, Disposable {
+
+    private static final String DEFAULT_LOCALE_ATTRIBUTE = "locale";
+    private static final String DEFAULT_DEFAULT_LANG = "en";
+    private static final String DEFAULT_DEFAULT_COUNTRY = "US";
+    private static final String DEFAULT_DEFAULT_VARIANT = "";
+
+    private ServiceManager manager;
+    private SourceResolver resolver;
+
+    /**
+     * Name of the locale request parameter, session attribute, cookie.
+     */
+    private String localeAttribute;
+
+    /**
+     * Whether to query locale provided by the user agent or not.
+     */
+    private boolean useLocale;
+
+    private boolean useLocales;
+    private Locale defaultLocale;
+    private boolean useBlankLocale;
+    private boolean testResourceExists;
+
+    /**
+     * Store the locale in request. Default is not to do this.
+     */
+    private boolean storeInRequest;
+
+    /**
+     * Store the locale in session, if available. Default is not to do this.
+     */
+    private boolean storeInSession;
+
+    /**
+     * Should we create a session if needed. Default is not to do this.
+     */
+    private boolean createSession;
+
+    /**
+     * Should we add a cookie with the locale. Default is not to do this.
+     */
+    private boolean storeInCookie;
+
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+    }
+
+    public void configure(Configuration config) {
+        this.storeInRequest = config.getChild("store-in-request").getValueAsBoolean(false);
+        this.createSession = config.getChild("create-session").getValueAsBoolean(false);
+        this.storeInSession = config.getChild("store-in-session").getValueAsBoolean(false);
+        this.storeInCookie = config.getChild("store-in-cookie").getValueAsBoolean(false);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug((this.storeInRequest ? "will" : "won't") + " set values in request");
+            getLogger().debug((this.createSession ? "will" : "won't") + " create session");
+            getLogger().debug((this.storeInSession ? "will" : "won't") + " set values in session");
+            getLogger().debug((this.storeInCookie ? "will" : "won't") + " set values in cookies");
+        }
+
+        this.localeAttribute = config.getChild("locale-attribute").getValue(DEFAULT_LOCALE_ATTRIBUTE);
+        this.testResourceExists = config.getChild("negotiate").getValueAsBoolean(false);
+
+        this.useLocale = config.getChild("use-locale").getValueAsBoolean(true);
+        this.useLocales = config.getChild("use-locales").getValueAsBoolean(false);
+        this.useBlankLocale = config.getChild("use-blank-locale").getValueAsBoolean(true);
+
+        Configuration child = config.getChild("default-locale", false);
+        if (child != null) {
+            this.defaultLocale = new Locale(child.getAttribute("language", DEFAULT_DEFAULT_LANG),
+                                            child.getAttribute("country", DEFAULT_DEFAULT_COUNTRY),
+                                            child.getAttribute("variant", DEFAULT_DEFAULT_VARIANT));
+        }
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Locale attribute name is " + this.localeAttribute);
+            getLogger().debug((this.testResourceExists ? "will" : "won't") + " negotiate locale");
+            getLogger().debug((this.useLocale ? "will" : "won't") + " use request locale");
+            getLogger().debug((this.useLocales ? "will" : "won't") + " use request locales");
+            getLogger().debug((this.useBlankLocale ? "will" : "won't") + " blank locales");
+            getLogger().debug("default locale " + this.defaultLocale);
+        }
+    }
+
+    public void dispose() {
+        this.manager.release(this.resolver);
+        this.resolver = null;
+        this.manager = null;
+    }
+
+
+    public Map match(final String pattern, Map objectModel, Parameters parameters)
+    throws PatternException {
+        final Map map = new HashMap();
+
+        I18nUtils.LocaleValidator validator = new I18nUtils.LocaleValidator() {
+            public boolean test(String name, Locale locale) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Testing " + name + " locale: '" + locale + "'");
+                }
+                return isValidResource(pattern, locale, map);
+            }
+        };
+
+        Locale locale = I18nUtils.findLocale(objectModel,
+                                             localeAttribute,
+                                             parameters,
+                                             defaultLocale,
+                                             useLocale,
+                                             useLocales,
+                                             useBlankLocale,
+                                             validator);
+
+        if (locale == null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("No locale found for resource: " + pattern);
+            }
+            return null;
+        }
+
+        String localeStr = locale.toString();
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Locale " + localeStr + " found for resource: " + pattern);
+        }
+
+        I18nUtils.storeLocale(objectModel,
+                              localeAttribute,
+                              localeStr,
+                              storeInRequest,
+                              storeInSession,
+                              storeInCookie,
+                              createSession);
+
+        return map;
+    }
+
+    private boolean isValidResource(String pattern, Locale locale, Map map) {
+        Locale testLocale;
+
+        // Test "language, country, variant" locale
+        if (locale.getVariant().length() > 0) {
+            if (isValidResource(pattern, locale, locale, map)) {
+                return true;
+            }
+        }
+
+        // Test "language, country" locale
+        if (locale.getCountry().length() > 0) {
+            testLocale = new Locale(locale.getLanguage(), locale.getCountry());
+            if (isValidResource(pattern, locale, testLocale, map)) {
+                return true;
+            }
+        }
+
+        // Test "language" locale (or empty - if language is "")
+        testLocale = new Locale(locale.getLanguage(), "");
+        if (isValidResource(pattern, locale, testLocale, map)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    private boolean isValidResource(String pattern, Locale locale, Locale testLocale, Map map) {
+        String url;
+
+        String testLocaleStr = testLocale.toString();
+        if ("".equals(testLocaleStr)) {
+            // If same character found before and after the '*', leave only one.
+            int starPos = pattern.indexOf("*");
+            if (starPos < pattern.length() - 1 && starPos > 1 &&
+                    pattern.charAt(starPos - 1) == pattern.charAt(starPos + 1)) {
+                url = pattern.substring(0, starPos - 1) + pattern.substring(starPos + 1);
+            } else {
+                url = StringUtils.replace(pattern, "*", "");
+            }
+        } else {
+            url = StringUtils.replace(pattern, "*", testLocaleStr);
+        }
+
+        boolean result = true;
+        if (testResourceExists) {
+            Source source = null;
+            try {
+                source = resolver.resolveURI(url);
+                result = source.exists();
+            } catch (IOException e) {
+                result = false;
+            } finally {
+                if (source != null) {
+                    resolver.release(source);
+                }
+            }
+        }
+
+        if (result) {
+            map.put("source", url);
+            map.put("matched-locale", testLocaleStr);
+            if (locale != null) {
+                map.put("locale", locale.toString());
+                map.put("language", locale.getLanguage());
+                map.put("country", locale.getCountry());
+                map.put("variant", locale.getVariant());
+            }
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/LocaleMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/Matcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/Matcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/Matcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/Matcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.sitemap.PatternException;
+
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @version CVS $Id: Matcher.java 55389 2004-10-23 15:46:58Z cziegeler $
+ */
+public interface Matcher {
+
+    String ROLE = Matcher.class.getName();
+
+    /**
+     * Matches the pattern against some <code>Request</code> values
+     * and returns a <code>Map</code> object with replacements
+     * for wildcards contained in the pattern.
+     * @param pattern     The pattern to match against. Depending on the
+     *                    implementation the pattern can contain wildcards
+     *                    or regular expressions.
+     * @param objectModel The <code>Map</code> with object of the
+     *                    calling environment which can be used
+     *                    to select values this matchers matches against.
+     * @return Map        The returned <code>Map</code> object with
+     *                    replacements for wildcards/regular-expressions
+     *                    contained in the pattern.
+     *                    If the return value is null there was no match.
+     */
+    Map match (String pattern, Map objectModel, Parameters parameters) throws PatternException;
+}
+
+
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/Matcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/MountTableMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/MountTableMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/MountTableMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/MountTableMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,214 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import org.apache.cocoon.components.source.SourceUtil;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.sitemap.PatternException;
+
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * A matcher that manages a "mount table", allowing to add subsitemaps to a Cocoon application without
+ * modifying the main sitemap. This is especially useful for prototypes and demos where installing
+ * a separate instance of Cocoon is overkill.
+ * <p>
+ * The mount table is an xml file which has a format similar to the <code>map:mount</code> syntax:
+ * <pre>
+ *   &lt;mount-table&gt;
+ *     &lt;mount uri-prefix="foo" src="file://path/to/foo/directory/"/&gt;
+ *     &lt;mount uri-prefix="bar/baz" src="file://path/to/bar-baz/directory/"/&gt;
+ *   &lt;/mount-table&gt;
+ * </pre>
+ * The matcher will scan the mount table for an "uri-prefix" value matching the beginning of the current
+ * request URI, and if found, succeed and populate the "src" and "uri-prefix" sitemap variables.
+ * <p>
+ * Usage in the sitemap is therefore as follows:
+ * <pre>
+ *   &lt;map:match type="mount-table" pattern="path/to/mount-table.xml"&gt;
+ *     &lt;map:mount uri-prefix="{uri-prefix}" src="{src}"/&gt;
+ *   &lt;/map:match&gt;
+ * </pre>
+ * <p>
+ * This matcher accepts a single configuration parameter, indicating if missing mount tables should be
+ * silently ignored (defaults is <code>false</code>, meaning "don't ignore"):
+ * <pre>
+ *   &lt;map:matcher type="mount-table" src="org.apache.cocoon.matching.MountTableMatcher"&gt;
+ *     &lt;map:parameter name="ignore-missing-tables" value="true"/&gt;
+ *   &lt;/map:matcher&gt;
+ * </pre>
+ * <p>
+ * This configuration is used in the main sitemap of Cocoon samples, to allow users to define their own mount
+ * table, but not fail if it does not exist.
+ *
+ * @author <a href="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
+ * @version $Id: MountTableMatcher.java 219491 2005-07-18 13:58:20Z bdelacretaz $
+ */
+public class MountTableMatcher extends AbstractLogEnabled
+                               implements Matcher, ThreadSafe, Serviceable, Parameterizable {
+
+    private ServiceManager manager;
+    private SourceResolver resolver;
+    private Map mountTables = Collections.synchronizedMap(new HashMap());
+    private boolean ignoreMissingTables;
+
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+    }
+
+    public void parameterize(Parameters params) throws ParameterException {
+        this.ignoreMissingTables = params.getParameterAsBoolean("ignore-missing-tables", false);
+    }
+
+    private Map getMountTable(String src) throws Exception {
+        Source source = null;
+        try {
+            source = this.resolver.resolveURI(src);
+            final String uri = source.getURI();
+
+            // Check if source exists
+            // FIXME: source.exists() returns true in the case of an OSGI bundle uri,
+            // For example if uri=bundle://11/../mount-table.xml, exists() returns true
+            // but the Source is unusable
+            if (!source.exists()) {
+                if (this.ignoreMissingTables) {
+                    return Collections.EMPTY_MAP;
+                } else {
+                    throw new PatternException("Mount table does not exist: '" + uri + "'");
+                }
+            }
+
+            // Source exists
+            Object[] values = (Object[]) this.mountTables.get(uri);
+            if (values != null) {
+                // Check validity
+                SourceValidity oldValidity = (SourceValidity) values[1];
+
+                int valid = oldValidity != null ? oldValidity.isValid() : SourceValidity.INVALID;
+                if (valid == SourceValidity.VALID) {
+                    // Valid without needing the new validity
+                    return (Map) values[0];
+                }
+
+                if (valid == SourceValidity.UNKNOWN &&
+                        oldValidity.isValid(source.getValidity()) == SourceValidity.VALID) {
+                    // Valid after comparing with the new validity
+                    return (Map) values[0];
+                }
+
+                // Invalid: fallback below to read the mount table
+            } else {
+                values = new Object[2];
+            }
+
+            // Read the mount table
+            Map mounts = new HashMap();
+            DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+            Configuration config = builder.build(SourceUtil.getInputSource(source));
+
+            Configuration[] children = config.getChildren();
+            for (int i = 0; i < children.length; i++) {
+                Configuration child = children[i];
+                if ("mount".equals(child.getName())) {
+                    String prefix = children[i].getAttribute("uri-prefix");
+                    // Append a '/' at the end of a not-empty prefix
+                    // this avoids flat uri matching which would cause
+                    // exceptions in the sub sitemap!
+                    if (!prefix.endsWith("/") && prefix.length() != 0) {
+                        prefix = prefix + '/';
+                    }
+                    mounts.put(prefix, children[i].getAttribute("src"));
+                } else {
+                    throw new PatternException(
+                        "Unexpected element '" + child.getName() + "' (awaiting 'mount'), at " + child.getLocation());
+                }
+            }
+            values[0] = mounts;
+            values[1] = source.getValidity();
+
+            // Cache it with the source validity
+            this.mountTables.put(uri, values);
+
+            return mounts;
+
+        } catch (SecurityException e) {
+            if (this.ignoreMissingTables) {
+                return Collections.EMPTY_MAP;
+            } else {
+                throw new PatternException("Mount table is not accessible: '" + src + "' (" + e + ")");
+            }
+
+        } finally {
+            if (source != null) {
+                this.resolver.release(source);
+            }
+        }
+    }
+
+    public Map match(String pattern, Map objectModel, Parameters parameters) throws PatternException {
+        Map mounts;
+        try {
+            mounts = getMountTable(pattern);
+        } catch (PatternException pe) {
+            throw pe;
+        } catch (Exception e) {
+            throw new PatternException(e);
+        }
+
+        // Get the request URI
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        String uri = request.getSitemapURI();
+
+        // and search for a matching prefix
+        Iterator iter = mounts.entrySet().iterator();
+        while (iter.hasNext()) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String prefix = (String) entry.getKey();
+            if (uri.startsWith(prefix)) {
+                // Found it
+                Map result = new HashMap(2);
+                result.put("uri-prefix", prefix);
+                result.put("src", entry.getValue());
+
+                // Return immediately
+                return result;
+            }
+        }
+
+        // Not found
+        return null;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/MountTableMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/ParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/ParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/ParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/ParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class allows for matching based on a parameter provided from the sitemap.
+ * If the specified sitemap parameter exists, its value is retrieved for later
+ * sitemap substitution.
+ *
+ * <p><b>Example:</b></p>
+ * <pre>
+ * &lt;map:match type="parameter" pattern="dest"&gt;
+ *     &lt;map:redirect-to uri="{1}"/&gt;
+ * &lt;/map:match&gt;
+ * </pre>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: ParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class ParameterMatcher implements Matcher, ThreadSafe
+{
+    /**
+     * Match method to see if the sitemap parameter exists. If it does
+     * have a value the parameter added to the array list for later
+     * sitemap substitution.
+     *
+     * @param pattern name of sitemap parameter to find
+     * @param objectModel environment passed through via cocoon
+     * @return null or map containing value of sitemap parameter 'pattern'
+     */
+    public Map match(String pattern, Map objectModel, Parameters parameters) {
+
+        String parameter = parameters.getParameter(pattern, null);
+        if (parameter == null) {
+            return null; // no parameter defined
+        } else {
+            Map map = new HashMap();
+            map.put("1", parameter);
+            return map; // parameter defined, return map
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/ParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/PreparableMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/PreparableMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/PreparableMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/PreparableMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.sitemap.PatternException;
+
+import java.util.Map;
+
+/**
+ * A matcher that can prepare patterns during sitemap setup for faster match at request time.
+ * This is also a regular matcher, meaning the sitemap can decide either to prepare the pattern
+ * or to match with a request-time evaluated pattern (for {..} substitution).
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: PreparableMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public interface PreparableMatcher extends Matcher {
+
+    /**
+     * Prepares a pattern in a form that allows faster match. For example, a regular
+     * expression matcher can precompile the expression and return the corresponding
+     * object. This method is called once for each pattern used with a particular matcher
+     * class. The returned value is then passed back as the <code>preparedPattern</code>
+     * parameter of {@link #preparedMatch(Object, Map, Parameters)}.
+     *
+     * @param pattern The pattern to prepare. Depending on the implementation the pattern
+     *                can contain wildcards or regular expressions.
+     * @return an optimized representation of the pattern.
+     * @throws PatternException if the pattern couldn't be prepared.
+     */
+    Object preparePattern(String pattern) throws PatternException;
+
+    /**
+     * Matches the prepared pattern against some values in the object model (most often the
+     * <code>Request</code>) and returns a <code>Map</code> object with replacements
+     * for wildcards contained in the pattern.
+     *
+     * @param preparedPattern The preparedPattern to match against, as returned by {@link #preparePattern(String)}.
+     * @param objectModel     The <code>Map</code> with objects of the calling environment
+     *                        which can be used to select values this matchers matches against.
+     * @return                a <code>Map</code> object with replacements for wildcards/regular-expressions
+     *                        contained in the pattern. If the return value is null there was no match.
+     */
+    Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters) throws PatternException;
+}
+
+
+

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/PreparableMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request header (e.g. "referer") against a regular expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>header-name</code></td><td>Name of the request header to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RegexpHeaderMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public class RegexpHeaderMatcher extends AbstractRegexpMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+
+        this.defaultParam = config.getChild("header-name").getValue(null);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("header-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No header name given. FAILING");
+            return null;
+        }
+
+        String result = ObjectModelHelper.getRequest(objectModel).getHeader(paramName);
+        if (result == null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Header '" + paramName + "' not set.");
+            }
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHeaderMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHostMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHostMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHostMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHostMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,36 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import java.util.Map;
+
+/**
+ * Matches the target host ("Host" request header) against a regular expression.
+ *
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: RegexpHostMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpHostMatcher extends AbstractRegexpMatcher
+{
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+        return ObjectModelHelper.getRequest(objectModel).getHeader("Host");
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpHostMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import java.util.Map;
+
+/**
+ * Matches a sitemap parameter against a regular expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>parameter-name</code></td><td>Name of the sitemap parameter to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RegexpParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpParameterMatcher extends AbstractRegexpMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("parameter-name").getValue(null);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("parameter-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No parameter name given. FAILING");
+            return null;
+        }
+
+        String result = parameters.getParameter(paramName, null);
+        if (result == null) {
+            getLogger().debug("Parameter '" + paramName + "' not set.");
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request attribute against a regular expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <tableborder="1">
+ * <tr><td><code>attribute-name</code></td><td>String identifying the request attribute</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RegexpRequestAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpRequestAttributeMatcher extends AbstractRegexpMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("attribute-name").getValue(null);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'");
+        }
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("attribute-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No attribute name given. FAILING");
+            return null;
+        }
+
+        Object result = ObjectModelHelper.getRequest(objectModel).getAttribute(paramName);
+        if (result == null) {
+            getLogger().debug("Request attribute '" + paramName + "' not set.");
+            return null;
+        }
+
+        return result.toString();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request parameter against a regular expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RegexpRequestParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpRequestParameterMatcher extends AbstractRegexpMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("parameter-name").getValue(null);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("parameter-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No parameter name given. FAILING");
+            return null;
+        }
+
+        String result = ObjectModelHelper.getRequest(objectModel).getParameter(paramName);
+        if (result == null) {
+            getLogger().debug("Parameter '" + paramName + "' not set.");
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpRequestParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a session attribute against a regular expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <tableborder="1">
+ * <tr><td><code>attribute-name</code></td><td>String identifying the session attribute</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RegexpSessionAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpSessionAttributeMatcher extends AbstractRegexpMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("attribute-name").getValue(null);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'");
+        }
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("attribute-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No attribute name given. FAILING");
+            return null;
+        }
+
+        Object result = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName);
+        if (result == null) {
+            getLogger().debug("Session attribute '" + paramName + "' not set.");
+            return null;
+        }
+
+        return result.toString();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpSessionAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpURIMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpURIMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpURIMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpURIMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,43 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches the request URIs against a regular expression pattern.
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: RegexpURIMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RegexpURIMatcher extends AbstractRegexpMatcher
+{
+    /**
+     * Return the request URI.
+     */
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+        String uri = ObjectModelHelper.getRequest(objectModel).getSitemapURI();
+
+        if (uri.startsWith("/")) {
+            uri = uri.substring(1);
+        }
+
+        return uri;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RegexpURIMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class allows for matching based on a request attribute.
+ * If the specified request attribute exists, its string representation
+ * is retrieved for later sitemap substitution.
+ *
+ * <p><b>Example:</b></p>
+ * <pre>
+ * &lt;map:match type="request-attribute" pattern="next"&gt;
+ *     &lt;map:redirect-to src="{1}"/&gt;
+ * &lt;/map:match&gt;
+ * </pre>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RequestAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RequestAttributeMatcher implements Matcher, ThreadSafe
+{
+    /**
+     * Match method to see if the request attribute exists. If it does
+     * have a value the string represenation of attribute is added to
+     * the array list for later sitemap substitution.
+     *
+     * @param pattern name of request attribute to find
+     * @param objectModel environment passed through via cocoon
+     * @return null or map containing value of request attribute 'pattern'
+     */
+    public Map match(String pattern, Map objectModel, Parameters parameters) {
+
+        Object attribute = ObjectModelHelper.getRequest(objectModel).getAttribute(pattern);
+
+        if (attribute == null) {
+            return null;
+        } else {
+            Map map = new HashMap();
+            map.put("1", attribute.toString());
+            return map;
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class allows for matching based on a request parameter.
+ * If the specified request parameter exists, its value is retrieved for later
+ * sitemap substitution.
+ *
+ * <p><b>Example:</b></p>
+ * <pre>
+ * &lt;map:match type="request" pattern="dest"&gt;
+ *     &lt;map:redirect-to uri="{1}"/&gt;
+ * &lt;/map:match&gt;
+ * </pre>
+ *
+ * @author <a href="mailto:Marcus.Crafter@osa.de">Marcus Crafter</a>
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: RequestParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class RequestParameterMatcher implements Matcher, ThreadSafe
+{
+    /**
+     * Match method to see if the request parameter exists. If it does
+     * have a value the parameter is added to the array list for later
+     * sitemap substitution.
+     *
+     * @param pattern name of request parameter to find
+     * @param objectModel environment passed through via cocoon
+     * @return null or map containing value of request parameter 'pattern'
+     */
+    public Map match(String pattern, Map objectModel, Parameters parameters) {
+        Request request = ObjectModelHelper.getRequest(objectModel);
+
+        String parameter = request.getParameter(pattern);
+        if (parameter == null) {
+            return null; // no parameter defined
+        } else {
+            Map map = new HashMap();
+            map.put("1", parameter);
+            return map; // parameter defined, return map
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/RequestParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/SessionAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/SessionAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/SessionAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/SessionAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This class allows for matching based on a session attribute.
+ * If the specified session attribute exists, its string representation
+ * is retrieved for later sitemap substitution.
+ *
+ * <p><b>Example:</b></p>
+ * <pre>
+ * &lt;map:match type="session-attribute" pattern="style"&gt;
+ *     &lt;map:read src="{1}"/&gt;
+ * &lt;/map:match&gt;
+ * </pre>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: SessionAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class SessionAttributeMatcher implements Matcher, ThreadSafe
+{
+    /**
+     * Match method to see if the request attribute exists. If it does
+     * have a value the string represenation of attribute is added to
+     * the array list for later sitemap substitution.
+     *
+     * @param pattern name of session attribute to find
+     * @param objectModel environment passed through via cocoon
+     * @return null or map containing value of session attribute 'pattern'
+     */
+    public Map match(String pattern, Map objectModel, Parameters parameters) {
+
+        Object attribute = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(pattern);
+        if (attribute == null) {
+            return null;
+        } else {
+            Map map = new HashMap();
+            map.put("1", attribute.toString());
+            return map;
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/SessionAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request header (e.g. "referer") against a wildcard expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>header-name</code></td><td>Name of the request header to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: WildcardHeaderMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardHeaderMatcher extends AbstractWildcardMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        // Check old name
+        this.defaultParam = config.getChild("parameter-name").getValue(null);
+        if (defaultParam != null) {
+            getLogger().warn("'parameter-name' is deprecated. Please use 'header-name'");
+        }
+        // Load with new one
+        this.defaultParam = config.getChild("header-name").getValue(this.defaultParam);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        // Check old name
+        String paramName = parameters.getParameter("parameter-name", null);
+        if (paramName != null) {
+            getLogger().warn("'parameter-name' is deprecated. Please use 'header-name'");
+        } else {
+            paramName = this.defaultParam;
+        }
+
+        // Load with new one.
+        paramName = parameters.getParameter("header-name", paramName);
+
+        if (paramName == null) {
+            getLogger().warn("No header name given. FAILING");
+            return null;
+        }
+
+        String result = ObjectModelHelper.getRequest(objectModel).getHeader(paramName);
+        if (result == null) {
+            getLogger().debug("Header '" + paramName + "' not set.");
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHeaderMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHostMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHostMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHostMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHostMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,37 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.environment.ObjectModelHelper;
+import java.util.Map;
+
+/**
+ * Matches the target host ("Host" request header) against a wildcard expression.
+ *
+ * @author <a href="mailto:Giacomo.Pati@pwr.ch">Giacomo Pati</a>
+ * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
+ * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: WildcardHostMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardHostMatcher extends AbstractWildcardMatcher
+{
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+        return ObjectModelHelper.getRequest(objectModel).getHeader("Host");
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardHostMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import java.util.Map;
+
+/**
+ * Matches a sitemap parameter against a wildcard expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>parameter-name</code></td><td>Name of the sitemap parameter to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: WildcardParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardParameterMatcher extends AbstractWildcardMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("parameter-name").getValue(null);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("parameter-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No parameter name given. FAILING");
+            return null;
+        }
+
+        String value = parameters.getParameter(paramName, null);
+        if (value == null) {
+            getLogger().debug("Parameter '" + paramName + "' not set.");
+        }
+
+        return value;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,68 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request attribute against a wildcard expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <tableborder="1">
+ * <tr><td><code>attribute-name</code></td><td>String identifying the request attribute</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: WildcardRequestAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardRequestAttributeMatcher extends AbstractWildcardMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("attribute-name").getValue(null);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'");
+        }
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("attribute-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No attribute name given. FAILING");
+            return null;
+        }
+
+        Object result = ObjectModelHelper.getRequest(objectModel).getAttribute(paramName);
+        if (result == null) {
+            getLogger().debug("Request attribute '" + paramName + "' not set.");
+            return null;
+        }
+
+        return result.toString();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,65 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a request parameter against a wildcard expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <table border="1">
+ * <tr><td><code>parameter-name</code></td><td>Name of the request parameter to
+ * match against</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
+ * @version CVS $Id: WildcardRequestParameterMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardRequestParameterMatcher extends AbstractWildcardMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("parameter-name").getValue(null);
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("parameter-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No parameter name given. FAILING");
+            return null;
+        }
+
+        String result = ObjectModelHelper.getRequest(objectModel).getParameter(paramName);
+        if (result == null) {
+            getLogger().debug("Parameter '" + paramName + "' not set.");
+        }
+
+        return result;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardRequestParameterMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.matching;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.util.Map;
+
+/**
+ * Matches a session attribute against a wildcard expression.
+ *
+ * <p><b>Global and local configuration</b></p>
+ * <tableborder="1">
+ * <tr><td><code>attribute-name</code></td><td>String identifying the session attribute</td></tr>
+ * </table>
+ *
+ * @author <a href="mailto:haul@apache.org">Christian Haul</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: WildcardSessionAttributeMatcher.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class WildcardSessionAttributeMatcher extends AbstractWildcardMatcher
+    implements Configurable
+{
+    private String defaultParam;
+
+    public void configure(Configuration config) throws ConfigurationException {
+        this.defaultParam = config.getChild("attribute-name").getValue(null);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'");
+        }
+    }
+
+    protected String getMatchString(Map objectModel, Parameters parameters) {
+
+        String paramName = parameters.getParameter("attribute-name", this.defaultParam);
+        if (paramName == null) {
+            getLogger().warn("No attribute name given. FAILING");
+            return null;
+        }
+
+        Object result = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName);
+        if (result == null) {
+            getLogger().debug("Session attribute '" + paramName + "' not set.");
+            return null;
+        }
+
+        return result.toString();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/matching/WildcardSessionAttributeMatcher.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message