Hi all... I need to search an AreaShapeLayer's dbf file. I've tried the
following:
However.. I get a NullPointerException whennever I tried to access any
record related methods like getRecord(int i) or even itr.next() on the
iterator from getRecords. I've chcked over and over.. the "model" is not
null either. The app successfully prints out the number of records.
public static void search(ShapeLayer sLayer, String query, int column){
Properties layerProps = sLayer.getProperties(null);
String prefix = sLayer.getPropertyPrefix() + ".";
String dbfFileLocation = layerProps.getProperty(prefix +
"shapeFile");
dbfFileLocation = dbfFileLocation.replaceAll(".shp", ".dbf");
// <-- this is a hack... we can't access the dbfFile property...
openmap deletes it on shp layer load... dunno y
// we assume that the dbf file has the same name
DbfTableModel model = DbfFile.getDbfTableModel(dbfFileLocation);
System.out.println(model.getColumnCount() + " columns");
if(model != null){
Iterator itr = model.getRecords();
while(itr.hasNext()){
Object obj = itr.next();
}
}
}
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Mon Jun 1 01:37:21 2009
This archive was generated by hypermail 2.1.8 : Mon Jun 01 2009 - 01:37:22 EDT