KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > ajax > AjaxRequestMatcher


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.ajax;
17
18 import java.util.Collections JavaDoc;
19 import java.util.Map JavaDoc;
20
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.avalon.framework.thread.ThreadSafe;
23 import org.apache.cocoon.environment.ObjectModelHelper;
24 import org.apache.cocoon.environment.Request;
25 import org.apache.cocoon.matching.Matcher;
26 import org.apache.cocoon.sitemap.PatternException;
27
28 /**
29  * A matcher that tests if the current request is an Ajax request. This matcher
30  * provides no sitemap variables.
31  * <p>
32  * Example:
33  * <pre>
34  * &lt;map:match type="ajax-request"&gt;
35  * ... ajax request ...
36  * &lt;/map:match&gt;
37  * </pre>
38  *
39  * @since 2.1.8
40  * @version $Id: AjaxRequestMatcher.java 292158 2005-09-28 10:24:51Z sylvain $
41  */

42 public class AjaxRequestMatcher implements Matcher, ThreadSafe {
43
44     public Map JavaDoc match(String JavaDoc pattern, Map JavaDoc objectModel, Parameters parameters) throws PatternException {
45         Request req = ObjectModelHelper.getRequest(objectModel);
46         
47         return AjaxHelper.isAjaxRequest(req) ? Collections.EMPTY_MAP : null;
48     }
49 }
50
Popular Tags