initial implementation of Rest client framework (JAL-715)
[jalview.git] / src / jalview / ws / rest / params / SeqVector.java
1 package jalview.ws.rest.params;
2
3 import jalview.datamodel.AlignmentI;
4 import jalview.datamodel.SequenceI;
5 import jalview.ws.rest.InputType;
6 import jalview.ws.rest.NoValidInputDataException;
7 import jalview.ws.rest.RestJob;
8 import jalview.ws.rest.InputType.molType;
9
10 import java.io.UnsupportedEncodingException;
11
12 import org.apache.http.entity.mime.content.ContentBody;
13 import org.apache.http.entity.mime.content.StringBody;
14
15 /**
16  * input a list of sequences separated by some separator 
17  * @author JimP
18  *
19  */
20 class SeqVector extends InputType {
21   String sep;
22   molType type;
23   public SeqVector()
24   {
25     super(new Class[] { AlignmentI.class} );
26   }
27
28   @Override
29   public ContentBody formatForInput(RestJob rj) throws UnsupportedEncodingException, NoValidInputDataException
30   {
31     StringBuffer idvector = new StringBuffer();
32     boolean list=false;
33     for (SequenceI seq:rj.getSequencesForInput(token, type))
34     {
35       if (list)
36       {
37         idvector.append(sep);
38       }
39       idvector.append(seq.getSequence());
40     }
41     return new StringBody(idvector.toString());
42   }
43 }