%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.turbine.services.pull.util.SessionData |
|
|
1 | package org.apache.turbine.services.pull.util; |
|
2 | ||
3 | /* |
|
4 | * Copyright 2001-2005 The Apache Software Foundation. |
|
5 | * |
|
6 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
7 | * you may not use this file except in compliance with the License. |
|
8 | * You may obtain a copy of the License at |
|
9 | * |
|
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
11 | * |
|
12 | * Unless required by applicable law or agreed to in writing, software |
|
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
15 | * See the License for the specific language governing permissions and |
|
16 | * limitations under the License. |
|
17 | */ |
|
18 | ||
19 | import java.util.Map; |
|
20 | import java.util.HashMap; |
|
21 | import java.util.Iterator; |
|
22 | ||
23 | import org.apache.turbine.services.pull.ApplicationTool; |
|
24 | ||
25 | /** |
|
26 | * Pull tool designed to be used in the session scope for storage of |
|
27 | * temporary data. This tool should eliminate the need for the |
|
28 | * {@link org.apache.turbine.om.security.User#setTemp} and |
|
29 | * {@link org.apache.turbine.om.security.User#getTemp} methods. |
|
30 | * |
|
31 | * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a> |
|
32 | * @version $Id: SessionData.java 264148 2005-08-29 14:21:04Z henning $ |
|
33 | */ |
|
34 | 0 | public class SessionData implements ApplicationTool |
35 | { |
|
36 | /** Storage of user defined data */ |
|
37 | private Map dataStorage; |
|
38 | ||
39 | /** |
|
40 | * Initialize the application tool. |
|
41 | * |
|
42 | * @param data initialization data |
|
43 | */ |
|
44 | public void init(Object data) |
|
45 | { |
|
46 | 0 | dataStorage = new HashMap(); |
47 | 0 | } |
48 | ||
49 | /** |
|
50 | * Refresh the application tool. |
|
51 | */ |
|
52 | public void refresh() |
|
53 | { |
|
54 | // do nothing |
|
55 | 0 | } |
56 | ||
57 | /** |
|
58 | * Gets the data stored under the key. Null will be returned if the |
|
59 | * key does not exist or if null was stored under the key. |
|
60 | * <p> |
|
61 | * To check for a key with a null value use {@link #containsKey}. |
|
62 | * |
|
63 | * @param key key under which the data is stored. |
|
64 | * @return <code>Object</code> stored under the key. |
|
65 | */ |
|
66 | public Object get(String key) |
|
67 | { |
|
68 | 0 | return dataStorage.get(key); |
69 | } |
|
70 | ||
71 | /** |
|
72 | * Determines is a given key is stored. |
|
73 | * |
|
74 | * @param key the key to check for |
|
75 | * @return true if the key was found |
|
76 | */ |
|
77 | public boolean containsKey(String key) |
|
78 | { |
|
79 | 0 | return dataStorage.containsKey(key); |
80 | } |
|
81 | ||
82 | /** |
|
83 | * Stores the data. If the key already exists, the value will be |
|
84 | * overwritten. |
|
85 | * |
|
86 | * @param key key under which the data will be stored. |
|
87 | * @param value data to store under the key. Null values are allowed. |
|
88 | */ |
|
89 | public void put(String key, Object value) |
|
90 | { |
|
91 | 0 | dataStorage.put(key, value); |
92 | 0 | } |
93 | ||
94 | /** |
|
95 | * Clears all data |
|
96 | */ |
|
97 | public void clear() |
|
98 | { |
|
99 | 0 | dataStorage.clear(); |
100 | 0 | } |
101 | ||
102 | /** |
|
103 | * Gets a iterator for the keys. |
|
104 | * |
|
105 | * @return <code>Iterator</code> for the keys |
|
106 | */ |
|
107 | public Iterator iterator() |
|
108 | { |
|
109 | 0 | return dataStorage.keySet().iterator(); |
110 | } |
|
111 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |