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