KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > portlet > bind > PortletRequestParameterPropertyValues


1 /*
2  * Copyright 2002-2005 the original author or authors.
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
17 package org.springframework.web.portlet.bind;
18
19 import javax.portlet.PortletRequest;
20
21 import org.springframework.beans.MutablePropertyValues;
22 import org.springframework.web.portlet.util.PortletUtils;
23
24 /**
25  * PropertyValues implementation created from parameters in a PortletRequest.
26  * Can look for all property values beginning with a certain prefix and
27  * prefix separator (default is "_").
28  *
29  * <p>For example, with a prefix of "spring", "spring_param1" and
30  * "spring_param2" result in a Map with "param1" and "param2" as keys.
31  *
32  * <p>This class is not immutable to be able to efficiently remove property
33  * values that should be ignored for binding.
34  *
35  * @author Juergen Hoeller
36  * @author John A. Lewis
37  * @since 2.0
38  * @see org.springframework.web.portlet.util.PortletUtils#getParametersStartingWith
39  */

40 public class PortletRequestParameterPropertyValues extends MutablePropertyValues {
41
42     /** Default prefix separator */
43     public static final String JavaDoc DEFAULT_PREFIX_SEPARATOR = "_";
44
45
46     /**
47      * Create new PortletRequestPropertyValues using no prefix
48      * (and hence, no prefix separator).
49      * @param request portlet request
50      */

51     public PortletRequestParameterPropertyValues(PortletRequest request) {
52         this(request, null, null);
53     }
54
55     /**
56      * Create new PortletRequestPropertyValues using the given prefix and
57      * the default prefix separator (the underscore character "_").
58      * @param request portlet request
59      * @param prefix the prefix for parameters (the full prefix will
60      * consist of this plus the separator)
61      * @see #DEFAULT_PREFIX_SEPARATOR
62      */

63     public PortletRequestParameterPropertyValues(PortletRequest request, String JavaDoc prefix) {
64         this(request, prefix, DEFAULT_PREFIX_SEPARATOR);
65     }
66
67     /**
68      * Create new PortletRequestPropertyValues supplying both prefix and
69      * prefix separator.
70      * @param request portlet request
71      * @param prefix the prefix for parameters (the full prefix will
72      * consist of this plus the separator)
73      * @param prefixSeparator separator delimiting prefix (e.g. "spring")
74      * and the rest of the parameter name ("param1", "param2")
75      */

76     public PortletRequestParameterPropertyValues(PortletRequest request, String JavaDoc prefix, String JavaDoc prefixSeparator) {
77         super(PortletUtils.getParametersStartingWith(
78                 request, (prefix != null) ? prefix + prefixSeparator : null));
79     }
80
81 }
82
Popular Tags