Revision 19399
trunk/libraries/libDataSource/src/org/gvsig/data/IDataSource.java | ||
---|---|---|
1 |
package org.gvsig.data; |
|
2 |
|
|
3 |
public interface IDataSource { |
|
4 |
|
|
5 |
public String getName(); |
|
6 |
|
|
7 |
public void init(IDataSourceParameters parameters); |
|
8 |
|
|
9 |
public IDataStoreParameters[] getSources(); |
|
10 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/IDataStoreNotification.java | ||
---|---|---|
1 |
package org.gvsig.data; |
|
2 |
|
|
3 |
|
|
4 |
public interface IDataStoreNotification { |
|
5 |
|
|
6 |
public static final String COMPLEX_NOTIFICATION = "complex_notification"; |
|
7 |
|
|
8 |
public static final String BEFORE_OPEN = "before_Open_DataStore"; |
|
9 |
public static final String AFTER_OPEN = "after_Open_DataStore"; |
|
10 |
public static final String BEFORE_CLOSE = "before_Close_DataStore"; |
|
11 |
public static final String AFTER_CLOSE = "after_Close_DataStore"; |
|
12 |
public static final String BEFORE_DISPOSE = "before_Dispose_DataStore"; |
|
13 |
public static final String AFTER_DISPOSE = "after_Dispose_DataStore"; |
|
14 |
|
|
15 |
|
|
16 |
public static final String BEFORE_STARTEDITING = "before_StartEditing_DataStore"; |
|
17 |
public static final String BEFORE_CANCELEDITING = "before_CancelEditing_DataStore"; |
|
18 |
public static final String BEFORE_FINISHEDITING = "before_FinishEditing_DataStore"; |
|
19 |
|
|
20 |
public static final String AFTER_STARTEDITING = "after_StartEditing_DataStore"; |
|
21 |
public static final String AFTER_CANCELEDITING = "after_CancelEditing_DataStore"; |
|
22 |
public static final String AFTER_FINISHEDITING = "after_FinishEditing_DataStore"; |
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
public static final String BEFORE_UNDO = "before_Undo_DataStore"; |
|
27 |
public static final String BEFORE_REDO = "before_Redo_DataStore"; |
|
28 |
|
|
29 |
public static final String AFTER_UNDO = "after_Undo_DataStore"; |
|
30 |
public static final String AFTER_REDO = "after_Redo_DataStore"; |
|
31 |
|
|
32 |
public static final String BEFORE_SELECTIONCHANGE = "before_SelectionChange_DataStore"; |
|
33 |
public static final String AFTER_SELECTIONCHANGE = "after_SelectionChange_DataStore"; |
|
34 |
|
|
35 |
public static final String BEFORE_LOCKEDCHANGE = "before_LockedChange_DataStore"; |
|
36 |
public static final String AFTER_LOCKEDCHANGE = "after_LockedChange_DataStore"; |
|
37 |
|
|
38 |
public IDataStore getSource(); |
|
39 |
|
|
40 |
public String getType(); |
|
41 |
|
|
42 |
public IDataCollection getNewSelection(); |
|
43 |
|
|
44 |
public IDataCollection getPreviousSelection(); |
|
45 |
|
|
46 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/FeatureStoreNotification.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import org.gvsig.data.DataStoreNotification; |
|
4 |
import org.gvsig.data.IDataCollection; |
|
5 |
import org.gvsig.data.IDataStore; |
|
6 |
import org.gvsig.data.commands.ICommand; |
|
7 |
|
|
8 |
public class FeatureStoreNotification extends DataStoreNotification implements |
|
9 |
IFeatureStoreNotification { |
|
10 |
private IFeatureID featureID=null; |
|
11 |
private IFeature previousFeatureValue=null; |
|
12 |
private IDataCollection collectionResult = null; |
|
13 |
private boolean loadCollectionSucefully=false; |
|
14 |
private Exception exceptionLoading=null; |
|
15 |
|
|
16 |
public FeatureStoreNotification(IDataStore source, String type) { |
|
17 |
super(source, type); |
|
18 |
} |
|
19 |
|
|
20 |
public FeatureStoreNotification(IDataStore source, String type, IFeature feature) { |
|
21 |
super(source, type, feature); |
|
22 |
} |
|
23 |
public FeatureStoreNotification(IDataStore source, String type, ICommand command) { |
|
24 |
super(source, type, command); |
|
25 |
} |
|
26 |
public FeatureStoreNotification(IDataStore source, String type, |
|
27 |
IDataCollection previousSeCollection, IDataCollection newSelection) { |
|
28 |
super(source, type, previousSeCollection, newSelection); |
|
29 |
} |
|
30 |
|
|
31 |
public FeatureStoreNotification(IDataStore source, String type, IFeatureID featureId) { |
|
32 |
super(source, type); |
|
33 |
this.featureID = featureId; |
|
34 |
} |
|
35 |
|
|
36 |
public FeatureStoreNotification(IDataStore source, String type, IFeatureID featureID,IFeature previousFeatureValue) { |
|
37 |
super(source, type); |
|
38 |
this.featureID = featureID; |
|
39 |
this.previousFeatureValue = previousFeatureValue; |
|
40 |
} |
|
41 |
|
|
42 |
public FeatureStoreNotification(IDataStore source, String type, Exception exception) { |
|
43 |
super(source, type); |
|
44 |
this.loadCollectionSucefully = false; |
|
45 |
this.exceptionLoading = exception; |
|
46 |
} |
|
47 |
|
|
48 |
public FeatureStoreNotification(IDataStore source, String type, IDataCollection collection) { |
|
49 |
super(source, type); |
|
50 |
this.loadCollectionSucefully = true; |
|
51 |
this.collectionResult = collection; |
|
52 |
} |
|
53 |
|
|
54 |
|
|
55 |
public IFeatureID getFeatureID() { |
|
56 |
return featureID; |
|
57 |
} |
|
58 |
|
|
59 |
public IFeature getPreviousFeatureValue() { |
|
60 |
return previousFeatureValue; |
|
61 |
} |
|
62 |
|
|
63 |
public IDataCollection getCollectionResult() { |
|
64 |
return this.collectionResult; |
|
65 |
} |
|
66 |
|
|
67 |
public Exception getExceptionLoading() { |
|
68 |
return this.exceptionLoading; |
|
69 |
} |
|
70 |
|
|
71 |
public boolean loadSucefully() { |
|
72 |
return this.loadCollectionSucefully; |
|
73 |
} |
|
74 |
|
|
75 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureCollection.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import org.gvsig.data.IDataCollection; |
|
4 |
|
|
5 |
public interface IFeatureCollection extends IDataCollection { |
|
6 |
|
|
7 |
|
|
8 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureID.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
|
|
4 |
public interface IFeatureID { |
|
5 |
|
|
6 |
public IFeature getFeature(IFeatureType featureType); |
|
7 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureStore.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import java.text.DateFormat; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.gvsig.data.IDataCollection; |
|
7 |
import org.gvsig.data.IDataStore; |
|
8 |
import org.gvsig.data.IObserver; |
|
9 |
|
|
10 |
public interface IFeatureStore extends IDataStore{ |
|
11 |
|
|
12 |
public IDataCollection getDataCollection(IFeatureType type, String filter, String order); |
|
13 |
|
|
14 |
/** |
|
15 |
* Para la carga en background |
|
16 |
*/ |
|
17 |
public void getDataCollection(IFeatureType type, String filter, String order,IObserver observer); |
|
18 |
public void getDataCollection(IObserver observer); |
|
19 |
|
|
20 |
public IFeature getFeatureByID(IFeatureID id); |
|
21 |
// public IFeature getFeatureByPosition(long position); |
|
22 |
|
|
23 |
|
|
24 |
public List getFeatureTypes(); |
|
25 |
public IFeature createFeature(IFeatureType type); |
|
26 |
|
|
27 |
public IFeature createDefaultFeature(boolean defaultValues); |
|
28 |
public IFeatureType getDefaultFeatureType(); |
|
29 |
|
|
30 |
public void update(IFeature feature, IFeature oldFeature); |
|
31 |
public void delete(IFeature feature); |
|
32 |
public void insert(IFeature feature); |
|
33 |
|
|
34 |
public void update(IFeatureAttributeDescriptor attributeDescriptor, IFeatureAttributeDescriptor oldAttributeDescriptor); |
|
35 |
public void delete(IFeatureAttributeDescriptor attributeDescriptor); |
|
36 |
public void insert(IFeatureAttributeDescriptor attributeDescriptor); |
|
37 |
|
|
38 |
public void disableNotifications(); |
|
39 |
public void enableNotifications(); |
|
40 |
|
|
41 |
//Bloqueo en edici?n |
|
42 |
public boolean isLocked(IFeatureID id); |
|
43 |
public boolean lock(IFeatureID id); |
|
44 |
|
|
45 |
//Cuando el origen de datos define una leyenda a aplicar. |
|
46 |
public boolean isWithDefaultLegend(); |
|
47 |
public Object getDefaultLegend(); |
|
48 |
public Object getDefaultLabelingStrategy(); |
|
49 |
|
|
50 |
public boolean canAlterFeatureType(); |
|
51 |
public void write(IFeatureCollection collection, IFeatureType featureType); |
|
52 |
|
|
53 |
} |
|
54 |
|
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/MemoryFeature.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.text.ParseException; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.cresques.cts.IProjection; |
|
9 |
|
|
10 |
public class MemoryFeature extends Feature implements IFeature { |
|
11 |
public MemoryFeature(IFeatureType type,boolean defaultValues) { |
|
12 |
super(type); |
|
13 |
if (defaultValues){ |
|
14 |
Iterator iterator=type.iterator(); |
|
15 |
int i=0; |
|
16 |
while(iterator.hasNext()){ |
|
17 |
IFeatureAttributeDescriptor featureAttribute=(IFeatureAttributeDescriptor)iterator.next(); |
|
18 |
String attributeType=featureAttribute.getDataType(); |
|
19 |
Object defaultValue=featureAttribute.getDefaultValue(); |
|
20 |
if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
|
21 |
set(i,Byte.parseByte((String)defaultValue)); |
|
22 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
|
23 |
try { |
|
24 |
set(i,type.getDateFormat().parse((String)defaultValue)); |
|
25 |
} catch (ParseException e) { |
|
26 |
// TODO Auto-generated catch block |
|
27 |
e.printStackTrace(); |
|
28 |
} |
|
29 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
|
30 |
set(i,Double.parseDouble((String)defaultValue)); |
|
31 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
|
32 |
set(i,Float.parseFloat((String)defaultValue)); |
|
33 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_GEOMETRY)){ |
|
34 |
set(i,defaultValue); |
|
35 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
|
36 |
set(i,Integer.parseInt((String)defaultValue)); |
|
37 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
|
38 |
set(i,Long.parseLong((String)defaultValue)); |
|
39 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_OBJECT)){ |
|
40 |
set(i,null); |
|
41 |
}else if (attributeType.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
|
42 |
set(i,(String)defaultValue); |
|
43 |
} |
|
44 |
i++; |
|
45 |
} |
|
46 |
} |
|
47 |
} |
|
48 |
|
|
49 |
public IFeatureID getID() { |
|
50 |
return new MemoryFeatureID(this); |
|
51 |
} |
|
52 |
|
|
53 |
public Rectangle2D getBoundingBox2D() { |
|
54 |
// TODO Auto-generated method stub |
|
55 |
return null; |
|
56 |
} |
|
57 |
|
|
58 |
public Object getBoundingBox() { |
|
59 |
// TODO Auto-generated method stub |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
public List getAllSRS() { |
|
64 |
// TODO Auto-generated method stub |
|
65 |
return null; |
|
66 |
} |
|
67 |
|
|
68 |
public IProjection getDefaultSRS() { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
return null; |
|
71 |
} |
|
72 |
|
|
73 |
public int[] getGeometryTypes() { |
|
74 |
// TODO Auto-generated method stub |
|
75 |
return null; |
|
76 |
} |
|
77 |
|
|
78 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/expansionadapter/FeatureManager.java | ||
---|---|---|
1 |
|
|
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 |
package org.gvsig.data.vectorial.expansionadapter; |
|
44 |
|
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.HashMap; |
|
47 |
import java.util.Iterator; |
|
48 |
|
|
49 |
import org.gvsig.data.IDataCollection; |
|
50 |
import org.gvsig.data.vectorial.IFeature; |
|
51 |
import org.gvsig.data.vectorial.IFeatureCollection; |
|
52 |
import org.gvsig.data.vectorial.IFeatureID; |
|
53 |
import org.gvsig.data.vectorial.IFeatureStore; |
|
54 |
import org.gvsig.data.vectorial.IFeatureType; |
|
55 |
import org.gvsig.data.vectorial.MemoryFeatureCollection; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* DOCUMENT ME! |
|
60 |
* |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
*/ |
|
63 |
public class FeatureManager { |
|
64 |
protected HashMap relations = new HashMap();//<IFeatureID,Integer> |
|
65 |
protected IExpansionAdapter expansionAdapter; |
|
66 |
protected ArrayList deletedFeatures = new ArrayList();//<IFeatureID> |
|
67 |
protected int num=0; |
|
68 |
public FeatureManager(IExpansionAdapter expansionAdapter){ |
|
69 |
this.expansionAdapter=expansionAdapter; |
|
70 |
} |
|
71 |
|
|
72 |
public void deleteFeature(IFeatureID id) { |
|
73 |
deletedFeatures.add(id); |
|
74 |
num--; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* DOCUMENT ME! |
|
79 |
* |
|
80 |
* @param feature DOCUMENT ME! |
|
81 |
*/ |
|
82 |
public void addFeature(IFeature feature) { |
|
83 |
int pos = expansionAdapter.addObject(feature); |
|
84 |
relations.put(feature.getID(), new Integer(pos)); |
|
85 |
num++; |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* DOCUMENT ME! |
|
90 |
* |
|
91 |
* @param id DOCUMENT ME! |
|
92 |
*/ |
|
93 |
public void deleteLastFeature(IFeatureID id) { |
|
94 |
expansionAdapter.deleteLastObject(); |
|
95 |
relations.remove(id); |
|
96 |
num--; |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* DOCUMENT ME! |
|
101 |
* |
|
102 |
* @param id DOCUMENT ME! |
|
103 |
* |
|
104 |
* @return DOCUMENT ME! |
|
105 |
*/ |
|
106 |
public boolean contains(IFeatureID id) { |
|
107 |
return relations.containsKey(id); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* DOCUMENT ME! |
|
112 |
* |
|
113 |
* @param id DOCUMENT ME! |
|
114 |
* |
|
115 |
* @return DOCUMENT ME! |
|
116 |
*/ |
|
117 |
public IFeature getFeature(IFeatureID id) { |
|
118 |
int num = ((Integer) relations.get(id)).intValue(); |
|
119 |
|
|
120 |
return (IFeature)expansionAdapter.getObject(num); |
|
121 |
} |
|
122 |
|
|
123 |
/** |
|
124 |
* DOCUMENT ME! |
|
125 |
* |
|
126 |
* @param feature DOCUMENT ME! |
|
127 |
* @param oldFeature DOCUMENT ME! |
|
128 |
*/ |
|
129 |
public void updateFeature(IFeature feature, IFeature oldFeature) { |
|
130 |
deletedFeatures.add(oldFeature.getID()); |
|
131 |
|
|
132 |
int num = expansionAdapter.updateObject(feature); |
|
133 |
|
|
134 |
/* |
|
135 |
* Actualiza la relaci?n del ?ndice de la geometr?a al ?ndice en el |
|
136 |
* fichero de expansi?n. |
|
137 |
*/ |
|
138 |
relations.put(feature.getID(), new Integer(num)); |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* DOCUMENT ME! |
|
143 |
* |
|
144 |
* @param id DOCUMENT ME! |
|
145 |
*/ |
|
146 |
public void restoreFeature(IFeatureID id) { |
|
147 |
deletedFeatures.remove(id); |
|
148 |
num++; |
|
149 |
} |
|
150 |
public int getNum(){ |
|
151 |
return num; |
|
152 |
} |
|
153 |
|
|
154 |
public IFeature getFeature(int i){ |
|
155 |
return (IFeature)expansionAdapter.getObject(i); |
|
156 |
} |
|
157 |
public boolean isDeleted(IFeature feature){ |
|
158 |
return deletedFeatures.contains(feature.getID()); |
|
159 |
} |
|
160 |
|
|
161 |
public IFeatureCollection getDataCollection(IDataCollection originalCollection, IFeatureType type, String filter, String order) { |
|
162 |
MemoryFeatureCollection memoryCollection=new MemoryFeatureCollection(); |
|
163 |
for (int i=0;i<relations.size();i++){ |
|
164 |
IFeature feature=(IFeature)expansionAdapter.getObject(i); |
|
165 |
if (!deletedFeatures.contains(feature.getID())){ |
|
166 |
memoryCollection.add(feature); |
|
167 |
} |
|
168 |
} |
|
169 |
Iterator iter=originalCollection.iterator(); |
|
170 |
int i=0; |
|
171 |
while (iter.hasNext()) { |
|
172 |
IFeature feature = (IFeature) iter.next(); |
|
173 |
if (!deletedFeatures.contains(feature.getID())){ |
|
174 |
memoryCollection.add(feature); |
|
175 |
} |
|
176 |
i++; |
|
177 |
} |
|
178 |
|
|
179 |
//TODO en el filtro de las features originales hay que a?adir, que no muestre las que est?n el el HashMap deletedFeatures |
|
180 |
// IFeatureCollection featureCollection=(IFeatureCollection)featureStore.getDataCollection(type,filter,order); |
|
181 |
|
|
182 |
|
|
183 |
EditingFeatureCollection collection=new EditingFeatureCollection(originalCollection, memoryCollection,type); |
|
184 |
// collection. |
|
185 |
// MemoryFeatureCollection collection=new MemoryFeatureCollection(); |
|
186 |
//TODO Filtrar y ordenar, quedar? tambi?n pendiente el IFeatureType que se pasa como |
|
187 |
//par?metro ya que aqu? lo ?nico que introducimos al DataCollection son IFeatureID, |
|
188 |
//todav?a no creamos IFeatures |
|
189 |
// featureStore.createDefaultFeature() |
|
190 |
// for (int i=0;i<driver.getFeatureCount();i++){ |
|
191 |
// MemoryFeatureID id=new MemoryFeatureID(driver.getFeatureByPosition(type,i)); |
|
192 |
// collection.add(id); |
|
193 |
// } |
|
194 |
return collection; |
|
195 |
|
|
196 |
} |
|
197 |
|
|
198 |
// public IFeatureCollection getDataCollection(IDataCollection originalCollection, IFeatureType type, String filter, String order) { |
|
199 |
// MemoryFeatureCollection memoryCollection=new MemoryFeatureCollection(); |
|
200 |
//// TODO Filtrar y ordenar, quedar? tambi?n pendiente el IFeatureType que se pasa como |
|
201 |
// //par?metro ya que aqu? lo ?nico que introducimos al DataCollection son IFeatureID, |
|
202 |
// //todav?a no creamos IFeatures |
|
203 |
// for (int i=0;i<relations.size();i++){ |
|
204 |
// IFeature feature=(IFeature)expansionAdapter.getObject(i); |
|
205 |
// if (!deletedFeatures.contains(feature.getID())){ |
|
206 |
// memoryCollection.add(feature); |
|
207 |
// } |
|
208 |
// } |
|
209 |
// Iterator iter=originalCollection.iterator(); |
|
210 |
// int i=0; |
|
211 |
// featureStore.open(); |
|
212 |
// while (iter.hasNext()) { |
|
213 |
// IFeature feature = (IFeature) iter.next(); |
|
214 |
// if (!deletedFeatures.contains(feature.getID())){ |
|
215 |
// memoryCollection.add(feature); |
|
216 |
// } |
|
217 |
// i++; |
|
218 |
// } |
|
219 |
// |
|
220 |
// //TODO en el filtro de las features originales hay que a?adir, que no muestre las que est?n el el HashMap deletedFeatures |
|
221 |
//// IFeatureCollection featureCollection=(IFeatureCollection)featureStore.getDataCollection(type,filter,order); |
|
222 |
// |
|
223 |
// |
|
224 |
// EditingFeatureCollection collection=new EditingFeatureCollection(originalCollection, memoryCollection,type); |
|
225 |
//// collection. |
|
226 |
//// MemoryFeatureCollection collection=new MemoryFeatureCollection(); |
|
227 |
// //TODO Filtrar y ordenar, quedar? tambi?n pendiente el IFeatureType que se pasa como |
|
228 |
// //par?metro ya que aqu? lo ?nico que introducimos al DataCollection son IFeatureID, |
|
229 |
// //todav?a no creamos IFeatures |
|
230 |
//// featureStore.createDefaultFeature() |
|
231 |
//// for (int i=0;i<driver.getFeatureCount();i++){ |
|
232 |
//// MemoryFeatureID id=new MemoryFeatureID(driver.getFeatureByPosition(type,i)); |
|
233 |
//// collection.add(id); |
|
234 |
//// } |
|
235 |
// return collection; |
|
236 |
// |
|
237 |
// } |
|
238 |
|
|
239 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/expansionadapter/EditingFeatureCollection.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial.expansionadapter; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Collection; |
|
5 |
import java.util.Iterator; |
|
6 |
|
|
7 |
import org.gvsig.data.ComplexObservable; |
|
8 |
import org.gvsig.data.IDataCollection; |
|
9 |
import org.gvsig.data.IObservable; |
|
10 |
import org.gvsig.data.vectorial.IFeature; |
|
11 |
import org.gvsig.data.vectorial.IFeatureCollection; |
|
12 |
import org.gvsig.data.vectorial.IFeatureID; |
|
13 |
import org.gvsig.data.vectorial.IFeatureType; |
|
14 |
|
|
15 |
public class EditingFeatureCollection implements IFeatureCollection { |
|
16 |
protected ComplexObservable observable = new ComplexObservable(); |
|
17 |
private ArrayList featureIDs=new ArrayList();//<IFeatureID> |
|
18 |
private IFeatureType featureType; |
|
19 |
|
|
20 |
public EditingFeatureCollection(IDataCollection featureCollection, IDataCollection memoryCollection,IFeatureType featureType) { |
|
21 |
// this.addAll(featureCollection); |
|
22 |
this.addAll(memoryCollection); |
|
23 |
this.featureType=featureType; |
|
24 |
|
|
25 |
} |
|
26 |
|
|
27 |
public int size() { |
|
28 |
return featureIDs.size(); |
|
29 |
} |
|
30 |
|
|
31 |
public boolean isEmpty() { |
|
32 |
return featureIDs.isEmpty(); |
|
33 |
} |
|
34 |
|
|
35 |
public boolean contains(Object o) { |
|
36 |
return featureIDs.contains(o); |
|
37 |
} |
|
38 |
|
|
39 |
public Iterator iterator() { |
|
40 |
EditingIterator editingIter=new EditingIterator(); |
|
41 |
return editingIter; |
|
42 |
} |
|
43 |
|
|
44 |
public Object[] toArray() { |
|
45 |
return featureIDs.toArray(); |
|
46 |
} |
|
47 |
|
|
48 |
public Object[] toArray(Object[] a) { |
|
49 |
return featureIDs.toArray(a); |
|
50 |
} |
|
51 |
|
|
52 |
public boolean add(Object o) { |
|
53 |
return featureIDs.add((IFeatureID)o); |
|
54 |
} |
|
55 |
|
|
56 |
public boolean remove(Object o) { |
|
57 |
return featureIDs.remove(o); |
|
58 |
} |
|
59 |
|
|
60 |
public boolean containsAll(Collection c) { |
|
61 |
return featureIDs.containsAll(c); |
|
62 |
} |
|
63 |
|
|
64 |
public boolean addAll(Collection c) { |
|
65 |
return featureIDs.addAll(c); |
|
66 |
} |
|
67 |
|
|
68 |
public boolean removeAll(Collection c) { |
|
69 |
return featureIDs.removeAll(c); |
|
70 |
} |
|
71 |
|
|
72 |
public boolean retainAll(Collection c) { |
|
73 |
return featureIDs.retainAll(c); |
|
74 |
} |
|
75 |
|
|
76 |
public void clear() { |
|
77 |
featureIDs.clear(); |
|
78 |
} |
|
79 |
|
|
80 |
public void update(IObservable obsevable, Object notification) { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
|
|
83 |
} |
|
84 |
private class EditingIterator implements Iterator{ |
|
85 |
private int position=0; |
|
86 |
public EditingIterator(){ |
|
87 |
position=0; |
|
88 |
} |
|
89 |
public boolean hasNext() { |
|
90 |
return position<featureIDs.size(); |
|
91 |
} |
|
92 |
|
|
93 |
public Object next() { |
|
94 |
IFeature feature=((IFeatureID)featureIDs.get(position)).getFeature(featureType); |
|
95 |
position++; |
|
96 |
return feature; |
|
97 |
} |
|
98 |
|
|
99 |
public void remove() { |
|
100 |
featureIDs.remove(position); |
|
101 |
} |
|
102 |
|
|
103 |
} |
|
104 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/expansionadapter/AttributeManager.java | ||
---|---|---|
1 |
|
|
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 |
package org.gvsig.data.vectorial.expansionadapter; |
|
44 |
|
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.HashMap; |
|
47 |
|
|
48 |
import org.gvsig.data.vectorial.DefaultFeatureType; |
|
49 |
import org.gvsig.data.vectorial.IFeature; |
|
50 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
|
51 |
import org.gvsig.data.vectorial.IFeatureType; |
|
52 |
import org.gvsig.data.vectorial.MemoryFeatureCollection; |
|
53 |
|
|
54 |
|
|
55 |
/** |
|
56 |
* DOCUMENT ME! |
|
57 |
* |
|
58 |
* @author Vicente Caballero Navarro |
|
59 |
*/ |
|
60 |
public class AttributeManager { |
|
61 |
protected HashMap relations = new HashMap();//<String,Integer> |
|
62 |
protected IExpansionAdapter expansionAdapter; |
|
63 |
protected ArrayList deletedAttributes = new ArrayList();//<String> |
|
64 |
|
|
65 |
public AttributeManager(IExpansionAdapter expansionAdapter){ |
|
66 |
this.expansionAdapter=expansionAdapter; |
|
67 |
} |
|
68 |
|
|
69 |
public void deleteAttribute(String id) { |
|
70 |
deletedAttributes.add(id); |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* DOCUMENT ME! |
|
75 |
* |
|
76 |
* @param feature DOCUMENT ME! |
|
77 |
*/ |
|
78 |
public void addAttribute(IFeatureAttributeDescriptor attributeDescriptor) { |
|
79 |
int pos = expansionAdapter.addObject(attributeDescriptor); |
|
80 |
relations.put(attributeDescriptor.getName(), new Integer(pos)); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* DOCUMENT ME! |
|
85 |
* |
|
86 |
* @param id DOCUMENT ME! |
|
87 |
*/ |
|
88 |
public void deleteLastAttribute(String id) { |
|
89 |
expansionAdapter.deleteLastObject(); |
|
90 |
relations.remove(id); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* DOCUMENT ME! |
|
95 |
* |
|
96 |
* @param id DOCUMENT ME! |
|
97 |
* |
|
98 |
* @return DOCUMENT ME! |
|
99 |
*/ |
|
100 |
public boolean contains(String id) { |
|
101 |
return relations.containsKey(id); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* DOCUMENT ME! |
|
106 |
* |
|
107 |
* @param id DOCUMENT ME! |
|
108 |
* |
|
109 |
* @return DOCUMENT ME! |
|
110 |
*/ |
|
111 |
public IFeatureAttributeDescriptor getAttribute(String id) { |
|
112 |
int num = ((Integer) relations.get(id)).intValue(); |
|
113 |
|
|
114 |
return (IFeatureAttributeDescriptor)expansionAdapter.getObject(num); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* DOCUMENT ME! |
|
119 |
* |
|
120 |
* @param feature DOCUMENT ME! |
|
121 |
* @param oldFeature DOCUMENT ME! |
|
122 |
*/ |
|
123 |
public void updateAttribute(IFeatureAttributeDescriptor attributeDescriptor, IFeatureAttributeDescriptor oldAttributeDescriptor) { |
|
124 |
deletedAttributes.add(oldAttributeDescriptor.getName()); |
|
125 |
|
|
126 |
int num = expansionAdapter.updateObject(attributeDescriptor); |
|
127 |
|
|
128 |
/* |
|
129 |
* Actualiza la relaci?n del ?ndice de la geometr?a al ?ndice en el |
|
130 |
* fichero de expansi?n. |
|
131 |
*/ |
|
132 |
relations.put(attributeDescriptor.getName(), new Integer(num)); |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* DOCUMENT ME! |
|
137 |
* |
|
138 |
* @param id DOCUMENT ME! |
|
139 |
*/ |
|
140 |
public void restoreAttribute(String id) { |
|
141 |
deletedAttributes.remove(id); |
|
142 |
} |
|
143 |
|
|
144 |
public IFeatureType getFeatureType(IFeatureType featureType) { |
|
145 |
IFeatureType ft = new DefaultFeatureType(); |
|
146 |
ft.setGeometryTypes(featureType.getGeometryTypes()); |
|
147 |
for (int i=0;i<featureType.size();i++){ |
|
148 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)featureType.get(i); |
|
149 |
if (!deletedAttributes.contains(descriptor)){ |
|
150 |
ft.add(descriptor); |
|
151 |
} |
|
152 |
} |
|
153 |
for (int i=0;i<relations.size();i++){ |
|
154 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)expansionAdapter.getObject(i); |
|
155 |
if (!deletedAttributes.contains(descriptor)){ |
|
156 |
ft.add(descriptor); |
|
157 |
} |
|
158 |
} |
|
159 |
return ft; |
|
160 |
} |
|
161 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/expansionadapter/IExpansionAdapter.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial.expansionadapter; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
|
|
5 |
|
|
6 |
/** |
|
7 |
* Maneja el fichero de extensi?n en el que se almacenan las modificacionesy adici?nes |
|
8 |
* durante la edici?n. Los ?ndices que devuelve esta clase en sus m?todos |
|
9 |
* addFeature y modifyFeature son invariables, es decir, que si se invoca un |
|
10 |
* m?todo addFeature que retorna un 8, independientemente de las operaciones |
|
11 |
* que se realicen posteriormente, una llamada a getFeature(8) retornar? |
|
12 |
* dicha fila. Si esta geometr?a es eliminada posteriormente, se retornar? un |
|
13 |
* null. Esto ?ltimo se cumple mientras no se invoque el m?todo compact, mediante |
|
14 |
* el que se reorganizan las geometr?as dejando en el fichero s?lo las que tienen |
|
15 |
* validez en el momento de realizar la invocaci?n. |
|
16 |
* |
|
17 |
* @author Vicente Caballero Navarro |
|
18 |
* |
|
19 |
*/ |
|
20 |
public interface IExpansionAdapter { |
|
21 |
/** |
|
22 |
* A?ade una geometria al final del fichero y retorna el ?ndice que ocupa |
|
23 |
* esta geometria en el mismo |
|
24 |
* |
|
25 |
* @param feature |
|
26 |
* @param status TODO |
|
27 |
* @param indexInternalFields fields that where valid when this feature was added. |
|
28 |
* |
|
29 |
* @return calculated index of the new feature. |
|
30 |
*/ |
|
31 |
int addObject(Object obj); |
|
32 |
|
|
33 |
/** |
|
34 |
* Modifica la index-?sima geometr?a del fichero devolviendo la posici?n en |
|
35 |
* la que se pone la geometria modificada. |
|
36 |
* |
|
37 |
* @param calculated index of feature to be modified |
|
38 |
* @param feature newFeature that replaces the old feature. |
|
39 |
* |
|
40 |
* @return new calculated index of the modified feature. |
|
41 |
*/ |
|
42 |
int updateObject(Object obj); |
|
43 |
|
|
44 |
/** |
|
45 |
* Obtiene la geometria que hay en el ?ndice 'index' o null si la geometr?a |
|
46 |
* ha sido invalidada. |
|
47 |
* |
|
48 |
* @param index caculatedIndex of the feature to be read. |
|
49 |
* @return feature |
|
50 |
*/ |
|
51 |
Object getObject(int index); |
|
52 |
|
|
53 |
/** |
|
54 |
* Realiza una compactaci?n del fichero que maneja esta clase |
|
55 |
* |
|
56 |
* @param relations DOCUMENT ME! |
|
57 |
*/ |
|
58 |
void compact(HashMap relations); |
|
59 |
|
|
60 |
/** |
|
61 |
* Mueve el puntero de escritura de manera que las siguientes escrituras |
|
62 |
* machacar?n la ?ltima fila |
|
63 |
*/ |
|
64 |
void deleteLastObject(); |
|
65 |
|
|
66 |
/** |
|
67 |
* Abre el fichero de expansi?n para comenzar la edici?n |
|
68 |
*/ |
|
69 |
void open(); |
|
70 |
|
|
71 |
/** |
|
72 |
* Cierra el fichero de expansi?n al terminar la edici?n |
|
73 |
*/ |
|
74 |
void close(); |
|
75 |
|
|
76 |
int getSize(); |
|
77 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/expansionadapter/MemoryExpansionAdapter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.data.vectorial.expansionadapter; |
|
42 |
|
|
43 |
import java.util.ArrayList; |
|
44 |
import java.util.HashMap; |
|
45 |
|
|
46 |
|
|
47 |
/** |
|
48 |
* Implementaci?n en memoria de ExpansionAdapter. |
|
49 |
* |
|
50 |
* @author Vicente Caballero Navarro |
|
51 |
*/ |
|
52 |
public class MemoryExpansionAdapter implements IExpansionAdapter { |
|
53 |
private ArrayList objects = new ArrayList(); |
|
54 |
|
|
55 |
public MemoryExpansionAdapter(){ |
|
56 |
} |
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#addFeature(org.gvsig.data.vectorial.IFeature) |
|
60 |
*/ |
|
61 |
public int addObject(Object obj) { |
|
62 |
// IFeature feature=(IFeature)obj; |
|
63 |
int newIndex = objects.size(); |
|
64 |
objects.add(obj); |
|
65 |
return newIndex; |
|
66 |
} |
|
67 |
|
|
68 |
/* (non-Javadoc) |
|
69 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#modifyFeature(int, org.gvsig.data.vectorial.IFeature) |
|
70 |
*/ |
|
71 |
public int updateObject(Object obj) { |
|
72 |
// IFeature feature=(IFeature)obj; |
|
73 |
objects.add(obj); |
|
74 |
return objects.size() - 1; |
|
75 |
} |
|
76 |
|
|
77 |
/* (non-Javadoc) |
|
78 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#getFeature(int) |
|
79 |
*/ |
|
80 |
public Object getObject(int index){ |
|
81 |
return objects.get(index); |
|
82 |
} |
|
83 |
|
|
84 |
/* (non-Javadoc) |
|
85 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#compact(java.util.HashMap) |
|
86 |
*/ |
|
87 |
public void compact(HashMap relations) { |
|
88 |
|
|
89 |
} |
|
90 |
|
|
91 |
/* (non-Javadoc) |
|
92 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#deleteLastFeature() |
|
93 |
*/ |
|
94 |
public void deleteLastObject() { |
|
95 |
objects.remove(objects.size()-1); |
|
96 |
|
|
97 |
} |
|
98 |
|
|
99 |
/* (non-Javadoc) |
|
100 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#open() |
|
101 |
*/ |
|
102 |
public void open() { |
|
103 |
// TODO Auto-generated method stub |
|
104 |
|
|
105 |
} |
|
106 |
|
|
107 |
/* (non-Javadoc) |
|
108 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#close() |
|
109 |
*/ |
|
110 |
public void close() { |
|
111 |
objects.clear(); |
|
112 |
System.gc(); |
|
113 |
} |
|
114 |
|
|
115 |
/* (non-Javadoc) |
|
116 |
* @see org.gvsig.data.vectorial.expansionadapter.ExpansionAdapter#getSize() |
|
117 |
*/ |
|
118 |
public int getSize() { |
|
119 |
return objects.size(); |
|
120 |
} |
|
121 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/AttributeStoreNotification.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
|
|
4 |
public class AttributeStoreNotification implements IFeatureAttributeNotification { |
|
5 |
|
|
6 |
private IFeatureStore store; |
|
7 |
private String type; |
|
8 |
private IFeatureAttributeDescriptor attributeDescriptor; |
|
9 |
|
|
10 |
public AttributeStoreNotification(IFeatureStore store, String type, IFeatureAttributeDescriptor attributeDescriptor){ |
|
11 |
this.store=store; |
|
12 |
this.type=type; |
|
13 |
this.attributeDescriptor=attributeDescriptor; |
|
14 |
|
|
15 |
} |
|
16 |
public IFeatureType getFeatureType() { |
|
17 |
// TODO Auto-generated method stub |
|
18 |
return null; |
|
19 |
} |
|
20 |
|
|
21 |
public String getPreviousFeatureFieldValue() { |
|
22 |
// TODO Auto-generated method stub |
|
23 |
return null; |
|
24 |
} |
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureAttributeDescriptor.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import org.cresques.cts.IProjection; |
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
public interface IFeatureAttributeDescriptor { |
|
8 |
|
|
9 |
public static final String TYPE_BYTE = "BYTE"; |
|
10 |
public static final String TYPE_BOOLEAN = "BOOLEAN"; |
|
11 |
public static final String TYPE_INT = "INTEGER"; |
|
12 |
public static final String TYPE_LONG = "LONG"; |
|
13 |
public static final String TYPE_FLOAT = "FLOAT"; |
|
14 |
public static final String TYPE_DOUBLE = "DOUBLE"; |
|
15 |
public static final String TYPE_STRING = "STRING"; |
|
16 |
public static final String TYPE_DATE = "DATE"; |
|
17 |
public static final String TYPE_GEOMETRY = "GEOMETRY"; |
|
18 |
public static final String TYPE_OBJECT = "OBJECT"; |
|
19 |
public static final String TYPE_FEATURE = "FEATURE"; |
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
/** |
|
24 |
* Returns the name of this attribute. This is the name that can be used to |
|
25 |
* retrieve the value of an attribute and usually maps to either an XML |
|
26 |
* element name or a column name in a relational database. |
|
27 |
*/ |
|
28 |
String getName(); |
|
29 |
|
|
30 |
/** |
|
31 |
* Returns a constant from {@link DataType}. The return value of this method |
|
32 |
* indicates how the return values of {@link #getSize}, {@link #getPrecision}, and |
|
33 |
* {@link #getObjectClass} should be interpreted. For attributes whose maximum |
|
34 |
* cardinality is greater than one, this should return the data type of |
|
35 |
* the individual elements of the collection. |
|
36 |
*/ |
|
37 |
String getDataType(); |
|
38 |
|
|
39 |
/** |
|
40 |
* Returns a number that indicates the size of a given attribute. See the documentation |
|
41 |
* for the various constants of {@link DataType} for how to interpret this value. As an |
|
42 |
* example, when the data type is {@link DataType#STRING STRING}, this value indicates |
|
43 |
* the maximum length of the string. |
|
44 |
*/ |
|
45 |
int getSize(); |
|
46 |
|
|
47 |
/** |
|
48 |
* For attributes of type {@link DataType#DECIMAL DECIMAL}, this returns the maximum number |
|
49 |
* of places after the decimal point. For other types, this must always return zero. |
|
50 |
*/ |
|
51 |
int getPrecision(); |
|
52 |
|
|
53 |
/** |
|
54 |
* For attributes of type {@link DataType#OBJECT OBJECT}, this returns the Java {@link Class} |
|
55 |
* object that class or interface that all values of this attribute can be cast to. |
|
56 |
*/ |
|
57 |
Class getObjectClass(); |
|
58 |
|
|
59 |
/** |
|
60 |
* Returns the minimum number of occurrences of this attribute on a given |
|
61 |
* feature. The vast majority of data sources and data consumers will only |
|
62 |
* function with this value being zero or one. If the minimum number of |
|
63 |
* occurrences is zero, this is equivalent, in SQL terms, to the attribute |
|
64 |
* being nillable. |
|
65 |
*/ |
|
66 |
int getMinimumOccurrences(); |
|
67 |
|
|
68 |
/** |
|
69 |
* Returns the maximum number of occurrences of this attribute on a given |
|
70 |
* feature. The vast majority of data sources and data consumers will only |
|
71 |
* function with this value being one. A value of {@link Integer#MAX_VALUE} |
|
72 |
* indicates that the maximum number of occurrences is unbounded. |
|
73 |
*/ |
|
74 |
int getMaximumOccurrences(); |
|
75 |
|
|
76 |
/** |
|
77 |
* Returns {@code true} if this attribute forms all or part of the unique identifying |
|
78 |
* value for the feature it is contained by. The primary key attributes uniquely |
|
79 |
* identify this feature from other features of the same type. This is different |
|
80 |
* from the {@linkplain Feature#getID feature's ID}, which must uniquely identify |
|
81 |
* the {@link Feature} among all feature types. |
|
82 |
*/ |
|
83 |
boolean isPrimaryKey(); |
|
84 |
public int ordinal(); |
|
85 |
|
|
86 |
IProjection getSRS(); |
|
87 |
int getGeometryType(); |
|
88 |
Object getDefaultValue(); |
|
89 |
|
|
90 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/SpatialManager.java | ||
---|---|---|
1 |
|
|
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 |
package org.gvsig.data.vectorial; |
|
44 |
|
|
45 |
/** |
|
46 |
* DOCUMENT ME! |
|
47 |
* |
|
48 |
* @author Vicente Caballero Navarro |
|
49 |
*/ |
|
50 |
public class SpatialManager { |
|
51 |
protected boolean isFullExtentDirty = true; |
|
52 |
|
|
53 |
/** |
|
54 |
* DOCUMENT ME! |
|
55 |
* |
|
56 |
* @return DOCUMENT ME! |
|
57 |
*/ |
|
58 |
public boolean isFullExtentDirty() { |
|
59 |
return isFullExtentDirty; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* DOCUMENT ME! |
|
64 |
* |
|
65 |
* @param feature DOCUMENT ME! |
|
66 |
* @param oldFeature DOCUMENT ME! |
|
67 |
*/ |
|
68 |
public void updateFeature(IFeature feature, IFeature oldFeature) { |
|
69 |
// TODO Auto-generated method stub |
|
70 |
isFullExtentDirty = true; |
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* DOCUMENT ME! |
|
75 |
* |
|
76 |
* @param feature DOCUMENT ME! |
|
77 |
*/ |
|
78 |
public void insertFeature(IFeature feature) { |
|
79 |
// TODO Auto-generated method stub |
|
80 |
isFullExtentDirty = true; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* DOCUMENT ME! |
|
85 |
* |
|
86 |
* @param feature DOCUMENT ME! |
|
87 |
*/ |
|
88 |
public void deleteFeature(IFeature feature) { |
|
89 |
// TODO Auto-generated method stub |
|
90 |
isFullExtentDirty = true; |
|
91 |
} |
|
92 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/IFeatureStoreNotification.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import org.gvsig.data.IDataCollection; |
|
4 |
import org.gvsig.data.IDataStoreNotification; |
|
5 |
|
|
6 |
public interface IFeatureStoreNotification extends IDataStoreNotification { |
|
7 |
|
|
8 |
public static final String BEFORE_UPDATE = "before_Update_Feature"; |
|
9 |
public static final String AFTER_UPDATE = "after_Update_Feature"; |
|
10 |
public static final String BEFORE_DELETE = "before_Delete_Feature"; |
|
11 |
public static final String AFTER_DELETE = "after_Delete_Feature"; |
|
12 |
public static final String BEFORE_INSERT = "before_Insert_Feature"; |
|
13 |
public static final String AFTER_INSERT = "after_Insert_Feature"; |
|
14 |
|
|
15 |
public static final String LOAD_FINISHED = "Load_Finished"; |
|
16 |
|
|
17 |
public IFeatureID getFeatureID(); |
|
18 |
|
|
19 |
public IFeature getPreviousFeatureValue(); |
|
20 |
|
|
21 |
public IDataCollection getCollectionResult(); |
|
22 |
|
|
23 |
public boolean loadSucefully(); |
|
24 |
|
|
25 |
public Exception getExceptionLoading(); |
|
26 |
|
|
27 |
} |
trunk/libraries/libDataSource/src/org/gvsig/data/vectorial/Feature.java | ||
---|---|---|
1 |
package org.gvsig.data.vectorial; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
import java.util.HashMap; |
|
5 |
|
|
6 |
public abstract class Feature extends HashMap implements IFeature{ |
|
7 |
protected IFeatureType featureType; |
|
8 |
protected Object defaultGeometry; |
|
9 |
protected Object object; |
|
10 |
|
|
11 |
public Feature(IFeatureType featureType){ |
|
12 |
this.featureType=featureType; |
|
13 |
} |
|
14 |
public IFeatureType getType() { |
|
15 |
return featureType; |
|
16 |
} |
|
17 |
|
|
18 |
public Object getDefaultGeometry() { |
|
19 |
return defaultGeometry; |
|
20 |
} |
|
21 |
|
|
22 |
public Object get(String name) { |
|
23 |
return super.get(name); |
|
24 |
} |
|
25 |
|
|
26 |
public int getInt(String name) { |
|
27 |
Integer value=(Integer)super.get(name); |
|
28 |
if (value==null) |
|
29 |
return 0; |
|
30 |
return value.intValue(); |
|
31 |
} |
|
32 |
|
|
33 |
public boolean getBoolean(String name) { |
|
34 |
Boolean value=(Boolean)super.get(name); |
|
35 |
if (value==null) |
|
36 |
return false; |
|
37 |
return value.booleanValue(); |
|
38 |
} |
|
39 |
|
|
40 |
public long getLong(String name) { |
|
41 |
Long value=(Long)super.get(name); |
|
42 |
if (value==null) |
|
43 |
return 0L; |
|
44 |
return value.longValue(); |
|
45 |
} |
|
46 |
|
|
47 |
public float getFloat(String name) { |
|
48 |
Float value=(Float)super.get(name); |
|
49 |
if (value==null) |
|
50 |
return 0F; |
|
51 |
return value.floatValue(); |
|
52 |
} |
|
53 |
|
|
54 |
public double getDouble(String name) { |
|
55 |
Double value=(Double)super.get(name); |
|
56 |
if (value==null) |
|
57 |
return 0D; |
|
58 |
return value.doubleValue(); |
|
59 |
} |
|
60 |
public String getString(String name) { |
|
61 |
String value=(String)super.get(name); |
|
62 |
return value; |
|
63 |
} |
|
64 |
public String getString(int index) { |
|
65 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
66 |
String value=(String)super.get(name); |
|
67 |
return value; |
|
68 |
} |
|
69 |
public Object get(int index) { |
|
70 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
71 |
return super.get(name); |
|
72 |
} |
|
73 |
|
|
74 |
public IFeature getFeature(int index) { |
|
75 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
76 |
IFeature value=(IFeature)super.get(name); |
|
77 |
return value; |
|
78 |
} |
|
79 |
|
|
80 |
public Object[] getArray(int index) { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
return null; |
|
83 |
} |
|
84 |
|
|
85 |
public int getInt(int index) { |
|
86 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
87 |
Integer value=(Integer)super.get(name); |
|
88 |
if (value==null) |
|
89 |
return 0; |
|
90 |
return value.intValue(); |
|
91 |
} |
|
92 |
|
|
93 |
public boolean getBoolean(int index) { |
|
94 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
95 |
Boolean value=(Boolean)super.get(name); |
|
96 |
if (value==null) |
|
97 |
return false; |
|
98 |
return value.booleanValue(); |
|
99 |
} |
|
100 |
|
|
101 |
public long getLong(int index) { |
|
102 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
103 |
Long value=(Long)super.get(name); |
|
104 |
if (value==null) |
|
105 |
return 0L; |
|
106 |
return value.longValue(); |
|
107 |
} |
|
108 |
|
|
109 |
public float getFloat(int index) { |
|
110 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
111 |
Float value=(Float)super.get(name); |
|
112 |
if (value==null) |
|
113 |
return 0F; |
|
114 |
return value.floatValue(); |
|
115 |
} |
|
116 |
|
|
117 |
public double getDouble(int index) { |
|
118 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
119 |
Double value=(Double)super.get(name); |
|
120 |
if (value==null) |
|
121 |
return 0D; |
|
122 |
return value.doubleValue(); |
|
123 |
} |
|
124 |
|
|
125 |
public Date getDate(int index) { |
|
126 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
127 |
return (Date)super.get(name); |
|
128 |
} |
|
129 |
|
|
130 |
public Date getDate(String name) { |
|
131 |
return (Date)super.get(name); |
|
132 |
} |
|
133 |
public void set(String name, Object value) { |
|
134 |
put(name,value); |
|
135 |
} |
|
136 |
|
|
137 |
public void set(String name, int value) { |
|
138 |
put(name,new Integer(value)); |
|
139 |
|
|
140 |
} |
|
141 |
|
|
142 |
public void set(String name, boolean value) { |
|
143 |
put(name,new Boolean(value)); |
|
144 |
} |
|
145 |
|
|
146 |
public void set(String name, long value) { |
|
147 |
put(name,new Long(value)); |
|
148 |
} |
|
149 |
|
|
150 |
public void set(String name, float value) { |
|
151 |
put(name,new Float(value)); |
|
152 |
} |
|
153 |
|
|
154 |
public void set(String name, double value) { |
|
155 |
put(name,new Double(value)); |
|
156 |
} |
|
157 |
|
|
158 |
public void set(int index, Object value) { |
|
159 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
160 |
put(name,value); |
|
161 |
} |
|
162 |
|
|
163 |
public void set(int index, int value) { |
|
164 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
165 |
put(name,new Integer(value)); |
|
166 |
} |
|
167 |
|
|
168 |
public void set(int index, boolean value) { |
|
169 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
170 |
put(name,new Boolean(value)); |
|
171 |
} |
|
172 |
|
|
173 |
public void set(int index, long value) { |
|
174 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
175 |
put(name,new Long(value)); |
|
176 |
} |
|
177 |
|
|
178 |
public void set(int index, float value) { |
|
179 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
180 |
put(name,new Float(value)); |
|
181 |
} |
|
182 |
|
|
183 |
public void set(int index, double value) { |
|
184 |
String name=((IFeatureAttributeDescriptor)featureType.get(index)).getName(); |
|
185 |
put(name,new Double(value)); |
|
186 |
} |
|
187 |
|
|
188 |
public void validateEnd(IFeatureStore featureStore) { |
|
189 |
getType().validateFeatureEnd(this,featureStore); |
|
190 |
|
|
191 |
} |
|
192 |
|
|
193 |
public void validateModification(IFeatureStore featureStore) { |
|
194 |
getType().validateFeatureModifiction(this,featureStore); |
|
195 |
} |
|
196 |
|
|
197 |
public void validate(IFeatureStore featureStore) { |
|
198 |
getType().validateFeature(this,featureStore); |
|
199 |
} |
Also available in: Unified diff