Revision 19467
trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/driver/DataStoreTest.java | ||
---|---|---|
1 | 1 |
package org.gvsig.data.datastores.vectorial.driver; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.Iterator; |
|
5 | 4 |
|
6 | 5 |
import junit.framework.TestCase; |
7 | 6 |
|
... | ... | |
19 | 18 |
import org.gvsig.data.vectorial.IFeatureCollection; |
20 | 19 |
import org.gvsig.data.vectorial.IFeatureStore; |
21 | 20 |
import org.gvsig.data.vectorial.IFeatureType; |
21 |
import org.gvsig.data.visitor.IVisitor; |
|
22 | 22 |
|
23 | 23 |
public class DataStoreTest extends TestCase { |
24 | 24 |
|
... | ... | |
106 | 106 |
// featureCollection = (IFeatureCollection)fs.getDataCollection(ft,"AREA > 3.2213163729E7 and AREA < 3.2213163749E7",null); |
107 | 107 |
featureCollection = (IFeatureCollection)fs.getDataCollection(ft,filter,order); |
108 | 108 |
|
109 |
Iterator iter = featureCollection.iterator(); |
|
109 |
VisitorExample visitor=new VisitorExample(ft); |
|
110 |
featureCollection.accept(visitor); |
|
110 | 111 |
|
111 |
System.out.println("DataStore Editing Feature ------------------- "); |
|
112 |
while (iter.hasNext()) { |
|
113 |
|
|
114 |
IFeature feature = (IFeature)iter.next(); |
|
115 |
System.out.println("Feature Class ------------------- "+feature.getClass().toString()); |
|
116 |
for (int i=0;i<ft.size();i++){ |
|
117 |
|
|
118 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)ft.get(i); |
|
119 |
String type=descriptor.getDataType(); |
|
120 |
if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){ |
|
121 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getBoolean(i)+ "---- Boolean"); |
|
122 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
|
123 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getByte(i)+ "---- Byte"); |
|
124 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
|
125 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getDate(i)+ "---- Date"); |
|
126 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
|
127 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getDouble(i)+ "---- Double"); |
|
128 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
|
129 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getFloat(i)+ "---- Float"); |
|
130 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
|
131 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getInt(i)+ "---- Integer"); |
|
132 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
|
133 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getLong(i)+ "---- Long"); |
|
134 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
|
135 |
System.out.println(((IFeatureAttributeDescriptor)ft.get(i)).getName()+" ----- "+ feature.getString(i)+ "---- String"); |
|
136 |
} |
|
137 |
} |
|
138 |
} |
|
139 |
|
|
140 | 112 |
if (fs.isEditable()){ |
141 | 113 |
try { |
142 | 114 |
fs.finishEditing(); |
... | ... | |
156 | 128 |
} |
157 | 129 |
fs.dispose(); |
158 | 130 |
} |
131 |
|
|
132 |
private class VisitorExample implements IVisitor{ |
|
133 |
private IFeatureType featureType; |
|
134 |
public VisitorExample(IFeatureType ft){ |
|
135 |
this.featureType=ft; |
|
136 |
} |
|
137 |
|
|
138 |
public void visit(Object obj) { |
|
139 |
IFeature feature=(IFeature)obj; |
|
140 |
System.out.println("Feature Class ------------------- "+feature.getClass().toString()); |
|
141 |
for (int i=0;i<featureType.size();i++){ |
|
142 |
|
|
143 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)featureType.get(i); |
|
144 |
String type=descriptor.getDataType(); |
|
145 |
if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){ |
|
146 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getBoolean(i)+ "---- Boolean"); |
|
147 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
|
148 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getByte(i)+ "---- Byte"); |
|
149 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
|
150 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getDate(i)+ "---- Date"); |
|
151 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
|
152 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getDouble(i)+ "---- Double"); |
|
153 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
|
154 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getFloat(i)+ "---- Float"); |
|
155 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
|
156 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getInt(i)+ "---- Integer"); |
|
157 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
|
158 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getLong(i)+ "---- Long"); |
|
159 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
|
160 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getString(i)+ "---- String"); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
} |
|
165 |
|
|
166 |
} |
|
167 |
|
|
168 |
|
|
159 | 169 |
} |
Also available in: Unified diff