package dalclient; import edu.jhu.pha.ivoa.*; import java.io.*; import java.net.*; import java.util.*; /** * Cone Service query. Provides methods to build up and execute a query * against a connection. */ public class ConeQuery extends DALQuery { ConeQuery(ConeConnection conn) { super(conn); } /* * Execute query and process the resultant VOTable into a cone search * query response class. Since for a cone search we deal with general * tables which do not have a data model, the records use the UCD as the * key for each field. */ public QueryResponse execute() throws Exception { ArrayList resultSet = new ArrayList(); VOTWrap.VOTable vot = this.executeVOTable(); VOTWrap.Resource r = vot.getResource(0); VOTWrap.Table table = r.getTable(0); // Read the table header; form array of field UCDs. ArrayList fieldKeys = new ArrayList(); for (int i=0; i < table.getFieldCount(); i++) { VOTWrap.Field field = table.getField(i); fieldKeys.add(field.getUCD()); } // Read the table data; form "fields" hashMap for each row. int TRCount = table.getTableData().getTRCount(); for (int j=0; j < TRCount; j++) { LinkedHashMap fields = new LinkedHashMap(); VOTWrap.TR row = table.getTableData().getTR(j); for (int i=0; i < table.getFieldCount(); i++) fields.put(fieldKeys.get(i), row.getTD(i).getPCDATA()); resultSet.add(fields); } QueryResponse qr = new QueryResponse(resultSet); return (qr); } }