From: gmungoc Date: Mon, 23 May 2016 10:47:35 +0000 (+0100) Subject: JAL-2113 tidy variable naming / javadoc X-Git-Tag: Release_2_10_0~196^2~2^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=eaa8cc6ff032ac14e2bd96ee3bd27e80cfa74a25;p=jalview.git JAL-2113 tidy variable naming / javadoc --- diff --git a/src/jalview/ws/ebi/EBIFetchClient.java b/src/jalview/ws/ebi/EBIFetchClient.java index dd3cc16..1dff32f 100644 --- a/src/jalview/ws/ebi/EBIFetchClient.java +++ b/src/jalview/ws/ebi/EBIFetchClient.java @@ -116,28 +116,32 @@ public class EBIFetchClient return outFile; } - String[] fetchData(String ids, String f, File outFile) + /** + * Fetches queries and either saves the response to a file or returns as + * string data + * + * @param ids + * @param format + * @param outFile + * @return + * @throws OutOfMemoryError + */ + String[] fetchData(String ids, String format, File outFile) throws OutOfMemoryError { - String[] rslts = new String[0]; StringBuilder querystring = new StringBuilder(ids.length()); - String db = parseIds(ids, querystring); - if (db == null) + String database = parseIds(ids, querystring); + if (database == null) { System.err.println("Invalid Query string : '" + ids + "'"); System.err.println("Should be of form 'dbname:q1;q2;q3;q4'"); return null; } - String[] rslt = fetchBatch(querystring.toString(), db, f, outFile); - if (rslt != null) - { - String[] nrslts = new String[rslt.length + rslts.length]; - System.arraycopy(rslts, 0, nrslts, 0, rslts.length); - System.arraycopy(rslt, 0, nrslts, rslts.length, rslt.length); - rslts = nrslts; - } - return (rslts.length == 0 ? null : rslts); + // note: outFile is currently always specified, so return value is null + String[] rslt = fetchBatch(querystring.toString(), database, format, outFile); + + return (rslt != null && rslt.length > 0 ? rslt : null); } /** @@ -179,11 +183,22 @@ public class EBIFetchClient return database; } - String[] fetchBatch(String ids, String dbPath, String format, + /** + * Fetches queries and either saves the response to a file or (if no file + * specified) returns as string data + * + * @param ids + * @param database + * @param format + * @param outFile + * @return + * @throws OutOfMemoryError + */ + String[] fetchBatch(String ids, String database, String format, File outFile) throws OutOfMemoryError { // long time = System.currentTimeMillis(); - String url = buildUrl(ids, dbPath, format); + String url = buildUrl(ids, database, format); try { @@ -215,8 +230,7 @@ public class EBIFetchClient } } catch (OutOfMemoryError er) { - - System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + dbPath + System.out.println("OUT OF MEMORY DOWNLOADING QUERY FROM " + database + ":\n" + ids); throw er; } catch (Exception ex) @@ -227,7 +241,7 @@ public class EBIFetchClient return null; } System.err.println("Unexpected exception when retrieving from " - + dbPath + + database + "\nQuery was : '" + ids + "'"); ex.printStackTrace(System.err); return null;