Adds alternative version of command.runWith(parameters)
[mkjsf-moved-to-github.git] / src / main / java / com / indexdata / mkjsf / pazpar2 / commands / Pazpar2Command.java
index 25ea8db..d8730b7 100644 (file)
@@ -80,7 +80,7 @@ public abstract class Pazpar2Command implements Serializable  {
   \r
   /**\r
    * Executes the commands with the currently selected parameters, while adding\r
-   * the parameters provided\r
+   * the parameters provided in the vararg\r
    * @param parameters A list of parameters on the form [key=value]\r
    * \r
    * @return Response data object based on the Pazpar2 service response\r
@@ -95,6 +95,29 @@ public abstract class Pazpar2Command implements Serializable  {
     }\r
     return run();\r
   }\r
+\r
+  /**\r
+   * Executes the commands with the currently selected parameters, while adding\r
+   * the parameters provided in the 'delimiter'-separated String.\r
+   * \r
+   * Note: This is for Glassfish/JBoss support. With Tomcat7 the method \r
+   *       runWith(String... parameters) can be used directly from EL \r
+   *       with a vararg \r
+   *  \r
+   * @param parameters A list of parameters separated by 'delimiter'\r
+   * @param delimiter The separator character of the String 'parameters' \r
+   * \r
+   * @return Response data object based on the Pazpar2 service response\r
+   */\r
+  public ResponseDataObject runWith2(String parameters, String delimiter) {    \r
+    StringTokenizer params = new StringTokenizer(parameters,delimiter);\r
+    String[] vararg = new String[params.countTokens()];\r
+    int i=0;\r
+    while (params.hasMoreTokens()) {\r
+      vararg[i++] = params.nextToken();\r
+    }\r
+    return runWith(vararg);\r
+  }\r
     \r
   /**\r
    * Executes the command in a thread.  \r