JAL-715 - allow rest service attributes to be exported and imported as a | separated...
[jalview.git] / src / jalview / ws / rest / params / SeqVector.java
index 9a98f3e..3a5b414 100644 (file)
@@ -5,9 +5,12 @@ import jalview.datamodel.SequenceI;
 import jalview.ws.rest.InputType;
 import jalview.ws.rest.NoValidInputDataException;
 import jalview.ws.rest.RestJob;
+import jalview.ws.rest.RestServiceDescription;
 import jalview.ws.rest.InputType.molType;
 
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.http.entity.mime.content.ContentBody;
 import org.apache.http.entity.mime.content.StringBody;
@@ -17,7 +20,7 @@ import org.apache.http.entity.mime.content.StringBody;
  * @author JimP
  *
  */
-class SeqVector extends InputType {
+public class SeqVector extends InputType {
   String sep;
   molType type;
   public SeqVector()
@@ -40,4 +43,48 @@ class SeqVector extends InputType {
     }
     return new StringBody(idvector.toString());
   }
+  @Override
+  public List<String> getURLEncodedParameter()
+  {
+    ArrayList<String> prms = new ArrayList<String>();
+    super.addBaseParams(prms);
+    prms.add("sep='"+ sep+"'");
+    prms.add("type='"+type+"'");
+    return prms;
+  }
+
+  @Override
+  public String getURLtokenPrefix()
+  {
+    return "SEQS";
+  }
+
+  @Override
+  public boolean configureProperty(String tok, String val,
+          StringBuffer warnings)
+  {
+
+    if (tok.startsWith("sep"))
+    {
+      sep=val;
+      return true;
+    }
+    if (tok.startsWith("type"))
+    {
+      try {
+        type=molType.valueOf(val);
+        return true;
+      } catch (Exception x)
+      {
+        warnings.append("Invalid molecule type '"+val+"'. Must be one of (");
+        for (molType v:molType.values())
+        {
+          warnings.append(" "+v);
+        }
+        warnings.append(")\n");
+      }
+    }
+    return false;
+  }
+
 }
\ No newline at end of file