KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.Collection JavaDoc;
19
20 import org.springframework.binding.collection.MapAdaptable;
21
22 /**
23  * An immutable interface for accessing attributes in a backing map with string keys.
24  * <p>
25  * Implementations can optionally support {@link AttributeMapBindingListener listeners}
26  * that will be notified when they're bound in or unbound from the map.
27  *
28  * @author Keith Donald
29  */

30 public interface AttributeMap extends MapAdaptable {
31
32     /**
33      * Get an attribute value out of this map, returning <code>null</code> if
34      * not found.
35      * @param attributeName the attribute name
36      * @return the attribute value
37      */

38     public Object JavaDoc get(String JavaDoc attributeName);
39
40     /**
41      * Returns the size of this map.
42      * @return the nubmer of entries in the map
43      */

44     public int size();
45
46     /**
47      * Is this attribute map empty with a size of 0?
48      * @return true if empty, false if not
49      */

50     public boolean isEmpty();
51
52     /**
53      * Does the attribute with the provided name exist in this map?
54      * @param attributeName the attribute name
55      * @return true if so, false otherwise
56      */

57     public boolean contains(String JavaDoc attributeName);
58
59     /**
60      * Does the attribute with the provided name exist in this map and is its
61      * value of the specified required type?
62      * @param attributeName the attribute name
63      * @param requiredType the required class of the attribute value
64      * @return true if so, false otherwise
65      * @throws IllegalArgumentException when the value is not of the required
66      * type
67      */

68     public boolean contains(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
69
70     /**
71      * Get an attribute value, returning the default value if no value is found.
72      * @param attributeName the name of the attribute
73      * @param defaultValue the default value
74      * @return the attribute value, falling back to the default if no such
75      * attribute exists
76      */

77     public Object JavaDoc get(String JavaDoc attributeName, Object JavaDoc defaultValue);
78
79     /**
80      * Get an attribute value, asserting the value is of the required type.
81      * @param attributeName the name of the attribute
82      * @param requiredType the required type of the attribute value
83      * @return the attribute value, or null if not found
84      * @throws IllegalArgumentException when the value is not of the required
85      * type
86      */

87     public Object JavaDoc get(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
88
89     /**
90      * Get an attribute value, asserting the value is of the required type and
91      * returning the default value if not found.
92      * @param attributeName the name of the attribute
93      * @param requiredType the value required type
94      * @param defaultValue the default value
95      * @return the attribute value, or the default if not found
96      * @throws IllegalArgumentException when the value (if found) is not of the
97      * required type
98      */

99     public Object JavaDoc get(String JavaDoc attributeName, Class JavaDoc requiredType, Object JavaDoc defaultValue) throws IllegalStateException JavaDoc;
100
101     /**
102      * Get the value of a required attribute, throwing an exception of no
103      * attribute is found.
104      * @param attributeName the name of the attribute
105      * @return the attribute value
106      * @throws IllegalArgumentException when the attribute is not found
107      */

108     public Object JavaDoc getRequired(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
109
110     /**
111      * Get the value of a required attribute and make sure it is of the required
112      * type.
113      * @param attributeName name of the attribute to get
114      * @param requiredType the required type of the attribute value
115      * @return the attribute value
116      * @throws IllegalArgumentException when the attribute is not found or not
117      * of the required type
118      */

119     public Object JavaDoc getRequired(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
120
121     /**
122      * Returns a string attribute value in the map, returning <code>null</code>
123      * if no value was found.
124      * @param attributeName the attribute name
125      * @return the string attribute value
126      * @throws IllegalArgumentException if the attribute is present but not a
127      * string
128      */

129     public String JavaDoc getString(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
130
131     /**
132      * Returns a string attribute value in the map, returning the default value
133      * if no value was found.
134      * @param attributeName the attribute name
135      * @param defaultValue the default
136      * @return the string attribute value
137      * @throws IllegalArgumentException if the attribute is present but not a
138      * string
139      */

140     public String JavaDoc getString(String JavaDoc attributeName, String JavaDoc defaultValue) throws IllegalArgumentException JavaDoc;
141
142     /**
143      * Returns a string attribute value in the map, throwing an exception if the
144      * attribute is not present and of the correct type.
145      * @param attributeName the attribute name
146      * @return the string attribute value
147      * @throws IllegalArgumentException if the attribute is not present or
148      * present but not a string
149      */

150     public String JavaDoc getRequiredString(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
151
152     /**
153      * Returns a collection attribute value in the map.
154      * @param attributeName the attribute name
155      * @return the collection attribute value
156      * @throws IllegalArgumentException if the attribute is present but not a
157      * collection
158      */

159     public Collection JavaDoc getCollection(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
160
161     /**
162      * Returns a collection attribute value in the map and make sure it is of
163      * the required type.
164      * @param attributeName the attribute name
165      * @param requiredType the required type of the attribute value
166      * @return the collection attribute value
167      * @throws IllegalArgumentException if the attribute is present but not a
168      * collection of the required type
169      */

170     public Collection JavaDoc getCollection(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
171
172     /**
173      * Returns a collection attribute value in the map, throwing an exception if
174      * the attribute is not present or not a collection.
175      * @param attributeName the attribute name
176      * @return the collection attribute value
177      * @throws IllegalArgumentException if the attribute is not present or is
178      * present but not a collection
179      */

180     public Collection JavaDoc getRequiredCollection(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
181
182     /**
183      * Returns a collection attribute value in the map, throwing an exception if
184      * the attribute is not present or not a collection of the required type.
185      * @param attributeName the attribute name
186      * @param requiredType the required collection type
187      * @return the collection attribute value
188      * @throws IllegalArgumentException if the attribute is not present or is
189      * present but not a collection of the required type
190      */

191     public Collection JavaDoc getRequiredCollection(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
192
193     /**
194      * Returns an array attribute value in the map and makes sure it is of the
195      * required type.
196      * @param attributeName the attribute name
197      * @param requiredType the required type of the attribute value
198      * @return the array attribute value
199      * @throws IllegalArgumentException if the attribute is present but not an
200      * array of the required type
201      */

202     public Object JavaDoc[] getArray(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
203
204     /**
205      * Returns an array attribute value in the map, throwing an exception if the
206      * attribute is not present or not an array of the required type.
207      * @param attributeName the attribute name
208      * @param requiredType the required array type
209      * @return the collection attribute value
210      * @throws IllegalArgumentException if the attribute is not present or is
211      * present but not a array of the required type
212      */

213     public Object JavaDoc[] getRequiredArray(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
214
215     /**
216      * Returns a number attribute value in the map that is of the specified
217      * type, returning <code>null</code> if no value was found.
218      * @param attributeName the attribute name
219      * @param requiredType the required number type
220      * @return the number attribute value
221      * @throws IllegalArgumentException if the attribute is present but not a
222      * number of the required type
223      */

224     public Number JavaDoc getNumber(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
225
226     /**
227      * Returns a number attribute value in the map of the specified type,
228      * returning the default value if no value was found.
229      * @param attributeName the attribute name
230      * @param defaultValue the default
231      * @return the number attribute value
232      * @throws IllegalArgumentException if the attribute is present but not a
233      * number of the required type
234      */

235     public Number JavaDoc getNumber(String JavaDoc attributeName, Class JavaDoc requiredType, Number JavaDoc defaultValue)
236             throws IllegalArgumentException JavaDoc;
237
238     /**
239      * Returns a number attribute value in the map, throwing an exception if the
240      * attribute is not present and of the correct type.
241      * @param attributeName the attribute name
242      * @return the number attribute value
243      * @throws IllegalArgumentException if the attribute is not present or
244      * present but not a number of the required type
245      */

246     public Number JavaDoc getRequiredNumber(String JavaDoc attributeName, Class JavaDoc requiredType) throws IllegalArgumentException JavaDoc;
247
248     /**
249      * Returns an integer attribute value in the map, returning
250      * <code>null</code> if no value was found.
251      * @param attributeName the attribute name
252      * @return the integer attribute value
253      * @throws IllegalArgumentException if the attribute is present but not an
254      * integer
255      */

256     public Integer JavaDoc getInteger(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
257
258     /**
259      * Returns an integer attribute value in the map, returning the default
260      * value if no value was found.
261      * @param attributeName the attribute name
262      * @param defaultValue the default
263      * @return the integer attribute value
264      * @throws IllegalArgumentException if the attribute is present but not an
265      * integer
266      */

267     public Integer JavaDoc getInteger(String JavaDoc attributeName, Integer JavaDoc defaultValue) throws IllegalArgumentException JavaDoc;
268
269     /**
270      * Returns an integer attribute value in the map, throwing an exception if
271      * the attribute is not present and of the correct type.
272      * @param attributeName the attribute name
273      * @return the integer attribute value
274      * @throws IllegalArgumentException if the attribute is not present or
275      * present but not an integer
276      */

277     public Integer JavaDoc getRequiredInteger(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
278
279     /**
280      * Returns a long attribute value in the map, returning <code>null</code>
281      * if no value was found.
282      * @param attributeName the attribute name
283      * @return the long attribute value
284      * @throws IllegalArgumentException if the attribute is present but not a
285      * long
286      */

287     public Long JavaDoc getLong(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
288
289     /**
290      * Returns a long attribute value in the map, returning the default value if
291      * no value was found.
292      * @param attributeName the attribute name
293      * @param defaultValue the default
294      * @return the long attribute value
295      * @throws IllegalArgumentException if the attribute is present but not a
296      * long
297      */

298     public Long JavaDoc getLong(String JavaDoc attributeName, Long JavaDoc defaultValue) throws IllegalArgumentException JavaDoc;
299
300     /**
301      * Returns a long attribute value in the map, throwing an exception if the
302      * attribute is not present and of the correct type.
303      * @param attributeName the attribute name
304      * @return the long attribute value
305      * @throws IllegalArgumentException if the attribute is not present or
306      * present but not a long
307      */

308     public Long JavaDoc getRequiredLong(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
309
310     /**
311      * Returns a boolean attribute value in the map, returning <code>null</code>
312      * if no value was found.
313      * @param attributeName the attribute name
314      * @return the long attribute value
315      * @throws IllegalArgumentException if the attribute is present but not a
316      * boolean
317      */

318     public Boolean JavaDoc getBoolean(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
319
320     /**
321      * Returns a boolean attribute value in the map, returning the default value
322      * if no value was found.
323      * @param attributeName the attribute name
324      * @param defaultValue the default
325      * @return the boolean attribute value
326      * @throws IllegalArgumentException if the attribute is present but not a
327      * boolean
328      */

329     public Boolean JavaDoc getBoolean(String JavaDoc attributeName, Boolean JavaDoc defaultValue) throws IllegalArgumentException JavaDoc;
330
331     /**
332      * Returns a boolean attribute value in the map, throwing an exception if
333      * the attribute is not present and of the correct type.
334      * @param attributeName the attribute name
335      * @return the boolean attribute value
336      * @throws IllegalArgumentException if the attribute is not present or
337      * present but is not a boolean
338      */

339     public Boolean JavaDoc getRequiredBoolean(String JavaDoc attributeName) throws IllegalArgumentException JavaDoc;
340
341     /**
342      * Returns a new attribute map containing the union of this map with the
343      * provided map.
344      * @param attributes the map to combine with this map
345      * @return a new, combined map
346      */

347     public AttributeMap union(AttributeMap attributes);
348
349 }
Popular Tags