root / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / fmap / data / feature / AttributeDescriptor.java @ 23303
History | View | Annotate | Download (15.6 KB)
1 | 19399 | vcaballero | |
---|---|---|---|
2 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
3 | *
|
||
4 | * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * Generalitat Valenciana
|
||
23 | * Conselleria d'Infraestructures i Transport
|
||
24 | * Av. Blasco Ib??ez, 50
|
||
25 | * 46010 VALENCIA
|
||
26 | * SPAIN
|
||
27 | *
|
||
28 | * +34 963862235
|
||
29 | * gvsig@gva.es
|
||
30 | * www.gvsig.gva.es
|
||
31 | *
|
||
32 | * or
|
||
33 | *
|
||
34 | * IVER T.I. S.A
|
||
35 | * Salamanca 50
|
||
36 | * 46005 Valencia
|
||
37 | * Spain
|
||
38 | *
|
||
39 | * +34 963163400
|
||
40 | * dac@iver.es
|
||
41 | */
|
||
42 | |||
43 | 22360 | jmvivo | package org.gvsig.fmap.data.feature; |
44 | 19399 | vcaballero | |
45 | 20907 | jmvivo | import java.lang.ref.WeakReference; |
46 | |||
47 | 23214 | jmvivo | import org.gvsig.fmap.data.feature.expressionevaluator.AttributeValueEvaluator; |
48 | 19399 | vcaballero | |
49 | 20412 | vcaballero | |
50 | 23123 | jmvivo | |
51 | 19399 | vcaballero | /**
|
52 | * DOCUMENT ME!
|
||
53 | *
|
||
54 | * @author Vicente Caballero Navarro
|
||
55 | */
|
||
56 | 21045 | jmvivo | public class AttributeDescriptor implements FeatureAttributeDescriptor { |
57 | 19399 | vcaballero | private String name = null; |
58 | 21045 | jmvivo | private String type = FeatureAttributeDescriptor.TYPE_STRING; |
59 | 19399 | vcaballero | private int size = 0; |
60 | private int precision = 0; |
||
61 | private int minimumOccurrences = 0; |
||
62 | private int maximumOccurences = 0; |
||
63 | private boolean isPrimaryKey = false; |
||
64 | private int ordinal = 0; |
||
65 | private Object defaultValue; |
||
66 | private int geometryType; |
||
67 | private String featureType; |
||
68 | 19414 | vcaballero | private String srs; |
69 | 19620 | jmvivo | private boolean allowNull; |
70 | 23214 | jmvivo | private AttributeValueEvaluator evaluator;
|
71 | 20084 | jmvivo | protected boolean readOnly; |
72 | 20449 | jmvivo | protected boolean evaluated; |
73 | 20084 | jmvivo | protected String expression; |
74 | 19399 | vcaballero | |
75 | 20419 | vcaballero | protected boolean editing = false; |
76 | 20848 | jmvivo | protected AttributeDescriptor newAttributeDescriptor;
|
77 | 20419 | vcaballero | protected boolean loading = false; |
78 | 20500 | vcaballero | private int originalPosition=-1; |
79 | 20848 | jmvivo | private boolean isNew=false; |
80 | private Class objectClass; |
||
81 | 23303 | jmvivo | private WeakReference wfFeatureType; |
82 | 20412 | vcaballero | |
83 | 21045 | jmvivo | protected AttributeDescriptor(FeatureType featureType) {
|
84 | 20907 | jmvivo | this.wfFeatureType = new WeakReference(featureType); |
85 | 20848 | jmvivo | this.isNew=false; |
86 | 19399 | vcaballero | } |
87 | 20848 | jmvivo | |
88 | 21045 | jmvivo | protected AttributeDescriptor(FeatureType featureType,boolean asNew) { |
89 | 20907 | jmvivo | this.wfFeatureType = new WeakReference(featureType); |
90 | 20848 | jmvivo | this.isNew=asNew;
|
91 | } |
||
92 | |||
93 | 21045 | jmvivo | protected FeatureType getFeatureType(){
|
94 | 20907 | jmvivo | if (this.wfFeatureType == null){ |
95 | 23303 | jmvivo | throw new RuntimeException(); |
96 | // return null;
|
||
97 | 20907 | jmvivo | } |
98 | 23303 | jmvivo | FeatureType ftype = (FeatureType) this.wfFeatureType.get();
|
99 | if (ftype == null) { |
||
100 | throw new RuntimeException(); |
||
101 | } |
||
102 | return ftype;
|
||
103 | 20907 | jmvivo | } |
104 | |||
105 | 21045 | jmvivo | public boolean isFromFeatureType(FeatureType featureType){ |
106 | FeatureType myFtype= this.getFeatureType();
|
||
107 | 20907 | jmvivo | if (myFtype == null){ |
108 | return false; |
||
109 | } |
||
110 | return myFtype == featureType;
|
||
111 | } |
||
112 | |||
113 | 19399 | vcaballero | /* (non-Javadoc)
|
114 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getName()
|
115 | 19399 | vcaballero | */
|
116 | public String getName() { |
||
117 | 20848 | jmvivo | if (useNewAttributeValue()){
|
118 | return this.newAttributeDescriptor.getName(); |
||
119 | } |
||
120 | 19399 | vcaballero | return name;
|
121 | } |
||
122 | |||
123 | /* (non-Javadoc)
|
||
124 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getDataType()
|
125 | 19399 | vcaballero | */
|
126 | public String getDataType() { |
||
127 | 20848 | jmvivo | if (useNewAttributeValue()){
|
128 | return this.newAttributeDescriptor.getDataType(); |
||
129 | } |
||
130 | 19399 | vcaballero | return type;
|
131 | } |
||
132 | |||
133 | /* (non-Javadoc)
|
||
134 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getSize()
|
135 | 19399 | vcaballero | */
|
136 | public int getSize() { |
||
137 | 20848 | jmvivo | if (useNewAttributeValue()){
|
138 | return this.newAttributeDescriptor.getSize(); |
||
139 | } |
||
140 | 19399 | vcaballero | return size;
|
141 | } |
||
142 | |||
143 | /* (non-Javadoc)
|
||
144 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getPrecision()
|
145 | 19399 | vcaballero | */
|
146 | public int getPrecision() { |
||
147 | 20848 | jmvivo | if (useNewAttributeValue()){
|
148 | return this.newAttributeDescriptor.getPrecision(); |
||
149 | } |
||
150 | 19399 | vcaballero | return precision;
|
151 | } |
||
152 | |||
153 | /**
|
||
154 | * DOCUMENT ME!
|
||
155 | *
|
||
156 | * @return DOCUMENT ME!
|
||
157 | */
|
||
158 | public Class getObjectClass() { |
||
159 | 20848 | jmvivo | if (useNewAttributeValue()){
|
160 | return this.newAttributeDescriptor.getObjectClass(); |
||
161 | } |
||
162 | return objectClass;
|
||
163 | 19399 | vcaballero | } |
164 | |||
165 | /* (non-Javadoc)
|
||
166 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getMinimumOccurrences()
|
167 | 19399 | vcaballero | */
|
168 | public int getMinimumOccurrences() { |
||
169 | 20848 | jmvivo | if (useNewAttributeValue()){
|
170 | return this.newAttributeDescriptor.getMinimumOccurrences(); |
||
171 | } |
||
172 | 19399 | vcaballero | return minimumOccurrences;
|
173 | } |
||
174 | |||
175 | /* (non-Javadoc)
|
||
176 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#getMaximumOccurrences()
|
177 | 19399 | vcaballero | */
|
178 | public int getMaximumOccurrences() { |
||
179 | 20848 | jmvivo | if (useNewAttributeValue()){
|
180 | return this.newAttributeDescriptor.getMaximumOccurrences(); |
||
181 | } |
||
182 | 19399 | vcaballero | return maximumOccurences;
|
183 | 20848 | jmvivo | |
184 | 19399 | vcaballero | } |
185 | |||
186 | /* (non-Javadoc)
|
||
187 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#isPrimaryKey()
|
188 | 19399 | vcaballero | */
|
189 | public boolean isPrimaryKey() { |
||
190 | 20848 | jmvivo | if (useNewAttributeValue()){
|
191 | return this.newAttributeDescriptor.isPrimaryKey(); |
||
192 | } |
||
193 | 19399 | vcaballero | return isPrimaryKey;
|
194 | } |
||
195 | |||
196 | /* (non-Javadoc)
|
||
197 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#ordinal()
|
198 | 19399 | vcaballero | */
|
199 | public int ordinal() { |
||
200 | 20848 | jmvivo | if (useNewAttributeValue()){
|
201 | return this.newAttributeDescriptor.ordinal(); |
||
202 | } else {
|
||
203 | return ordinal;
|
||
204 | } |
||
205 | 19399 | vcaballero | } |
206 | 20848 | jmvivo | public void setPrimaryKey(boolean isPrimaryKey) throws IsNotAttributeSettingException { |
207 | canSetValue(); |
||
208 | if (useNewAttributeValue()){
|
||
209 | this.newAttributeDescriptor.loading();
|
||
210 | this.newAttributeDescriptor.setPrimaryKey(isPrimaryKey);
|
||
211 | this.newAttributeDescriptor.stopLoading();
|
||
212 | } else {
|
||
213 | this.isPrimaryKey = isPrimaryKey;
|
||
214 | } |
||
215 | 19399 | vcaballero | } |
216 | 20848 | jmvivo | public void setMaximumOccurences(int maximumOccurences) throws IsNotAttributeSettingException { |
217 | canSetValue(); |
||
218 | if (useNewAttributeValue()){
|
||
219 | newAttributeDescriptor.loading(); |
||
220 | this.newAttributeDescriptor.setMaximumOccurences(maximumOccurences);
|
||
221 | newAttributeDescriptor.stopLoading(); |
||
222 | } else {
|
||
223 | this.maximumOccurences = maximumOccurences;
|
||
224 | } |
||
225 | 19399 | vcaballero | } |
226 | 20848 | jmvivo | public void setMinimumOccurrences(int minimumOccurrences) throws IsNotAttributeSettingException { |
227 | canSetValue(); |
||
228 | if (useNewAttributeValue()){
|
||
229 | newAttributeDescriptor.loading(); |
||
230 | this.newAttributeDescriptor.setMinimumOccurrences(minimumOccurrences);
|
||
231 | newAttributeDescriptor.stopLoading(); |
||
232 | } else {
|
||
233 | this.minimumOccurrences = minimumOccurrences;
|
||
234 | } |
||
235 | 19399 | vcaballero | } |
236 | 20412 | vcaballero | public void setName(String name) throws IsNotAttributeSettingException { |
237 | 20500 | vcaballero | canSetValue(); |
238 | 20848 | jmvivo | if (useNewAttributeValue()){
|
239 | newAttributeDescriptor.loading(); |
||
240 | newAttributeDescriptor.setName(name); |
||
241 | newAttributeDescriptor.stopLoading(); |
||
242 | |||
243 | }else{
|
||
244 | 20500 | vcaballero | this.name = name;
|
245 | 20848 | jmvivo | } |
246 | 19399 | vcaballero | } |
247 | 20412 | vcaballero | |
248 | /**
|
||
249 | * M?todo ?nicamente utilizado desde esta librer?a en el DefaultFeatureType.add();
|
||
250 | 20848 | jmvivo | * @throws IsNotAttributeSettingException
|
251 | 20412 | vcaballero | */
|
252 | 20848 | jmvivo | void setOrdinal(int ordinal){ |
253 | if (useNewAttributeValue()){
|
||
254 | newAttributeDescriptor.loading(); |
||
255 | newAttributeDescriptor.setOrdinal(ordinal); |
||
256 | newAttributeDescriptor.stopLoading(); |
||
257 | }else{
|
||
258 | this.ordinal = ordinal;
|
||
259 | } |
||
260 | 19399 | vcaballero | } |
261 | 20848 | jmvivo | |
262 | 20412 | vcaballero | public void setPrecision(int precision) throws IsNotAttributeSettingException { |
263 | 20500 | vcaballero | canSetValue(); |
264 | 20848 | jmvivo | if (useNewAttributeValue()){
|
265 | newAttributeDescriptor.loading(); |
||
266 | newAttributeDescriptor.setPrecision(precision); |
||
267 | newAttributeDescriptor.stopLoading(); |
||
268 | }else{
|
||
269 | 20500 | vcaballero | this.precision = precision;
|
270 | 20848 | jmvivo | |
271 | } |
||
272 | 19399 | vcaballero | } |
273 | 20848 | jmvivo | |
274 | 20412 | vcaballero | public void setSize(int size) throws IsNotAttributeSettingException { |
275 | 20500 | vcaballero | canSetValue(); |
276 | 20848 | jmvivo | if (useNewAttributeValue()){
|
277 | newAttributeDescriptor.loading(); |
||
278 | newAttributeDescriptor.setSize(size); |
||
279 | newAttributeDescriptor.stopLoading(); |
||
280 | }else{
|
||
281 | 20500 | vcaballero | this.size = size;
|
282 | 20848 | jmvivo | } |
283 | 19399 | vcaballero | } |
284 | 20412 | vcaballero | public void setType(String type) throws IsNotAttributeSettingException { |
285 | 20500 | vcaballero | canSetValue(); |
286 | 20848 | jmvivo | if (useNewAttributeValue()){
|
287 | newAttributeDescriptor.loading(); |
||
288 | newAttributeDescriptor.setType(type); |
||
289 | newAttributeDescriptor.stopLoading(); |
||
290 | }else{
|
||
291 | this.type = type;
|
||
292 | } |
||
293 | 19399 | vcaballero | } |
294 | 20848 | jmvivo | |
295 | 19414 | vcaballero | public String getSRS() { |
296 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
297 | 20848 | jmvivo | return newAttributeDescriptor.getSRS();
|
298 | 22663 | jmvivo | } else {
|
299 | 20848 | jmvivo | return srs;
|
300 | 22663 | jmvivo | } |
301 | 19399 | vcaballero | } |
302 | 20412 | vcaballero | public void setSRS(String srs) throws IsNotAttributeSettingException { |
303 | 20500 | vcaballero | canSetValue(); |
304 | 20848 | jmvivo | if (useNewAttributeValue()){
|
305 | newAttributeDescriptor.loading(); |
||
306 | newAttributeDescriptor.setSRS(srs); |
||
307 | newAttributeDescriptor.stopLoading(); |
||
308 | }else{
|
||
309 | 20500 | vcaballero | this.srs=srs;
|
310 | 20848 | jmvivo | } |
311 | 19399 | vcaballero | } |
312 | public int getGeometryType() { |
||
313 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
314 | 20848 | jmvivo | return newAttributeDescriptor.getGeometryType();
|
315 | 22663 | jmvivo | } else {
|
316 | 20848 | jmvivo | return geometryType;
|
317 | 22663 | jmvivo | } |
318 | 19399 | vcaballero | } |
319 | 20848 | jmvivo | |
320 | 20412 | vcaballero | public void setGeometryType(int type) throws IsNotAttributeSettingException{ |
321 | 20500 | vcaballero | canSetValue(); |
322 | 20848 | jmvivo | if (useNewAttributeValue()){
|
323 | newAttributeDescriptor.loading(); |
||
324 | newAttributeDescriptor.setGeometryType(type); |
||
325 | newAttributeDescriptor.stopLoading(); |
||
326 | }else{
|
||
327 | 20500 | vcaballero | this.geometryType=type;
|
328 | 20848 | jmvivo | } |
329 | 19399 | vcaballero | } |
330 | public Object getDefaultValue() { |
||
331 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
332 | 20848 | jmvivo | return newAttributeDescriptor.getDefaultValue();
|
333 | 22663 | jmvivo | } else {
|
334 | 20848 | jmvivo | return defaultValue;
|
335 | 22663 | jmvivo | } |
336 | 19399 | vcaballero | } |
337 | 20848 | jmvivo | public void setDefaultValue(Object s) throws IsNotAttributeSettingException { |
338 | canSetValue(); |
||
339 | if (useNewAttributeValue()){
|
||
340 | newAttributeDescriptor.loading(); |
||
341 | newAttributeDescriptor.setDefaultValue(s); |
||
342 | newAttributeDescriptor.stopLoading(); |
||
343 | }else{
|
||
344 | this.defaultValue=s;
|
||
345 | } |
||
346 | 19399 | vcaballero | } |
347 | 19620 | jmvivo | |
348 | public boolean isAllowNull() { |
||
349 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
350 | 20848 | jmvivo | return newAttributeDescriptor.isAllowNull();
|
351 | 22663 | jmvivo | } else {
|
352 | 20848 | jmvivo | return allowNull;
|
353 | 22663 | jmvivo | } |
354 | 19620 | jmvivo | } |
355 | |||
356 | 20848 | jmvivo | public void setAllowNull(boolean allowNull) throws IsNotAttributeSettingException { |
357 | canSetValue(); |
||
358 | if (useNewAttributeValue()){
|
||
359 | newAttributeDescriptor.loading(); |
||
360 | newAttributeDescriptor.setAllowNull(allowNull); |
||
361 | newAttributeDescriptor.stopLoading(); |
||
362 | }else{
|
||
363 | this.allowNull = allowNull;
|
||
364 | } |
||
365 | 19620 | jmvivo | } |
366 | 20848 | jmvivo | |
367 | 21045 | jmvivo | public FeatureAttributeDescriptor cloneAttribute() {
|
368 | 20606 | vcaballero | AttributeDescriptor newFD = (AttributeDescriptor)newAttribute(); |
369 | 22663 | jmvivo | this.fillAttributeDescriptor(newFD);
|
370 | return newFD;
|
||
371 | } |
||
372 | |||
373 | protected void fillAttributeDescriptor(AttributeDescriptor newFD) { |
||
374 | 19695 | jmvivo | newFD.name = this.name;
|
375 | newFD.type = this.type;
|
||
376 | newFD.size = this.size;
|
||
377 | newFD.precision = this.precision;
|
||
378 | newFD.minimumOccurrences = this.minimumOccurrences;
|
||
379 | newFD.maximumOccurences = this.maximumOccurences;
|
||
380 | newFD.isPrimaryKey = this.isPrimaryKey;
|
||
381 | newFD.ordinal = this.ordinal;
|
||
382 | newFD.defaultValue = this.defaultValue;
|
||
383 | newFD.geometryType = this.geometryType;
|
||
384 | newFD.featureType = this.featureType;
|
||
385 | newFD.srs = this.srs;
|
||
386 | newFD.allowNull = this.allowNull;
|
||
387 | 20084 | jmvivo | newFD.evaluator = this.evaluator;
|
388 | 23303 | jmvivo | newFD.expression = this.expression;
|
389 | newFD.evaluated = this.evaluated;
|
||
390 | newFD.readOnly = this.readOnly;
|
||
391 | newFD.objectClass = this.objectClass;
|
||
392 | newFD.originalPosition = this.originalPosition;
|
||
393 | 22663 | jmvivo | } |
394 | 19620 | jmvivo | |
395 | 22663 | jmvivo | public void loadFrom(FeatureAttributeDescriptor otherFAD) { |
396 | if (otherFAD instanceof AttributeDescriptor) { |
||
397 | AttributeDescriptor otherFD = (AttributeDescriptor) otherFAD; |
||
398 | this.name = otherFD.name;
|
||
399 | this.type = otherFD.type;
|
||
400 | this.size = otherFD.size;
|
||
401 | this.precision = otherFD.precision;
|
||
402 | this.minimumOccurrences = otherFD.minimumOccurrences;
|
||
403 | this.maximumOccurences = otherFD.maximumOccurences;
|
||
404 | this.isPrimaryKey = otherFD.isPrimaryKey;
|
||
405 | this.ordinal = otherFD.ordinal;
|
||
406 | this.defaultValue = otherFD.defaultValue;
|
||
407 | this.geometryType = otherFD.geometryType;
|
||
408 | this.featureType = otherFD.featureType;
|
||
409 | this.srs = otherFD.srs;
|
||
410 | this.allowNull = otherFD.allowNull;
|
||
411 | this.evaluator = otherFD.evaluator;
|
||
412 | } |
||
413 | 19695 | jmvivo | } |
414 | |||
415 | 21045 | jmvivo | protected FeatureAttributeDescriptor newAttribute(){
|
416 | return ((DefaultFeatureType)this.getFeatureType()).createAttributeDescriptor(); |
||
417 | 19695 | jmvivo | } |
418 | |||
419 | 20084 | jmvivo | public boolean isValid() { |
420 | //TODO: Faltan mas comprobaciones
|
||
421 | 20449 | jmvivo | if (this.isEvaluated()){ |
422 | 20084 | jmvivo | if (this.evaluator == null){ |
423 | return false; |
||
424 | } |
||
425 | } |
||
426 | return true; |
||
427 | } |
||
428 | 19695 | jmvivo | |
429 | 23214 | jmvivo | public AttributeValueEvaluator getEvaluator() {
|
430 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
431 | 20848 | jmvivo | return newAttributeDescriptor.getEvaluator();
|
432 | 22663 | jmvivo | } else {
|
433 | 20848 | jmvivo | return evaluator;
|
434 | 22663 | jmvivo | } |
435 | 20084 | jmvivo | } |
436 | 23214 | jmvivo | public void setEvaluator(AttributeValueEvaluator evaluator) throws IsNotAttributeSettingException { |
437 | 20848 | jmvivo | canSetValue(); |
438 | if (useNewAttributeValue()){
|
||
439 | newAttributeDescriptor.loading(); |
||
440 | newAttributeDescriptor.setEvaluator(evaluator); |
||
441 | newAttributeDescriptor.stopLoading(); |
||
442 | }else{
|
||
443 | this.evaluator = evaluator;
|
||
444 | } |
||
445 | 20084 | jmvivo | } |
446 | public boolean isReadOnly() { |
||
447 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
448 | 20848 | jmvivo | return newAttributeDescriptor.isReadOnly();
|
449 | 22663 | jmvivo | } else {
|
450 | 20848 | jmvivo | return this.readOnly || this.isEvaluated(); |
451 | 22663 | jmvivo | } |
452 | 20084 | jmvivo | } |
453 | 19695 | jmvivo | |
454 | 20848 | jmvivo | public void setReadOnly(boolean readOnly) throws IsNotAttributeSettingException { |
455 | canSetValue(); |
||
456 | if (useNewAttributeValue()){
|
||
457 | newAttributeDescriptor.loading(); |
||
458 | newAttributeDescriptor.setReadOnly(readOnly); |
||
459 | newAttributeDescriptor.stopLoading(); |
||
460 | }else{
|
||
461 | this.readOnly = readOnly;
|
||
462 | } |
||
463 | 20084 | jmvivo | } |
464 | public String getExpression() { |
||
465 | return expression;
|
||
466 | } |
||
467 | 20848 | jmvivo | public void setExpression(String expression) throws IsNotAttributeSettingException { |
468 | canSetValue(); |
||
469 | if (useNewAttributeValue()){
|
||
470 | newAttributeDescriptor.loading(); |
||
471 | newAttributeDescriptor.setExpression(expression); |
||
472 | newAttributeDescriptor.stopLoading(); |
||
473 | }else{
|
||
474 | this.expression = expression;
|
||
475 | } |
||
476 | 20084 | jmvivo | } |
477 | 20848 | jmvivo | |
478 | 20412 | vcaballero | public void loading() { |
479 | loading=true;
|
||
480 | 20084 | jmvivo | |
481 | 20412 | vcaballero | } |
482 | public void stopLoading() { |
||
483 | loading=false;
|
||
484 | 20084 | jmvivo | |
485 | 20412 | vcaballero | } |
486 | public void editing() { |
||
487 | editing=true;
|
||
488 | 20848 | jmvivo | newAttributeDescriptor=(AttributeDescriptor) this.cloneAttribute();
|
489 | newAttributeDescriptor.setOriginalPosition(ordinal); |
||
490 | 20412 | vcaballero | } |
491 | public void cancelEditing() { |
||
492 | editing=false;
|
||
493 | 20500 | vcaballero | newAttributeDescriptor=null;
|
494 | 20412 | vcaballero | } |
495 | 21045 | jmvivo | public FeatureAttributeDescriptor getNewAttributeDescriptor() {
|
496 | 20500 | vcaballero | return newAttributeDescriptor;
|
497 | 20412 | vcaballero | } |
498 | 20449 | jmvivo | /* (non-Javadoc)
|
499 | 22360 | jmvivo | * @see org.gvsig.fmap.data.feature.FeatureAttributeDescriptor#isEvalued()
|
500 | 20449 | jmvivo | */
|
501 | public boolean isEvaluated() { |
||
502 | 22663 | jmvivo | if (useNewAttributeValue()) {
|
503 | 20848 | jmvivo | return this.newAttributeDescriptor.isEvaluated(); |
504 | 22663 | jmvivo | } else {
|
505 | 20848 | jmvivo | return this.evaluated; |
506 | 22663 | jmvivo | } |
507 | 20449 | jmvivo | } |
508 | |||
509 | 20848 | jmvivo | public void setEvalued(boolean evalued) throws IsNotAttributeSettingException{ |
510 | canSetValue(); |
||
511 | if (useNewAttributeValue()){
|
||
512 | newAttributeDescriptor.loading(); |
||
513 | newAttributeDescriptor.setEvalued(evalued); |
||
514 | newAttributeDescriptor.stopLoading(); |
||
515 | }else{
|
||
516 | this.evaluated = evalued;
|
||
517 | } |
||
518 | 20449 | jmvivo | } |
519 | 20469 | vcaballero | protected void stopEditing() { |
520 | editing=false;
|
||
521 | 20848 | jmvivo | if (this.isNew){ |
522 | this.isNew =false; |
||
523 | } |
||
524 | 20469 | vcaballero | } |
525 | 20500 | vcaballero | protected void canSetValue() throws IsNotAttributeSettingException { |
526 | if (!editing && !loading){
|
||
527 | throw new IsNotAttributeSettingException("set"); |
||
528 | } |
||
529 | if (!loading && isReadOnly()){
|
||
530 | //TODO Construir la clase adecuada para esta excepci?n
|
||
531 | throw new IsNotAttributeSettingException(" Read only field: " +getName()); |
||
532 | } |
||
533 | } |
||
534 | 20848 | jmvivo | |
535 | protected boolean useNewAttributeValue(){ |
||
536 | return this.editing && !this.isNew; |
||
537 | |||
538 | } |
||
539 | |||
540 | 20500 | vcaballero | public int originalPosition() { |
541 | if (originalPosition!=-1){ |
||
542 | return originalPosition;
|
||
543 | } |
||
544 | return ordinal;
|
||
545 | } |
||
546 | private void setOriginalPosition(int i){ |
||
547 | originalPosition=i; |
||
548 | } |
||
549 | 20848 | jmvivo | |
550 | /**
|
||
551 | * @return
|
||
552 | */
|
||
553 | public boolean isNew() { |
||
554 | return this.isNew; |
||
555 | } |
||
556 | 22664 | jmvivo | |
557 | public String toString() { |
||
558 | return this.getName() + "{" + this.getDataType() + "}"; |
||
559 | } |
||
560 | |||
561 | 23303 | jmvivo | protected void setFeatureType(DefaultFeatureType defaultFeatureType) { |
562 | // FIXME
|
||
563 | // this.wfFeatureType = new WeakReference(featureType);
|
||
564 | } |
||
565 | 22664 | jmvivo | |
566 | 23303 | jmvivo | |
567 | 19399 | vcaballero | } |