gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dynobject / DynField.java @ 212
History | View | Annotate | Download (8.62 KB)
1 |
package org.gvsig.tools.dynobject; |
---|---|
2 |
|
3 |
import java.util.List; |
4 |
|
5 |
import org.gvsig.tools.dataTypes.CoercionException; |
6 |
import org.gvsig.tools.dataTypes.DataTypes; |
7 |
import org.gvsig.tools.dynobject.exception.DynFieldIsNotAContainerException; |
8 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
9 |
|
10 |
/**
|
11 |
* A field of a {@link DynObject}.
|
12 |
* <p>
|
13 |
* A field will be persisted only if it is set as persistent (@see
|
14 |
* {@link DynField#isPersistent()}, which is the default value.
|
15 |
* </p>
|
16 |
*
|
17 |
* @author <a href="mailto:jjdelcerro@gvsig.org">Joaqu�n Jos� del Cerro</a>
|
18 |
*/
|
19 |
public interface DynField { |
20 |
|
21 |
/**
|
22 |
* Return the name of the field.
|
23 |
*
|
24 |
* @return name of the field
|
25 |
*/
|
26 |
public String getName(); |
27 |
|
28 |
/**
|
29 |
* Return the type used in this field.
|
30 |
* The values of type is the same of {@link DataTypes}
|
31 |
*
|
32 |
* @return
|
33 |
*/
|
34 |
public int getType(); |
35 |
|
36 |
/**
|
37 |
* Return the subtype associated to this field.
|
38 |
* The subtype is a string used for the cliente of the
|
39 |
* field.
|
40 |
*
|
41 |
* When the field is of type #{@link DataTypes#DYNOBJECT},
|
42 |
* the subtype are the fullname of the DynClass.
|
43 |
*
|
44 |
* @return the subtype of the field.
|
45 |
*/
|
46 |
public String getSubtype(); |
47 |
|
48 |
/**
|
49 |
* Return the descripcion associated to this field.
|
50 |
*
|
51 |
* @return the description of the field.
|
52 |
*/
|
53 |
public String getDescription(); |
54 |
|
55 |
/**
|
56 |
* Return the default value used in creation of new objects
|
57 |
* with this field.
|
58 |
*
|
59 |
* @return defaulr value to use for this field.
|
60 |
*/
|
61 |
public Object getDefaultValue(); |
62 |
|
63 |
/**
|
64 |
* Return a string that identify a group for this field.
|
65 |
* The groups are defined by the client of the field.
|
66 |
*
|
67 |
* @return the group of the field
|
68 |
*/
|
69 |
public String getGroup(); |
70 |
|
71 |
/**
|
72 |
* Return the ordinal that identify the order of this field
|
73 |
* in the {@link DynObject}.
|
74 |
*
|
75 |
* @return the order of field in the {@link DynObject}
|
76 |
*/
|
77 |
public int getOder(); |
78 |
|
79 |
/**
|
80 |
* Return true if this field is mandatory.
|
81 |
*
|
82 |
*/
|
83 |
public boolean isMandatory(); |
84 |
|
85 |
/**
|
86 |
* Returns if the field is persistent or volatile. The meaning of being
|
87 |
* persistent depends on how is persisted, but any persistence mechanism
|
88 |
* must avoid persisting this field value.
|
89 |
*
|
90 |
* @return if the field is to be persisted or not
|
91 |
*/
|
92 |
boolean isPersistent();
|
93 |
|
94 |
/**
|
95 |
* Inform if this field can be visible or not for the user.
|
96 |
* This value don't affect the access through the API.
|
97 |
*
|
98 |
* @return true if the field is hidden for the user.
|
99 |
*/
|
100 |
boolean isHidden();
|
101 |
|
102 |
/**
|
103 |
* Returns if the field is readOnly or not. The meaning of being
|
104 |
* readOnly allows to know if the user input to any graphic component associated
|
105 |
* to this field should be allowed or not.
|
106 |
*
|
107 |
* @return if the graphic component associated to this field should be readOnly or not
|
108 |
*/
|
109 |
public boolean isReadOnly(); |
110 |
|
111 |
/**
|
112 |
* Return true if the value of this field is a container.
|
113 |
* This method uses the same criteria of the {@link DataType}
|
114 |
*
|
115 |
* @return true if the field type is a container
|
116 |
*/
|
117 |
public boolean isContainer(); |
118 |
|
119 |
/**
|
120 |
* Return the available values for this field.
|
121 |
* When assign a value to the field, this value need that
|
122 |
* exists in this list.
|
123 |
*
|
124 |
* @return an array of the available values for the field.
|
125 |
*/
|
126 |
public DynObjectValueItem[] getAvailableValues(); |
127 |
|
128 |
public Object getMinValue(); |
129 |
|
130 |
public Object getMaxValue(); |
131 |
|
132 |
/**
|
133 |
* Return the java class of the value of the field.
|
134 |
*
|
135 |
* @return the class of the value
|
136 |
*/
|
137 |
Class getClassOfValue();
|
138 |
|
139 |
/**
|
140 |
* If the field is a container (List, Map or Set) return
|
141 |
* the java class of its items.
|
142 |
*
|
143 |
* @return the class of the items
|
144 |
*/
|
145 |
Class getClassOfItems();
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
/**
|
156 |
* Sets the description asociated to this field.
|
157 |
*
|
158 |
* @param description
|
159 |
*
|
160 |
* @return this same {@link DynField} object
|
161 |
*/
|
162 |
DynField setDescription(String description);
|
163 |
|
164 |
/**
|
165 |
* Sets the type of the field.
|
166 |
* The values used are the specified in {@link DataTypes}.
|
167 |
*
|
168 |
* This method assign the default values of the type for
|
169 |
* "ClassOfValue" and "subType".
|
170 |
*
|
171 |
* @param type
|
172 |
*
|
173 |
* @return this same {@link DynField} object
|
174 |
*/
|
175 |
DynField setType(int type);
|
176 |
|
177 |
/**
|
178 |
* Strings used as subtype for this field.
|
179 |
* This value is used by the client of the object.
|
180 |
*
|
181 |
* When the field is a #{@link DataTypes#DYNOBJECT},
|
182 |
* the subtype is the fullname of the DynStruct.
|
183 |
*
|
184 |
* @param subtype
|
185 |
*
|
186 |
* @return this same {@link DynField} object
|
187 |
*/
|
188 |
DynField setSubtype(String subtype);
|
189 |
|
190 |
/**
|
191 |
* Set the default value used for this field when a new
|
192 |
* object with this field is created.
|
193 |
*
|
194 |
* @param defaultValue
|
195 |
*
|
196 |
* @return this same {@link DynField} object
|
197 |
*/
|
198 |
DynField setDefaultValue(Object defaultValue);
|
199 |
|
200 |
DynField setGroup(String groupName);
|
201 |
|
202 |
DynField setOrder(int order);
|
203 |
|
204 |
DynField setMandatory(boolean mandatory);
|
205 |
|
206 |
DynField setHidden(boolean hidden);
|
207 |
|
208 |
/**
|
209 |
* Sets if the field must be persisted or not.
|
210 |
* @see #isPersistent()
|
211 |
* @param persistent if the field must be persisted or not
|
212 |
* @return this same {@link DynField} object
|
213 |
*/
|
214 |
DynField setPersistent(boolean persistent);
|
215 |
|
216 |
DynField setAvailableValues(DynObjectValueItem[] values);
|
217 |
|
218 |
DynField setAvailableValues(List values);
|
219 |
|
220 |
DynField setMinValue(Object minValue);
|
221 |
|
222 |
DynField setMaxValue(Object maxValue);
|
223 |
|
224 |
/**
|
225 |
* Sets the class used for the values of the field.
|
226 |
*
|
227 |
* @param theClass
|
228 |
*
|
229 |
* @return this same {@link DynField} object
|
230 |
*
|
231 |
* @throws DynFieldIsNotAContainerException
|
232 |
*/
|
233 |
DynField setClassOfValue(Class theClass) throws DynFieldIsNotAContainerException; |
234 |
|
235 |
/**
|
236 |
* If field type is List, Set or Map, this class is the class of items.
|
237 |
*
|
238 |
* @param theClass
|
239 |
*
|
240 |
* @return this same {@link DynField} object
|
241 |
*
|
242 |
* @throws DynFieldIsNotAContainerException
|
243 |
*/
|
244 |
DynField setClassOfItems(Class theClass) throws DynFieldIsNotAContainerException; |
245 |
|
246 |
/**
|
247 |
* Sets if the field is readOnly or not. The meaning of being
|
248 |
* readOnly allows to know if the user input to any graphic component associated
|
249 |
* to this field should be allowed or not.
|
250 |
* @param isReadOnly
|
251 |
* if the graphic component associated to this field should be readOnly or not
|
252 |
*
|
253 |
* @return DynField that define the type of elements.
|
254 |
*/
|
255 |
public DynField setReadOnly(boolean isReadOnly); |
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
/**
|
264 |
* When a field is of type container, this method return a DynClass
|
265 |
* that define the type of elements.
|
266 |
* When the type is DYNOBJECT return the DynClass associated
|
267 |
* to this.
|
268 |
*
|
269 |
* Return null if the type not is a container.
|
270 |
*
|
271 |
* @return DynField that define the type of elements.
|
272 |
*/
|
273 |
public DynField getElementsType();
|
274 |
|
275 |
/**
|
276 |
* Set the type of items when the field is a container.
|
277 |
*
|
278 |
* El tipo de los elementos de un container esta definido
|
279 |
* mediante un DynField, que crea con el tipo pasado por
|
280 |
* parametro y lo devuelve este metodo.
|
281 |
*
|
282 |
* @param tipo de los elementos
|
283 |
* @return this same {@link DynField} object
|
284 |
* @throws DynFieldIsNotAContainerException
|
285 |
*/
|
286 |
public DynField setElementsType(int type) throws DynFieldIsNotAContainerException ; |
287 |
|
288 |
/**
|
289 |
* Set the type of items when the field is a container.
|
290 |
*
|
291 |
* Metodo de utilidad que establece el typo de DYNOBJECT y
|
292 |
* methe como subtipo el DynStruct pasado como parametro.
|
293 |
*
|
294 |
* @param tipo de los elementos
|
295 |
* @return this same {@link DynField} object
|
296 |
* @throws DynFieldIsNotAContainerException
|
297 |
*/
|
298 |
public DynField setElementsType(DynStruct type) throws DynFieldIsNotAContainerException ; |
299 |
|
300 |
|
301 |
|
302 |
/**
|
303 |
* Validate that the value match the properties of the field.
|
304 |
*
|
305 |
* @param value
|
306 |
* @throws DynFieldValidateException
|
307 |
*/
|
308 |
void validate(Object value) throws DynFieldValidateException; |
309 |
|
310 |
/**
|
311 |
* Force the type of value to the type of the field.
|
312 |
*
|
313 |
* @param value
|
314 |
* @return new value
|
315 |
* @throws CoercionException
|
316 |
*/
|
317 |
Object coerce(Object value) throws CoercionException; |
318 |
|
319 |
/**
|
320 |
* If the field value can be any possible value, for its type.
|
321 |
*
|
322 |
* @deprecated now autodetect the mode of use
|
323 |
*/
|
324 |
static final int ANY = 1; |
325 |
|
326 |
/**
|
327 |
* If the field value must be one of a list of posible values.
|
328 |
*
|
329 |
* @deprecated usado automaticamente al asignar AvailableValues
|
330 |
*/
|
331 |
static final int CHOICE = 2; |
332 |
|
333 |
/**
|
334 |
* If the field value must pertain to a range of possible values.
|
335 |
*
|
336 |
* @deprecated usado automaticamente al asignar minValue/maxValue
|
337 |
*/
|
338 |
static final int RANGE = 3; |
339 |
|
340 |
/**
|
341 |
* @deprecated don't use, check minValue/maxValue and getAvailableValues instead
|
342 |
*/
|
343 |
int getTheTypeOfAvailableValues(); // SINGLE, CHOICE o RANGE |
344 |
|
345 |
/**
|
346 |
* @deprecated use instead {@link #setDefaultValue(Object)}
|
347 |
*/
|
348 |
DynField setDefaultDynValue(Object defaultValue);
|
349 |
|
350 |
/**
|
351 |
* @deprecated don't use, set minValue/maxValue and availableValues instead
|
352 |
*/
|
353 |
DynField setTheTypeOfAvailableValues(int type);
|
354 |
|
355 |
} |