Revision 19490 trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/driver/DataStoreTest.java
DataStoreTest.java | ||
---|---|---|
19 | 19 |
import org.gvsig.data.vectorial.IFeatureCollection; |
20 | 20 |
import org.gvsig.data.vectorial.IFeatureStore; |
21 | 21 |
import org.gvsig.data.vectorial.IFeatureType; |
22 |
import org.gvsig.data.vectorial.visitor.PrintlnFeaturesVisitor; |
|
22 | 23 |
import org.gvsig.data.visitor.IVisitor; |
24 |
import org.gvsig.exceptions.BaseException; |
|
23 | 25 |
|
26 |
import com.iver.cit.gvsig.fmap.operations.strategies.FeatureVisitor; |
|
27 |
|
|
24 | 28 |
public class DataStoreTest extends TestCase { |
25 | 29 |
|
26 | 30 |
private File dbffile = new File(DataStoreTest.class.getResource("data/prueba.dbf").getFile()); |
... | ... | |
375 | 379 |
// featureCollection = (IFeatureCollection)fs.getDataCollection(ft,"AREA > 3.2213163729E7 and AREA < 3.2213163749E7",null); |
376 | 380 |
featureCollection = (IFeatureCollection)fs.getDataCollection(ft,filter,order); |
377 | 381 |
|
378 |
VisitorExample visitor=new VisitorExample(ft); |
|
379 |
featureCollection.accept(visitor); |
|
382 |
PrintlnFeaturesVisitor visitor=new PrintlnFeaturesVisitor(ft); |
|
383 |
try { |
|
384 |
featureCollection.accept(visitor); |
|
385 |
} catch (BaseException e1) { |
|
386 |
e1.printStackTrace(); |
|
387 |
fail("Exception: "+e1); |
|
388 |
} |
|
380 | 389 |
|
381 | 390 |
if (fs.isEditable() && testEdit){ |
382 | 391 |
try { |
... | ... | |
397 | 406 |
} |
398 | 407 |
fs.dispose(); |
399 | 408 |
} |
400 |
|
|
401 |
private class VisitorExample implements IVisitor{ |
|
402 |
private IFeatureType featureType; |
|
403 |
public VisitorExample(IFeatureType ft){ |
|
404 |
this.featureType=ft; |
|
405 |
} |
|
406 |
|
|
407 |
public void visit(Object obj) { |
|
408 |
IFeature feature=(IFeature)obj; |
|
409 |
System.out.println("Feature Class ------------------- "+feature.getClass().toString()); |
|
410 |
for (int i=0;i<featureType.size();i++){ |
|
411 |
|
|
412 |
IFeatureAttributeDescriptor descriptor=(IFeatureAttributeDescriptor)featureType.get(i); |
|
413 |
String type=descriptor.getDataType(); |
|
414 |
if (type.equals(IFeatureAttributeDescriptor.TYPE_BOOLEAN)){ |
|
415 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getBoolean(i)+ "---- Boolean"); |
|
416 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_BYTE)){ |
|
417 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getByte(i)+ "---- Byte"); |
|
418 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DATE)){ |
|
419 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getDate(i)+ "---- Date"); |
|
420 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_DOUBLE)){ |
|
421 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getDouble(i)+ "---- Double"); |
|
422 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_FLOAT)){ |
|
423 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getFloat(i)+ "---- Float"); |
|
424 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_INT)){ |
|
425 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getInt(i)+ "---- Integer"); |
|
426 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_LONG)){ |
|
427 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getLong(i)+ "---- Long"); |
|
428 |
}else if (type.equals(IFeatureAttributeDescriptor.TYPE_STRING)){ |
|
429 |
System.out.println(((IFeatureAttributeDescriptor)featureType.get(i)).getName()+" ----- "+ feature.getString(i)+ "---- String"); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
} |
|
435 | 409 |
} |
Also available in: Unified diff