gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dynobject / DynField.java @ 202
History | View | Annotate | Download (5.51 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 |
* If the field value can be any possible value, for its type.
|
23 |
*
|
24 |
* @deprecated now autodetect the mode of use
|
25 |
*/
|
26 |
static final int ANY = 1; |
27 |
|
28 |
/**
|
29 |
* If the field value must be one of a list of posible values.
|
30 |
*
|
31 |
* @deprecated usado automaticamente al asignar AvailableValues
|
32 |
*/
|
33 |
static final int CHOICE = 2; |
34 |
|
35 |
/**
|
36 |
* If the field value must pertain to a range of possible values.
|
37 |
*
|
38 |
* @deprecated usado automaticamente al asignar minValue/maxValue
|
39 |
*/
|
40 |
static final int RANGE = 3; |
41 |
|
42 |
String getName();
|
43 |
|
44 |
int getType();
|
45 |
|
46 |
String getSubtype();
|
47 |
|
48 |
String getDescription();
|
49 |
|
50 |
Object getDefaultValue();
|
51 |
|
52 |
boolean isMandatory();
|
53 |
|
54 |
String getGroup();
|
55 |
int getOder();
|
56 |
|
57 |
/**
|
58 |
* Returns if the field is persistent or volatile. The meaning of being
|
59 |
* persistent depends on how is persisted, but any persistence mechanism
|
60 |
* must avoid persisting this field value.
|
61 |
* @return if the field is to be persisted or not
|
62 |
*/
|
63 |
boolean isPersistent();
|
64 |
|
65 |
boolean isHidden();
|
66 |
|
67 |
/**
|
68 |
* @deprecated don't use, check minValue/maxValue and getAvailableValues instead
|
69 |
*/
|
70 |
int getTheTypeOfAvailableValues(); // SINGLE, CHOICE o RANGE |
71 |
|
72 |
DynObjectValueItem[] getAvailableValues();
|
73 |
|
74 |
Object getMinValue();
|
75 |
|
76 |
Object getMaxValue();
|
77 |
|
78 |
Class getClassOfValue();
|
79 |
|
80 |
DynField setDescription(String description);
|
81 |
|
82 |
DynField setType(int type);
|
83 |
|
84 |
/**
|
85 |
* Cuando el tipo sea #{@link DataTypes#DYNOBJECT}, el
|
86 |
* subtype sera el fullname de la DynStruct.
|
87 |
*
|
88 |
* @param subtype
|
89 |
* @return
|
90 |
*/
|
91 |
DynField setSubtype(String subtype);
|
92 |
|
93 |
DynField setDefaultDynValue(Object defaultValue);
|
94 |
|
95 |
DynField setMandatory(boolean mandatory);
|
96 |
|
97 |
DynField setGroup(String groupName);
|
98 |
|
99 |
DynField setHidden(boolean hidden);
|
100 |
|
101 |
DynField setOrder(int order);
|
102 |
/**
|
103 |
* Sets if the field must be persisted or not.
|
104 |
* @see #isPersistent()
|
105 |
* @param persistent if the field must be persisted or not
|
106 |
* @return this same {@link DynField} object
|
107 |
*/
|
108 |
DynField setPersistent(boolean persistent);
|
109 |
|
110 |
/**
|
111 |
* @deprecated don't use, set minValue/maxValue and availableValues instead
|
112 |
*/
|
113 |
DynField setTheTypeOfAvailableValues(int type);
|
114 |
|
115 |
DynField setAvailableValues(DynObjectValueItem[] values);
|
116 |
|
117 |
DynField setAvailableValues(List values);
|
118 |
|
119 |
DynField setMinValue(Object minValue);
|
120 |
|
121 |
DynField setMaxValue(Object maxValue);
|
122 |
|
123 |
/**
|
124 |
* When a field is type object, this is the class of the object.
|
125 |
* If field type is List, Set or Map, this class is the class of items.
|
126 |
*
|
127 |
* @param theClass
|
128 |
* @return this same {@link DynField} object
|
129 |
* @throws DynFieldIsNotAContainerException
|
130 |
*/
|
131 |
DynField setClassOfValue(Class theClass) throws DynFieldIsNotAContainerException; |
132 |
|
133 |
/**
|
134 |
* Validate that the value match the properties of the field.
|
135 |
*
|
136 |
* @param value
|
137 |
* @throws DynFieldValidateException
|
138 |
*/
|
139 |
void validate(Object value) throws DynFieldValidateException; |
140 |
|
141 |
/**
|
142 |
* Force the type of value to the type of the field.
|
143 |
*
|
144 |
* @param value
|
145 |
* @return new value
|
146 |
* @throws CoercionException
|
147 |
*/
|
148 |
Object coerce(Object value) throws CoercionException; |
149 |
|
150 |
/**
|
151 |
* When a field is of type container, this method return a DynClass
|
152 |
* that define the type of elements.
|
153 |
* When the type is DYNOBJECT return the DynClass associated
|
154 |
* to this.
|
155 |
*
|
156 |
* Return null if the type not is a container.
|
157 |
*
|
158 |
* @return DynField that define the type of elements.
|
159 |
*/
|
160 |
public DynField getElementsType();
|
161 |
|
162 |
/**
|
163 |
* Set the type of items when the field is a container.
|
164 |
*
|
165 |
* El tipo de los elementos de un container esta definido
|
166 |
* mediante un DynField, que crea con el tipo pasado por
|
167 |
* parametro y lo devuelve este metodo.
|
168 |
*
|
169 |
* @param tipo de los elementos
|
170 |
* @return this same {@link DynField} object
|
171 |
* @throws DynFieldIsNotAContainerException
|
172 |
*/
|
173 |
public DynField setElementsType(int type) throws DynFieldIsNotAContainerException ; |
174 |
|
175 |
/**
|
176 |
* Set the type of items when the field is a container.
|
177 |
*
|
178 |
* Metodo de utilidad que establece el typo de DYNOBJECT y
|
179 |
* methe como subtipo el DynStruct pasado como parametro.
|
180 |
*
|
181 |
* @param tipo de los elementos
|
182 |
* @return this same {@link DynField} object
|
183 |
* @throws DynFieldIsNotAContainerException
|
184 |
*/
|
185 |
public DynField setElementsType(DynStruct type) throws DynFieldIsNotAContainerException ; |
186 |
|
187 |
/**
|
188 |
* Returns if the field is readOnly or not. The meaning of being
|
189 |
* readOnly allows to know if the user input to any graphic component associated
|
190 |
* to this field should be allowed or not.
|
191 |
* @return if the graphic component associated to this field should be readOnly or not
|
192 |
*/
|
193 |
public boolean isReadOnly(); |
194 |
|
195 |
/**
|
196 |
* Sets if the field is readOnly or not. The meaning of being
|
197 |
* readOnly allows to know if the user input to any graphic component associated
|
198 |
* to this field should be allowed or not.
|
199 |
* @param isReadOnly
|
200 |
* if the graphic component associated to this field should be readOnly or not
|
201 |
*
|
202 |
* @return DynField that define the type of elements.
|
203 |
*/
|
204 |
public DynField setReadOnly(boolean isReadOnly); |
205 |
|
206 |
|
207 |
public boolean isContainer(); |
208 |
} |