* jo= getCatalog( URL( "https://jfaden.net/HapiServerDemo/hapi/catalog" ) )
* for j in jo.getJsonArray( 'catalog' ):
* print j.get('id')
*
* @param server
* @return
* @throws java.io.IOException
* @throws org.json.JSONException
*/
public static org.json.JSONObject getCatalog( URL server ) throws IOException, JSONException {
if ( EventQueue.isDispatchThread() ) {
logger.warning("HAPI network call on event thread");
}
URL url;
url= new URL( server, "catalog" );
String s= readFromURL(url, "json");
JSONObject o= new JSONObject(s);
return o;
}
/**
* return the catalog as a JSONArray.
*
* jo= getCatalogArray( URL( "https://jfaden.net/HapiServerDemo/hapi/catalog" ) )
* for i in xrange(jo.length()):
* print jo.get(i,'id')
*
* @param server
* @return
* @throws IOException
* @throws JSONException
*/
public static org.json.JSONArray getCatalogArray( URL server ) throws IOException, JSONException {
JSONObject jo= getCatalog(server);
JSONArray ja= jo.getJSONArray("catalog");
return ja;
}
/**
* return the data record-by-record, using the CSV response.
* @param server
* @param id
* @param startTime
* @param endTime
* @return Iterator, which will return records until the stream is empty.
* @throws java.io.IOException
* @throws org.json.JSONException should the server return an invalid response.
*/
public static Iterator