gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / dynobject / DynField.java @ 120
History | View | Annotate | Download (4.64 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.dynobject.exception.DynFieldIsNotAContainerException; |
7 |
import org.gvsig.tools.dynobject.exception.DynFieldValidateException; |
8 |
|
9 |
/**
|
10 |
* A field of a {@link DynObject}.
|
11 |
* <p>
|
12 |
* A field will be persisted only if it is set as persistent (@see
|
13 |
* {@link DynField#isPersistent()}, which is the default value.
|
14 |
* </p>
|
15 |
*
|
16 |
* @author <a href="mailto:jjdelcerro@gvsig.org">Joaqu�n Jos� del Cerro</a>
|
17 |
*/
|
18 |
public interface DynField { |
19 |
|
20 |
/**
|
21 |
* If the field value can be any possible value, for its type.
|
22 |
*
|
23 |
* @deprecated now autodetect the mode of use
|
24 |
*/
|
25 |
static final int ANY = 1; |
26 |
|
27 |
/**
|
28 |
* If the field value must be one of a list of posible values.
|
29 |
*
|
30 |
* @deprecated usado automaticamente al asignar AvailableValues
|
31 |
*/
|
32 |
static final int CHOICE = 2; |
33 |
|
34 |
/**
|
35 |
* If the field value must pertain to a range of possible values.
|
36 |
*
|
37 |
* @deprecated usado automaticamente al asignar minValue/maxValue
|
38 |
*/
|
39 |
static final int RANGE = 3; |
40 |
|
41 |
String getName();
|
42 |
|
43 |
int getType();
|
44 |
|
45 |
String getSubtype();
|
46 |
|
47 |
String getDescription();
|
48 |
|
49 |
Object getDefaultValue();
|
50 |
|
51 |
boolean isMandatory();
|
52 |
|
53 |
String getGroup();
|
54 |
int getOder();
|
55 |
|
56 |
/**
|
57 |
* Returns if the field is persistent or volatile. The meaning of being
|
58 |
* persistent depends on how is persisted, but any persistence mechanism
|
59 |
* must avoid persisting this field value.
|
60 |
* @return if the field is to be persisted or not
|
61 |
*/
|
62 |
boolean isPersistent();
|
63 |
|
64 |
boolean isHidden();
|
65 |
|
66 |
/**
|
67 |
* @deprecated don't use, check minValue/maxValue and getAvailableValues instead
|
68 |
*/
|
69 |
int getTheTypeOfAvailableValues(); // SINGLE, CHOICE o RANGE |
70 |
|
71 |
DynObjectValueItem[] getAvailableValues();
|
72 |
|
73 |
Object getMinValue();
|
74 |
|
75 |
Object getMaxValue();
|
76 |
|
77 |
Class getClassOfValue();
|
78 |
|
79 |
DynField setDescription(String description);
|
80 |
|
81 |
DynField setType(int type);
|
82 |
|
83 |
DynField setSubtype(String subtype);
|
84 |
|
85 |
DynField setDefaultDynValue(Object defaultValue);
|
86 |
|
87 |
DynField setMandatory(boolean mandatory);
|
88 |
|
89 |
DynField setGroup(String groupName);
|
90 |
|
91 |
DynField setHidden(boolean hidden);
|
92 |
|
93 |
DynField setOrder(int order);
|
94 |
/**
|
95 |
* Sets if the field must be persisted or not.
|
96 |
* @see #isPersistent()
|
97 |
* @param persistent if the field must be persisted or not
|
98 |
* @return this same {@link DynField} object
|
99 |
*/
|
100 |
DynField setPersistent(boolean persistent);
|
101 |
|
102 |
/**
|
103 |
* @deprecated don't use, set minValue/maxValue and availableValues instead
|
104 |
*/
|
105 |
DynField setTheTypeOfAvailableValues(int type);
|
106 |
|
107 |
DynField setAvailableValues(DynObjectValueItem[] values);
|
108 |
|
109 |
DynField setAvailableValues(List values);
|
110 |
|
111 |
DynField setMinValue(Object minValue);
|
112 |
|
113 |
DynField setMaxValue(Object maxValue);
|
114 |
|
115 |
/**
|
116 |
* When a field is type object, this is the class of the object.
|
117 |
* If field type is List, Set or Map, this class is the class of items.
|
118 |
*
|
119 |
* @param theClass
|
120 |
* @return this same {@link DynField} object
|
121 |
* @throws DynFieldIsNotAContainerException
|
122 |
*/
|
123 |
DynField setClassOfValue(Class theClass) throws DynFieldIsNotAContainerException; |
124 |
|
125 |
/**
|
126 |
* Validate that the value match the properties of the field.
|
127 |
*
|
128 |
* @param value
|
129 |
* @throws DynFieldValidateException
|
130 |
*/
|
131 |
void validate(Object value) throws DynFieldValidateException; |
132 |
|
133 |
/**
|
134 |
* Force the type of value to the type of the field.
|
135 |
*
|
136 |
* @param value
|
137 |
* @return new value
|
138 |
* @throws CoercionException
|
139 |
*/
|
140 |
Object coerce(Object value) throws CoercionException; |
141 |
|
142 |
/**
|
143 |
* When a field is of type container, this method return a DynClass
|
144 |
* that define the type of elements.
|
145 |
* When the type is DYNOBJECT return the DynClass associated
|
146 |
* to this.
|
147 |
*
|
148 |
* Return null if the type not is a container.
|
149 |
*
|
150 |
* @return DynClass that define the type of elements.
|
151 |
*/
|
152 |
public DynStruct getElementsType();
|
153 |
|
154 |
/**
|
155 |
* Set the type of items when the field is a container.
|
156 |
* When the type is DYNOBJECT is the DynClass associated
|
157 |
* to this.
|
158 |
*
|
159 |
* @param definition
|
160 |
* @return this same {@link DynField} object
|
161 |
* @throws DynFieldIsNotAContainerException
|
162 |
*/
|
163 |
public DynField setElementsType(DynStruct definition) throws DynFieldIsNotAContainerException ; |
164 |
|
165 |
|
166 |
/**
|
167 |
* Create a DynClass and asociate to the elements of this
|
168 |
* container field and return the unique field defined in this
|
169 |
* DynClass.
|
170 |
*
|
171 |
* This method is a utility method for define the type
|
172 |
* of elements of a container when this elements are
|
173 |
* basic types and not compound objects.
|
174 |
*
|
175 |
* The name of the DynField and DynClass created are
|
176 |
* the same as this field.
|
177 |
*
|
178 |
* @return DynField that define the type of elements.
|
179 |
* @throws DynFieldIsNotAContainerException
|
180 |
*/
|
181 |
public DynField addElementsType() throws DynFieldIsNotAContainerException ; |
182 |
|
183 |
} |