KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > core > urls > URLRewriter


1 /*
2  * Copyright 2004 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  * $Header:$
17  */

18 package org.apache.beehive.netui.core.urls;
19
20 import javax.servlet.ServletContext JavaDoc;
21 import javax.servlet.ServletRequest JavaDoc;
22 import javax.servlet.ServletResponse JavaDoc;
23
24
25 /**
26  * Offers methods for rewriting URLs/query parameters.
27  */

28 public abstract class URLRewriter
29 {
30     /**
31      * Flag indicating that other rewriters are allowed to be used in the chain.
32      * The URLRewriterService API will not allow more than one URLRewriter in
33      * the chain with this property equal to false.
34      */

35     private boolean _allowOtherRewriters = true;
36
37     public void setAllowOtherRewriters( boolean allowOtherRewriters )
38     {
39         _allowOtherRewriters = allowOtherRewriters;
40     }
41
42     public boolean allowOtherRewriters()
43     {
44         return _allowOtherRewriters;
45     }
46
47     /**
48      * Get the prefix to use when rewriting a query parameter name.
49      * Loops through the list of registered URLRewriters to build up a the prefix.
50      *
51      * @param servletContext the current ServletContext.
52      * @param request the current ServletRequest.
53      * @param name the name of the query parameter.
54      * @return a prefix to use to rewrite a query parameter name.
55      */

56     public abstract String JavaDoc getNamePrefix( ServletContext JavaDoc servletContext, ServletRequest JavaDoc request, String JavaDoc name );
57
58     /**
59      * Rewrite the given URL.
60      *
61      * @param servletContext the current ServletContext.
62      * @param request the current ServletRequest.
63      * @param response the current ServletResponse.
64      * @param url the MutableURI to be rewritten.
65      * @param type the type of URL to be rewritten. This is one of the following values:
66      * <ul>
67      * <li><code>action</code>: a standard (non-resource) URL
68      * <li><code>resource</code>: a resource (e.g., image) URL
69      * </ul>
70      * @param needsToBeSecure a flag indicating whether the URL should be secure (SSL required) or not
71      */

72     public abstract void rewriteURL( ServletContext JavaDoc servletContext, ServletRequest JavaDoc request,
73                                      ServletResponse JavaDoc response, MutableURI url, URLType type,
74                                      boolean needsToBeSecure );
75
76     /**
77      * Tell whether rewritten form actions should be allowed to have query parameters. If this returns
78      * <code>false</code>, then a form-tag implementation should render query parameters into hidden
79      * fields on the form instead of allowing them to remain in the URL.
80      */

81     public boolean allowParamsOnFormAction( ServletContext JavaDoc servletContext, ServletRequest JavaDoc request )
82     {
83         return false;
84     }
85 }
86
Popular Tags