Revision 29956 branches/v2_0_0_prep/libraries/libTools/src/org/gvsig/tools/persistence/PersistentState.java
PersistentState.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.Reader; |
4 | 4 |
import java.io.Writer; |
5 |
import java.util.ArrayList; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.HashSet; |
|
5 | 8 |
import java.util.Iterator; |
9 |
import java.util.List; |
|
10 |
import java.util.Map; |
|
11 |
import java.util.Set; |
|
6 | 12 |
|
7 | 13 |
public interface PersistentState { |
8 | 14 |
/** |
... | ... | |
14 | 20 |
|
15 | 21 |
/** |
16 | 22 |
* Gets an <code>int</code> property. |
17 |
* @param name The name of the property to get |
|
18 |
* |
|
23 |
* |
|
24 |
* @param name |
|
25 |
* The name of the property to get |
|
26 |
* |
|
19 | 27 |
* @return The <code>int</code> property associated to the provided name |
20 |
* @throws PersistenceValueNotFoundException
|
|
28 |
* @throws PersistenceException |
|
21 | 29 |
*/ |
22 |
public int getInt(String name) throws PersistenceValueNotFoundException;
|
|
30 |
public int getInt(String name) throws PersistenceException; |
|
23 | 31 |
|
24 | 32 |
/** |
25 | 33 |
* Gets an <code>long</code> property. |
26 |
* @param name The name of the property to get |
|
27 |
* |
|
34 |
* |
|
35 |
* @param name |
|
36 |
* The name of the property to get |
|
37 |
* |
|
28 | 38 |
* @return The <code>long</code> property associated to the provided name |
29 |
* @throws PersistenceValueNotFoundException
|
|
39 |
* @throws PersistenceException |
|
30 | 40 |
*/ |
31 |
public long getLong(String name) throws PersistenceValueNotFoundException;
|
|
41 |
public long getLong(String name) throws PersistenceException; |
|
32 | 42 |
|
33 | 43 |
/** |
34 | 44 |
* Gets a <code>double</code> property. |
35 |
* @param name The name of the property to get |
|
36 |
* |
|
45 |
* |
|
46 |
* @param name |
|
47 |
* The name of the property to get |
|
48 |
* |
|
37 | 49 |
* @return The <code>double</code> property associated to the provided name |
38 |
* @throws PersistenceValueNotFoundException
|
|
50 |
* @throws PersistenceException |
|
39 | 51 |
*/ |
40 | 52 |
public double getDouble(String name) |
41 |
throws PersistenceValueNotFoundException;
|
|
53 |
throws PersistenceException; |
|
42 | 54 |
|
43 | 55 |
/** |
44 | 56 |
* Gets a <code>float</code> property. |
45 |
* @param name The name of the property to get |
|
46 |
* |
|
57 |
* |
|
58 |
* @param name |
|
59 |
* The name of the property to get |
|
60 |
* |
|
47 | 61 |
* @return The <code>float</code> property associated to the provided name |
48 |
* @throws PersistenceValueNotFoundException
|
|
62 |
* @throws PersistenceException |
|
49 | 63 |
*/ |
50 |
public float getFloat(String name) throws PersistenceValueNotFoundException;
|
|
64 |
public float getFloat(String name) throws PersistenceException; |
|
51 | 65 |
|
52 | 66 |
/** |
53 | 67 |
* Gets a <code>boolean</code> property. |
54 |
* @param name The name of the property to get |
|
55 |
* |
|
68 |
* |
|
69 |
* @param name |
|
70 |
* The name of the property to get |
|
71 |
* |
|
56 | 72 |
* @return The <code>boolean</code> property associated to the provided name |
57 |
* @throws PersistenceValueNotFoundException
|
|
73 |
* @throws PersistenceException |
|
58 | 74 |
*/ |
59 | 75 |
public boolean getBoolean(String name) |
60 |
throws PersistenceValueNotFoundException;
|
|
76 |
throws PersistenceException; |
|
61 | 77 |
|
62 | 78 |
/** |
63 | 79 |
* Gets a <code>String</code> property. |
64 |
* @param name The name of the property to get |
|
65 |
* |
|
80 |
* |
|
81 |
* @param name |
|
82 |
* The name of the property to get |
|
83 |
* |
|
66 | 84 |
* @return The <code>String</code> property associated to the provided name |
67 |
* @throws PersistenceValueNotFoundException
|
|
85 |
* @throws PersistenceException |
|
68 | 86 |
*/ |
69 | 87 |
public String getString(String name) |
70 |
throws PersistenceValueNotFoundException;
|
|
88 |
throws PersistenceException; |
|
71 | 89 |
|
72 | 90 |
/** |
73 | 91 |
* Gets an <code>Object</code> property. |
74 |
* @param name The name of the property to get |
|
75 |
* |
|
92 |
* |
|
93 |
* @param name |
|
94 |
* The name of the property to get |
|
95 |
* |
|
76 | 96 |
* @return The <code>Object</code> property associated to the provided name |
77 |
* @throws PersistenceValueNotFoundException |
|
97 |
* |
|
98 |
* @throws PersistenceException |
|
78 | 99 |
*/ |
79 |
public Object get(String name) throws PersistenceValueNotFoundException, |
|
80 |
PersistenceException; |
|
100 |
public Object get(String name) throws PersistenceException; |
|
81 | 101 |
|
82 | 102 |
/** |
83 |
* <p>Gets an <code>Iterator</code> property.</p> |
|
84 |
* |
|
85 |
* @param name The name of the property to get |
|
86 |
* |
|
87 |
* @return The <code>Iterator</code> property associated to the provided name |
|
88 |
* @throws PersistenceValueNotFoundException |
|
89 |
* @throws PersistenceException |
|
103 |
* <p> |
|
104 |
* Gets an <code>Iterator</code> over properties of types {@link List}, |
|
105 |
* {@link Set} or {@link Map}. |
|
106 |
* </p> |
|
107 |
* |
|
108 |
* @param name |
|
109 |
* The name of the property to get |
|
110 |
* |
|
111 |
* @return The <code>Iterator</code> associated to the property value of |
|
112 |
* provided name |
|
113 |
* @throws PersistenceException |
|
90 | 114 |
*/ |
91 |
public Iterator getIterator(String name) throws PersistenceValueNotFoundException, PersistenceException;
|
|
115 |
public Iterator getIterator(String name) throws PersistenceException; |
|
92 | 116 |
|
93 | 117 |
/** |
94 | 118 |
* <p>Sets a property of type String.</p> |
95 |
*
|
|
119 |
* |
|
96 | 120 |
* @param name The name of the property to store |
97 | 121 |
* @param it The String object to be stored in the state. |
98 |
*
|
|
122 |
* |
|
99 | 123 |
* @throws PersistenceException |
100 | 124 |
*/ |
101 |
public void set(String name, String value); |
|
125 |
public void set(String name, String value) throws PersistenceException;
|
|
102 | 126 |
|
103 | 127 |
/** |
104 | 128 |
* <p>Sets a property of type int.</p> |
105 |
*
|
|
129 |
* |
|
106 | 130 |
* @param name The name of the property to store |
107 | 131 |
* @param it The int value to be stored in the state. |
108 |
*
|
|
132 |
* |
|
109 | 133 |
* @throws PersistenceException |
110 | 134 |
*/ |
111 |
public void set(String name, int value); |
|
135 |
public void set(String name, int value) throws PersistenceException;
|
|
112 | 136 |
|
113 | 137 |
/** |
114 | 138 |
* <p>Sets a property of type long.</p> |
115 |
*
|
|
139 |
* |
|
116 | 140 |
* @param name The name of the property to store |
117 | 141 |
* @param it The long value to be stored in the state. |
118 |
*
|
|
142 |
* |
|
119 | 143 |
* @throws PersistenceException |
120 | 144 |
*/ |
121 |
public void set(String name, long value); |
|
145 |
public void set(String name, long value) throws PersistenceException;
|
|
122 | 146 |
|
123 | 147 |
/** |
124 | 148 |
* <p>Sets a property of type double.</p> |
125 |
*
|
|
149 |
* |
|
126 | 150 |
* @param name The name of the property to store |
127 | 151 |
* @param it The double value to be stored in the state. |
128 |
*
|
|
152 |
* |
|
129 | 153 |
* @throws PersistenceException |
130 | 154 |
*/ |
131 |
public void set(String name, double value); |
|
155 |
public void set(String name, double value) throws PersistenceException;
|
|
132 | 156 |
|
133 | 157 |
/** |
134 | 158 |
* <p>Sets a property of type float.</p> |
135 |
*
|
|
159 |
* |
|
136 | 160 |
* @param name The name of the property to store |
137 | 161 |
* @param it The float value to be stored in the state. |
138 |
*
|
|
162 |
* |
|
139 | 163 |
* @throws PersistenceException |
140 | 164 |
*/ |
141 |
public void set(String name, float value); |
|
165 |
public void set(String name, float value) throws PersistenceException;
|
|
142 | 166 |
|
143 | 167 |
/** |
144 | 168 |
* <p>Sets a property of type boolean.</p> |
145 |
*
|
|
169 |
* |
|
146 | 170 |
* @param name The name of the property to store |
147 | 171 |
* @param it The boolean value to be stored in the state. |
148 |
*
|
|
172 |
* |
|
149 | 173 |
* @throws PersistenceException |
150 | 174 |
*/ |
151 |
public void set(String name, boolean value); |
|
175 |
public void set(String name, boolean value) throws PersistenceException;
|
|
152 | 176 |
|
153 | 177 |
/** |
154 | 178 |
* <p>Sets a property of type Persistent.</p> |
155 |
*
|
|
179 |
* |
|
156 | 180 |
* @param name The name of the property to store |
157 | 181 |
* @param it The Persistent object to be stored in the state. |
158 |
*
|
|
182 |
* |
|
159 | 183 |
* @throws PersistenceException |
160 | 184 |
*/ |
161 | 185 |
public void set(String name, Persistent obj) |
162 | 186 |
throws PersistenceException; |
163 | 187 |
|
164 | 188 |
/** |
165 |
* <p>Sets a property of type Object. Only the following types can be |
|
166 |
* stored: Persistent, PersistentState, Iterator, Boolean, Integer, Long, |
|
167 |
* Float, Double or String.</p> |
|
168 |
* |
|
169 |
* @param name The name of the property to store |
|
170 |
* @param it The object to be stored in the state. |
|
171 |
* |
|
189 |
* Sets a property of type Object. Only the following types can be stored: |
|
190 |
* <ul> |
|
191 |
* <li> {@link Persistent}</li> |
|
192 |
* <li> {@link Boolean}</li> |
|
193 |
* <li> {@link Integer}</li> |
|
194 |
* <li> {@link Long}</li> |
|
195 |
* <li> {@link Float}</li> |
|
196 |
* <li> {@link Double}</li> |
|
197 |
* <li> {@link String}</li> |
|
198 |
* <li> {@link List} <i>({@link #get(String)} return an {@link ArrayList} |
|
199 |
* instance after {@link #load(Reader)}) </i></li> |
|
200 |
* <li> {@link Set} <i>({@link #get(String)} return a {@link HashSet} |
|
201 |
* instance after {@link #load(Reader)}) </i></li> |
|
202 |
* <li> {@link Map} <i>({@link #get(String)} return a {@link HashMap} |
|
203 |
* instance after {@link #load(Reader)}) </i></li> |
|
204 |
* |
|
205 |
* @param name |
|
206 |
* The name of the property to store |
|
207 |
* @param obj |
|
208 |
* The object to be stored in the state. |
|
209 |
* |
|
172 | 210 |
* @throws PersistenceException |
173 | 211 |
*/ |
174 | 212 |
public void set(String name, Object obj) |
175 | 213 |
throws PersistenceException; |
176 | 214 |
|
177 | 215 |
/** |
178 |
* <p>Sets a property of type Iterator. This method is useful |
|
179 |
* to store arrays or lists.</p> |
|
180 |
* |
|
181 |
* @param name The name of the property to store |
|
182 |
* @param it The iterator to be stored in the state. |
|
183 |
* |
|
216 |
* <p> |
|
217 |
* Sets a property of type {@link List} filled with the values provided by a |
|
218 |
* {@link Iterator} |
|
219 |
* </p> |
|
220 |
* |
|
221 |
* @param name |
|
222 |
* The name of the property to store |
|
223 |
* @param it |
|
224 |
* The iterator to get values to store in the list property. |
|
225 |
* |
|
184 | 226 |
* @throws PersistenceException |
185 | 227 |
*/ |
186 | 228 |
public void set(String name, Iterator it) |
... | ... | |
189 | 231 |
/** |
190 | 232 |
* <p>Gets an iterator over the names of the properties contained |
191 | 233 |
* in this PersistentState.</p> |
192 |
*
|
|
234 |
* |
|
193 | 235 |
* @return An iterator which provides the name of all the |
194 | 236 |
* properties contained in this state. |
195 | 237 |
*/ |
... | ... | |
209 | 251 |
* <p>De-serializes the data read from the provided <code>reader</code>. Depending |
210 | 252 |
* on the implementation the serialized data may have different formats, such as XML or |
211 | 253 |
* binary data.</p> |
212 |
*
|
|
254 |
* |
|
213 | 255 |
* <p>Note that a particular implementation will only be able to |
214 | 256 |
* de-serialize data which has been serialized by the same |
215 | 257 |
* implementation.</p> |
... | ... | |
217 | 259 |
* @param reader |
218 | 260 |
*/ |
219 | 261 |
public void load(Reader reader) throws PersistenceException; |
262 |
|
|
263 |
/** |
|
264 |
* Informs that a property is set or not. |
|
265 |
* |
|
266 |
* @param name |
|
267 |
* @return |
|
268 |
*/ |
|
269 |
public boolean hasValue(String name); |
|
220 | 270 |
} |
Also available in: Unified diff