Collection results = null; String URLSpec = clusterURL + PSP_PACKAGE + "/" + PSP_id; String agent = URLSpec; if (filter != null) URLSpec = URLSpec + "?operatorPredicate=" + URLEncoder.encode(filter);  try { URL url = new URL(URLSpec); URLConnection connection = url.openConnection(); connection.setDoInput(true); connection.setDoOutput(true);  InputStream is = connection.getInputStream(); ObjectInputStream p = new ObjectInputStream(is); results = (Collection)p.readObject(); if (results == null || results.isEmpty()) { results = null; JOptionPane.showMessageDialog(null, agent + " returned null; no information to graph from this agent."); } } catch (Exception e) { System.out.println("Util: Failed to contact: " + URLSpec + " " + e); JOptionPane.showMessageDialog(null, "Failed to contact: " + agent + "; no information to graph from this agent."); return null; }   return results;
return getCollectionFromCluster(clusterURL, PSP_id, filter, -1);
  public static Collection getCollectionFromCluster(String clusterURL,						    String PSP_id,						    String filter) {    Collection results = null;    String URLSpec = clusterURL + PSP_PACKAGE + "/" + PSP_id;    String agent = URLSpec;    if (filter != null)      URLSpec = URLSpec + "?operatorPredicate=" + URLEncoder.encode(filter);    //    System.out.println("Util: Connecting to society: " + URLSpec);    try {      URL url = new URL(URLSpec);      URLConnection connection = url.openConnection();      connection.setDoInput(true);      connection.setDoOutput(true);      // read events from PSP      InputStream is = connection.getInputStream();      ObjectInputStream p = new ObjectInputStream(is);      results = (Collection)p.readObject();      if (results == null || results.isEmpty()) {	results = null;	JOptionPane.showMessageDialog(null,				      agent + " returned null; no information to graph from this agent.");      }    } catch (Exception e) {      System.out.println("Util: Failed to contact: " + URLSpec + " " + e);      JOptionPane.showMessageDialog(null,				    "Failed to contact: " + agent + 				    "; no information to graph from this agent.");      return null;    }    //    System.out.println("Received events: " + results.size() +    //		       " from cluster: " + clusterURL);    return results;  }