dims 01/05/15 04:34:26
Modified: webapp sitemap.xmap
Added: src/org/apache/cocoon/matching RequestParamMatcher.java
Log:
RequestParamMatcher contribution from Marcus Crafter ([EMAIL PROTECTED])
Revision Changes Path
1.1
xml-cocoon2/src/org/apache/cocoon/matching/RequestParamMatcher.java
Index: RequestParamMatcher.java
===================================================================
/*****************************************************************************
* Copyright (C) The Apache Software Foundation. All rights reserved. *
* ------------------------------------------------------------------------- *
* This software is published under the terms of the Apache Software License *
* version 1.1, a copy of which has been included with this distribution in *
* the LICENSE file. *
*****************************************************************************/
/*
* Package definition
*/
package org.apache.cocoon.matching;
/*
* Standard imports
*/
import java.util.*;
import org.apache.cocoon.matching.Matcher;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.Constants;
/**
* This class allows for matching based on a request parameter.
* If the specified request parameter exists, its value is retrieved for later
* xpath substitution.
*
* Example:
*
* <map:match type="request" pattern="dest">
* <map:redirect-to uri="{1}"/>
* </map:match>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Marcus Crafter</a>
* @version CVS $Revision: 1.1 $
*/
public class RequestParamMatcher implements Matcher {
/**
* 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
* substitution with a xpath attribute.
*
* @param pattern name of request parameter to find
* @param objectModel environment passed through via cocoon
* @returns null or map containing value of request parameter 'pattern'
*/
public Map match(String pattern, Map objectModel) {
Request request =
(Request) objectModel.get(Constants.REQUEST_OBJECT);
String param = request.getParameter(pattern);
if (param == null)
return null; // no parameter defined
else {
Map map = new HashMap();
map.put(Integer.toString(1), param);
return map; // parameter defined, return map
}
}
}
1.3 +2 -1 xml-cocoon2/webapp/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/sitemap.xmap,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sitemap.xmap 2001/05/11 11:00:52 1.2
+++ sitemap.xmap 2001/05/15 11:34:24 1.3
@@ -89,8 +89,9 @@
</map:selectors>
<map:matchers default="wildcard">
- <map:matcher name="wildcard"
factory="org.apache.cocoon.matching.WildcardURIMatcherFactory"/>
+ <map:matcher name="wildcard"
factory="org.apache.cocoon.matching.WildcardURIMatcherFactory"/>
<map:matcher name="regexp"
factory="org.apache.cocoon.matching.RegexpURIMatcherFactory"/>
+ <map:matcher name="request"
src="org.apache.cocoon.matching.RequestParamMatcher"/>
</map:matchers>
<map:actions>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]