cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <d...@yahoo.com>
Subject Re: [C2] RequestParamMatcher source
Date Tue, 15 May 2001 11:45:26 GMT
Marcus,
Checked in. Can you please check if all's well.

Thanks,
dims

--- Marcus Crafter <crafterm@fztig938.bank.dresdner.net> wrote:
> Hi All,
> 	
> 	Hope all is well around the globe.
> 
> 	I've just updated my RequestParamMatcher class, and thought I
> 	would send it around just in case anyone else finds it useful.
> 	
> 	Its a simple matcher, which matches a given request parameter, and if
> 	existing, adds the given request parameter's value to the sitemap
> 	listOfMaps, for later use/subsitution.
> 
> 	Here's one simple example:
> 
> 	<map:match type="request" pattern="dest">
> 	    <map:redirect-to uri="{1}"/>
> 	</map:match>
> 
> 	This example matches the request parameter 'dest', and if it exists,
> 	redirects the client to the value specified by the dest parameter
> 	itself.
> 
> 	in sitemap:
> 
> 	<map:matcher name="request"
> 		src="org.apache.cocoon.matching.RequestParamMatcher"/>
> 
> 	If anyone has a good name to use instead of the {1} feel free to
> 	suggest it. I'm happy to change it to something more legible :-)
> 
> 	Cheers,
> 
> 	Marcus
> 
> -- 
>         .....
>      ,,$$$$$$$$$,      Marcus Crafter
>     ;$'      '$$$$:    Computer Systems Engineer
>     $:         $$$$:   Open Software Associates GmbH
>      $       o_)$$$:   82-84 Mainzer Landstrasse
>      ;$,    _/\ &&:'   60327 Frankfurt Germany
>        '     /( &&&
>            \_&&&&'     Email : Marcus.Crafter@osa.de
>           &&&&.        Business Hours : +49 69 9757 200
>     &&&&&&&:           After Hours    : +49 69 49086750
> > /*****************************************************************************
>  * 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:Marcus.Crafter@osa.de">Marcus Crafter</a>
>  * @version CVS $Revision:$
>  */
> 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
>         }
>     }
> }
> > ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org


=====
Davanum Srinivas, JNI-FAQ Manager
http://www.jGuru.com/faq/JNI

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message