+ /* 2022-07-20 bsoares
+ * used for the new API "cursor" pagination. See https://www.uniprot.org/help/pagination
+ */
+ private ArrayList<String> cursors;
+
+ private int cursorPage = 0;
+
+ protected int getCursorPage()
+ {
+ return cursorPage;
+ }
+
+ protected void setCursorPage(int i)
+ {
+ cursorPage = i;
+ }
+
+ protected void setPrevCursorPage()
+ {
+ if (cursorPage > 0)
+ cursorPage--;
+ }
+
+ protected void setNextCursorPage()
+ {
+ cursorPage++;
+ }
+
+ protected void clearCursors()
+ {
+ cursors = new ArrayList(10);
+ }
+
+ protected String getCursor(int i)
+ {
+ return cursors.get(i);
+ }
+
+ protected String getNextCursor()
+ {
+ if (cursors.size() < cursorPage + 2)
+ return null;
+ return cursors.get(cursorPage + 1);
+ }
+
+ protected String getPrevCursor()
+ {
+ if (cursorPage == 0)
+ return null;
+ return cursors.get(cursorPage - 1);
+ }
+
+ protected void setCursor(int i, String c)
+ {
+ cursors.ensureCapacity(i + 1);
+ while (cursors.size() <= i)
+ {
+ cursors.add(null);
+ }
+ cursors.set(i, c);
+ Console.debug(
+ "Set UniprotFRSRestClient cursors[" + i + "] to '" + c + "'");
+ // cursors.add(c);
+ }
+
+ public static String getQueryParam(String param, String u)
+ {
+ if (param == null || u == null)
+ return null;
+ try
+ {
+ URL url = new URL(u);
+ String[] kevs = url.getQuery().split("&");
+ for (int j = 0; j < kevs.length; j++)
+ {
+ String[] kev = kevs[j].split("=", 2);
+ if (param.equals(kev[0]))
+ {
+ return kev[1];
+ }
+ }
+ } catch (MalformedURLException e)
+ {
+ Console.warn("Could not obtain next page 'cursor' value from 'u");
+ }
+ return null;
+ }
+}
\ No newline at end of file