svn-gvsig-desktop / branches / dal_time_support / libraries / libFMap_dal / src / org / gvsig / fmap / dal / feature / AbstractFeatureStoreTransform.java @ 35770
History | View | Annotate | Download (3.04 KB)
1 |
package org.gvsig.fmap.dal.feature; |
---|---|
2 |
|
3 |
import java.util.ArrayList; |
4 |
import java.util.List; |
5 |
|
6 |
import org.gvsig.fmap.dal.exception.DataException; |
7 |
import org.gvsig.tools.ToolsLocator; |
8 |
import org.gvsig.tools.dynobject.DynStruct; |
9 |
import org.gvsig.tools.persistence.PersistentState; |
10 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
11 |
|
12 |
/**
|
13 |
* Abstract feature store transform intended for giving a partial default implementation
|
14 |
* of the {@link FeatureStoreTransform} interface to other transform implementations. It is recommended
|
15 |
* to extend this class when implementing new {@link FeatureStoreTransform}s.
|
16 |
*
|
17 |
*/
|
18 |
public abstract class AbstractFeatureStoreTransform implements |
19 |
FeatureStoreTransform { |
20 |
public static final String ABSTRACT_FEATURESTORE_DYNCLASS_NAME = "AbstractFeatureStoreTransform"; |
21 |
|
22 |
private FeatureStore store;
|
23 |
|
24 |
private FeatureType defaultFeatureType = null; |
25 |
private List featureTypes = new ArrayList(); |
26 |
|
27 |
protected String name; |
28 |
|
29 |
protected String descripcion; |
30 |
|
31 |
|
32 |
|
33 |
public AbstractFeatureStoreTransform() {
|
34 |
this("", ""); |
35 |
} |
36 |
|
37 |
public AbstractFeatureStoreTransform(String name, String description) { |
38 |
if( name == null || "".equals(name) ) { |
39 |
this.name = this.getClass().getSimpleName(); |
40 |
} else {
|
41 |
this.name = name;
|
42 |
} |
43 |
this.descripcion = description;
|
44 |
} |
45 |
|
46 |
public String getDescription() { |
47 |
return this.descripcion; |
48 |
} |
49 |
|
50 |
public String getName() { |
51 |
return this.name; |
52 |
} |
53 |
|
54 |
public FeatureType getDefaultFeatureType() throws DataException { |
55 |
return defaultFeatureType;
|
56 |
} |
57 |
|
58 |
public List getFeatureTypes() throws DataException { |
59 |
return featureTypes;
|
60 |
} |
61 |
|
62 |
public void setFeatureStore(FeatureStore store) { |
63 |
this.store = store;
|
64 |
} |
65 |
|
66 |
public FeatureStore getFeatureStore() {
|
67 |
return store;
|
68 |
} |
69 |
|
70 |
protected void setFeatureTypes(List types, FeatureType defaultType) { |
71 |
this.featureTypes.clear();
|
72 |
this.featureTypes.addAll(types);
|
73 |
this.defaultFeatureType = defaultType;
|
74 |
} |
75 |
|
76 |
public static void registerPersistent() { |
77 |
DynStruct definition = ToolsLocator.getPersistenceManager().addDefinition( |
78 |
AbstractFeatureStoreTransform.class, |
79 |
ABSTRACT_FEATURESTORE_DYNCLASS_NAME, |
80 |
"AbstractFeatureStoreTransform Persistent definition",
|
81 |
null,
|
82 |
null
|
83 |
); |
84 |
|
85 |
definition.addDynFieldObject("store")
|
86 |
.setClassOfValue(FeatureStore.class) |
87 |
.setMandatory(true);
|
88 |
definition.addDynFieldObject("defaultFeatureType")
|
89 |
.setClassOfValue(FeatureType.class) |
90 |
.setMandatory(true);
|
91 |
definition.addDynFieldList("featureTypes")
|
92 |
.setClassOfItems(FeatureType.class) |
93 |
.setMandatory(true);
|
94 |
|
95 |
} |
96 |
|
97 |
public void loadFromState(PersistentState state) throws PersistenceException { |
98 |
this.store = (FeatureStore) state.get("store"); |
99 |
this.defaultFeatureType = (FeatureType) state.get("defaultFeatureType"); |
100 |
this.featureTypes = new ArrayList(state.getList("featureTypes")); |
101 |
} |
102 |
|
103 |
public void saveToState(PersistentState state) throws PersistenceException { |
104 |
state.set("store", store);
|
105 |
state.set("defaultFeatureType", defaultFeatureType);
|
106 |
state.set("featureTypes", featureTypes);
|
107 |
} |
108 |
|
109 |
|
110 |
} |