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