Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libTools / src / org / gvsig / tools / persistence / PersistentState.java @ 28468

History | View | Annotate | Download (6.25 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 an <code>Object</code> property.
74
         * @param name The name of the property to get
75
         * 
76
         * @return The <code>Object</code> property associated to the provided name
77
         * @throws PersistenceValueNotFoundException
78
         */
79
        public Object get(String name) throws PersistenceValueNotFoundException,
80
                        PersistenceException;
81

    
82
        /**
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 
90
         */
91
        public Iterator getIterator(String name) throws PersistenceValueNotFoundException, PersistenceException;
92

    
93
        /**
94
         * <p>Sets a property of type String.</p>
95
         * 
96
         * @param name The name of the property to store
97
         * @param it The String object to be stored in the state.
98
         * 
99
         * @throws PersistenceException
100
         */
101
        public void set(String name, String value);
102

    
103
        /**
104
         * <p>Sets a property of type int.</p>
105
         * 
106
         * @param name The name of the property to store
107
         * @param it The int value to be stored in the state.
108
         * 
109
         * @throws PersistenceException
110
         */
111
        public void set(String name, int value);
112

    
113
        /**
114
         * <p>Sets a property of type long.</p>
115
         * 
116
         * @param name The name of the property to store
117
         * @param it The long value to be stored in the state.
118
         * 
119
         * @throws PersistenceException
120
         */
121
        public void set(String name, long value);
122

    
123
        /**
124
         * <p>Sets a property of type double.</p>
125
         * 
126
         * @param name The name of the property to store
127
         * @param it The double value to be stored in the state.
128
         * 
129
         * @throws PersistenceException
130
         */
131
        public void set(String name, double value);
132

    
133
        /**
134
         * <p>Sets a property of type float.</p>
135
         * 
136
         * @param name The name of the property to store
137
         * @param it The float value to be stored in the state.
138
         * 
139
         * @throws PersistenceException
140
         */
141
        public void set(String name, float value);
142

    
143
        /**
144
         * <p>Sets a property of type boolean.</p>
145
         * 
146
         * @param name The name of the property to store
147
         * @param it The boolean value to be stored in the state.
148
         * 
149
         * @throws PersistenceException
150
         */
151
        public void set(String name, boolean value);
152

    
153
        /**
154
         * <p>Sets a property of type Persistent.</p>
155
         * 
156
         * @param name The name of the property to store
157
         * @param it The Persistent object to be stored in the state.
158
         * 
159
         * @throws PersistenceException
160
         */
161
        public void set(String name, Persistent obj)
162
                        throws PersistenceException;
163

    
164
        /**
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
         * 
172
         * @throws PersistenceException
173
         */
174
        public void set(String name, Object obj)
175
                        throws PersistenceException;
176

    
177
        /**
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
         * 
184
         * @throws PersistenceException
185
         */
186
        public void set(String name, Iterator it)
187
                        throws PersistenceException;
188

    
189
        /**
190
         * <p>Gets an iterator over the names of the properties contained
191
         * in this PersistentState.</p>
192
         * 
193
         * @return An iterator which provides the name of all the
194
         * properties contained in this state.
195
         */
196
        public Iterator getNames();
197

    
198
        /**
199
         * <p>Serializes this state and writes the serialized data
200
         * in the provided <code>writer</code>. Depending on the implementation
201
         * the serialized data may have different formats, such as XML or
202
         * binary data.</p>
203
         *
204
         * @param writer
205
         */
206
        public void save(Writer writer) throws PersistenceException;
207

    
208
        /**
209
         * <p>De-serializes the data read from the provided <code>reader</code>. Depending
210
         * on the implementation the serialized data may have different formats, such as XML or
211
         * binary data.</p>
212
         * 
213
         * <p>Note that a particular implementation will only be able to
214
         * de-serialize data which has been serialized by the same
215
         * implementation.</p>
216
         *
217
         * @param reader
218
         */
219
        public void load(Reader reader) throws PersistenceException;
220
}