Revision 28468 branches/v2_0_0_prep/libraries/libTools/src/org/gvsig/tools/persistence/PersistenceManager.java
PersistenceManager.java | ||
---|---|---|
16 | 16 |
* @author IVER T.I. <http://www.iver.es> |
17 | 17 |
*/ |
18 | 18 |
public interface PersistenceManager { |
19 |
/** |
|
20 |
* <p>Validation Mode -- MANDATORY: Validation is active, so |
|
21 |
* {@link PersistenceManager#create(org.gvsig.tools.persistence.PersistentState)} |
|
22 |
* and |
|
23 |
* {@link PersistenceManager#getState(org.gvsig.tools.persistence.Persistent)} |
|
24 |
* will throw validation exceptions if validation errors are found.</p> |
|
25 |
* <p>If an undeclared attribute or class is found, this will be considered |
|
26 |
* a validation error.</p> |
|
27 |
*/ |
|
28 |
static public final int MANDATORY = 3; |
|
29 |
/** |
|
30 |
* <p>Validation Mode -- MANDATORY_IF_DECLARED: Validation is active, but |
|
31 |
* it will be only applied to Persistent objectswhich have been registered. |
|
32 |
* {@link PersistenceManager#create(org.gvsig.tools.persistence.PersistentState)} |
|
33 |
* and |
|
34 |
* {@link PersistenceManager#getState(org.gvsig.tools.persistence.Persistent)} |
|
35 |
* methods will throw validation exceptions if validation errors are found.</p> |
|
36 |
*/ |
|
37 |
static public final int MANDATORY_IF_DECLARED = 2; |
|
38 |
/** |
|
39 |
* <p>Validation Mode - DISABLED: No validation is performed at all. |
|
40 |
* In this mode, {@link PersistenceManager#ge}</p> |
|
41 |
*/ |
|
42 |
static public final int DISABLED = 0; |
|
19 | 43 |
|
20 | 44 |
/** |
21 | 45 |
* <p>Creates a persistent state from an Persistent object.</p> |
... | ... | |
86 | 110 |
public void removeDefinition(Class persistentClass); |
87 | 111 |
|
88 | 112 |
/** |
89 |
* <p>Validate a persistent state by using the corresponding registered |
|
113 |
* <p>Validates a persistent state by using the corresponding registered
|
|
90 | 114 |
* attribute definition. If there is no registered definition for the class |
91 | 115 |
* represented by the PersistenteState, validation should fail.</p> |
92 | 116 |
* |
... | ... | |
132 | 156 |
* @return |
133 | 157 |
*/ |
134 | 158 |
public PersistentState loadState(Reader reader) throws PersistenceException; |
159 |
|
|
160 |
/** |
|
161 |
* <p>Sets the validation which will be applied in |
|
162 |
* {@link #getState(Persistent)}, {@link #create(PersistentState)} |
|
163 |
* methods. Validation ensures that persisted or de-persisted objects |
|
164 |
* match the declared definition (which must have been previously |
|
165 |
* registered by using {@link #addDefinition(Class, DynStruct)}).</p> |
|
166 |
* |
|
167 |
* <p>When automatic validation is enabled (MANDATORY or |
|
168 |
* MANDATORY_IF_DECLARED), a ValidationException will be thrown by |
|
169 |
* {@link #getState(Persistent)}, {@link #create(PersistentState)} |
|
170 |
* if a validation error is found.</p> |
|
171 |
* |
|
172 |
* @param validationMode On of the following values: |
|
173 |
* {@link #DISABLED}, {@link #MANDATORY} |
|
174 |
* or {@link #MANDATORY_IF_DECLARED} |
|
135 | 175 |
|
176 |
* @see #validate(PersistentState) |
|
177 |
* @see #addDefinition(Class, DynStruct) |
|
178 |
* |
|
179 |
* @throws PersistenceException If the mode is not supported by this manager |
|
180 |
*/ |
|
181 |
public void setAutoValidation(int validationMode) throws PersistenceException; |
|
182 |
|
|
183 |
/** |
|
184 |
* <p>Gets the validation which will be applied in |
|
185 |
* {@link #getState(Persistent)}, {@link #create(PersistentState)} methods. |
|
186 |
* |
|
187 |
* @return The current mode for automatic validation: {@link #DISABLED}, |
|
188 |
* {@link #MANDATORY} or {@link #MANDATORY_IF_DECLARED} |
|
189 |
* |
|
190 |
* @see #validate(PersistentState) |
|
191 |
* @see #addDefinition(Class, DynStruct) |
|
192 |
*/ |
|
193 |
public int getAutoValidation(); |
|
194 |
|
|
136 | 195 |
} |
Also available in: Unified diff