KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > webflow > core > collection > ParameterMap


1 /*
2  * Copyright 2002-2006 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 package org.springframework.webflow.core.collection;
17
18 import org.springframework.binding.collection.MapAdaptable;
19 import org.springframework.binding.convert.ConversionException;
20 import org.springframework.web.multipart.MultipartFile;
21
22 /**
23  * An interface for accessing parameters in a backing map. Parameters are
24  * immutable and have string keys and string values.
25  *
26  * @author Keith Donald
27  */

28 public interface ParameterMap extends MapAdaptable {
29
30     /**
31      * Is this parameter map empty, with a size of 0?
32      * @return true if empty, false if not
33      */

34     public boolean isEmpty();
35
36     /**
37      * Returns the number of parameters in this map.
38      * @return the parameter count
39      */

40     public int size();
41
42     /**
43      * Does the parameter with the provided name exist in this map?
44      * @param parameterName the parameter name
45      * @return true if so, false otherwise
46      */

47     public boolean contains(String JavaDoc parameterName);
48
49     /**
50      * Get a parameter value, returning <code>null</code> if no value is
51      * found.
52      * @param parameterName the parameter name
53      * @return the parameter value
54      */

55     public String JavaDoc get(String JavaDoc parameterName);
56
57     /**
58      * Get a parameter value, returning the defaultValue if no value is found.
59      * @param parameterName the parameter name
60      * @param defaultValue the default
61      * @return the parameter value
62      */

63     public String JavaDoc get(String JavaDoc parameterName, String JavaDoc defaultValue);
64
65     /**
66      * Get a multi-valued parameter value, returning <code>null</code> if no
67      * value is found. If the parameter is single valued an array with a single
68      * element is returned.
69      * @param parameterName the parameter name
70      * @return the parameter value array
71      */

72     public String JavaDoc[] getArray(String JavaDoc parameterName);
73
74     /**
75      * Get a multi-valued parameter value, converting each value to the target
76      * type or returning <code>null</code> if no value is found.
77      * @param parameterName the parameter name
78      * @param targetElementType the target type of the array's elements
79      * @return the converterd parameter value array
80      * @throws ConversionException when the value could not be converted
81      */

82     public Object JavaDoc[] getArray(String JavaDoc parameterName, Class JavaDoc targetElementType) throws ConversionException;
83
84     /**
85      * Get a parameter value, converting it from <code>String</code> to the
86      * target type.
87      * @param parameterName the name of the parameter
88      * @param targetType the target type of the parameter value
89      * @return the converted parameter value, or null if not found
90      * @throws ConversionException when the value could not be converted
91      */

92     public Object JavaDoc get(String JavaDoc parameterName, Class JavaDoc targetType) throws ConversionException;
93
94     /**
95      * Get a parameter value, converting it from <code>String</code> to the
96      * target type or returning the defaultValue if not found.
97      * @param parameterName name of the parameter to get
98      * @param targetType the target type of the parameter value
99      * @param defaultValue the default value
100      * @return the converted parameter value, or the default if not found
101      * @throws ConversionException when a value could not be converted
102      */

103     public Object JavaDoc get(String JavaDoc parameterName, Class JavaDoc targetType, Object JavaDoc defaultValue) throws ConversionException;
104
105     /**
106      * Get the value of a required parameter.
107      * @param parameterName the name of the parameter
108      * @return the parameter value
109      * @throws IllegalArgumentException when the parameter is not found
110      */

111     public String JavaDoc getRequired(String JavaDoc parameterName) throws IllegalArgumentException JavaDoc;
112
113     /**
114      * Get a required multi-valued parameter value.
115      * @param parameterName the name of the parameter
116      * @return the parameter value
117      * @throws IllegalArgumentException when the parameter is not found
118      */

119     public String JavaDoc[] getRequiredArray(String JavaDoc parameterName) throws IllegalArgumentException JavaDoc;
120
121     /**
122      * Get a required multi-valued parameter value, converting each value to the
123      * target type.
124      * @param parameterName the name of the parameter
125      * @return the parameter value
126      * @throws IllegalArgumentException when the parameter is not found
127      * @throws ConversionException when a value could not be converted
128      */

129     public Object JavaDoc[] getRequiredArray(String JavaDoc parameterName, Class JavaDoc targetElementType) throws IllegalArgumentException JavaDoc,
130             ConversionException;
131
132     /**
133      * Get the value of a required parameter and convert it to the target type.
134      * @param parameterName the name of the parameter
135      * @param targetType the target type of the parameter value
136      * @return the converted parameter value
137      * @throws IllegalArgumentException when the parameter is not found
138      * @throws ConversionException when the value could not be converted
139      */

140     public Object JavaDoc getRequired(String JavaDoc parameterName, Class JavaDoc targetType) throws IllegalArgumentException JavaDoc,
141             ConversionException;
142
143     /**
144      * Returns a number parameter value in the map that is of the specified
145      * type, returning <code>null</code> if no value was found.
146      * @param parameterName the parameter name
147      * @param targetType the target number type
148      * @return the number parameter value
149      * @throws ConversionException when the value could not be converted
150      */

151     public Number JavaDoc getNumber(String JavaDoc parameterName, Class JavaDoc targetType) throws ConversionException;
152
153     /**
154      * Returns a number parameter value in the map of the specified type,
155      * returning the defaultValue if no value was found.
156      * @param parameterName the parameter name
157      * @param defaultValue the default
158      * @return the number parameter value
159      * @throws ConversionException when the value could not be converted
160      */

161     public Number JavaDoc getNumber(String JavaDoc parameterName, Class JavaDoc targetType, Number JavaDoc defaultValue) throws ConversionException;
162
163     /**
164      * Returns a number parameter value in the map, throwing an exception if the
165      * parameter is not present or could not be converted.
166      * @param parameterName the parameter name
167      * @return the number parameter value
168      * @throws IllegalArgumentException if the parameter is not present
169      * @throws ConversionException when the value could not be converted
170      */

171     public Number JavaDoc getRequiredNumber(String JavaDoc parameterName, Class JavaDoc targetType) throws IllegalArgumentException JavaDoc,
172             ConversionException;
173
174     /**
175      * Returns an integer parameter value in the map, returning
176      * <code>null</code> if no value was found.
177      * @param parameterName the parameter name
178      * @return the integer parameter value
179      * @throws ConversionException when the value could not be converted
180      */

181     public Integer JavaDoc getInteger(String JavaDoc parameterName) throws ConversionException;
182
183     /**
184      * Returns an integer parameter value in the map, returning the defaultValue
185      * if no value was found.
186      * @param parameterName the parameter name
187      * @param defaultValue the default
188      * @return the integer parameter value
189      * @throws ConversionException when the value could not be converted
190      */

191     public Integer JavaDoc getInteger(String JavaDoc parameterName, Integer JavaDoc defaultValue) throws ConversionException;
192
193     /**
194      * Returns an integer parameter value in the map, throwing an exception if
195      * the parameter is not present or could not be converted.
196      * @param parameterName the parameter name
197      * @return the integer parameter value
198      * @throws IllegalArgumentException if the parameter is not present
199      * @throws ConversionException when the value could not be converted
200      */

201     public Integer JavaDoc getRequiredInteger(String JavaDoc parameterName) throws IllegalArgumentException JavaDoc, ConversionException;
202
203     /**
204      * Returns a long parameter value in the map, returning <code>null</code>
205      * if no value was found.
206      * @param parameterName the parameter name
207      * @return the long parameter value
208      * @throws ConversionException when the value could not be converted
209      */

210     public Long JavaDoc getLong(String JavaDoc parameterName) throws ConversionException;
211
212     /**
213      * Returns a long parameter value in the map, returning the defaultValue if
214      * no value was found.
215      * @param parameterName the parameter name
216      * @param defaultValue the default
217      * @return the long parameter value
218      * @throws ConversionException when the value could not be converted
219      */

220     public Long JavaDoc getLong(String JavaDoc parameterName, Long JavaDoc defaultValue) throws ConversionException;
221
222     /**
223      * Returns a long parameter value in the map, throwing an exception if the
224      * parameter is not present or could not be converted.
225      * @param parameterName the parameter name
226      * @return the long parameter value
227      * @throws IllegalArgumentException if the parameter is not present
228      * @throws ConversionException when the value could not be converted
229      */

230     public Long JavaDoc getRequiredLong(String JavaDoc parameterName) throws IllegalArgumentException JavaDoc, ConversionException;
231
232     /**
233      * Returns a boolean parameter value in the map, returning <code>null</code>
234      * if no value was found.
235      * @param parameterName the parameter name
236      * @return the long parameter value
237      * @throws ConversionException when the value could not be converted
238      */

239     public Boolean JavaDoc getBoolean(String JavaDoc parameterName) throws ConversionException;
240
241     /**
242      * Returns a boolean parameter value in the map, returning the defaultValue
243      * if no value was found.
244      * @param parameterName the parameter name
245      * @param defaultValue the default
246      * @return the boolean parameter value
247      * @throws ConversionException when the value could not be converted
248      */

249     public Boolean JavaDoc getBoolean(String JavaDoc parameterName, Boolean JavaDoc defaultValue) throws ConversionException;
250
251     /**
252      * Returns a boolean parameter value in the map, throwing an exception if
253      * the parameter is not present or could not be converted.
254      * @param parameterName the parameter name
255      * @return the boolean parameter value
256      * @throws IllegalArgumentException if the parameter is not present
257      * @throws ConversionException when the value could not be converted
258      */

259     public Boolean JavaDoc getRequiredBoolean(String JavaDoc parameterName) throws IllegalArgumentException JavaDoc, ConversionException;
260
261     /**
262      * Get a multi-part file parameter value, returning <code>null</code> if
263      * no value is found.
264      * @param parameterName the parameter name
265      * @return the multipart file
266      */

267     public MultipartFile getMultipartFile(String JavaDoc parameterName);
268
269     /**
270      * Get the value of a required multipart file parameter.
271      * @param parameterName the name of the parameter
272      * @return the parameter value
273      * @throws IllegalArgumentException when the parameter is not found
274      */

275     public MultipartFile getRequiredMultipartFile(String JavaDoc parameterName);
276
277     /**
278      * Adapts this parameter map to an {@link AttributeMap}.
279      * @return the underlying map as a unmodifiable attribute map
280      */

281     public AttributeMap asAttributeMap();
282
283 }
Popular Tags