1 package jalview.javascript.web;
3 import jalview.util.Platform;
6 import java.net.URISyntaxException;
8 /* this class is a proxy for
11 public class WebResource
14 private String endpoint, params = "";
16 public WebResource(String endpoint) {
17 this.endpoint = endpoint;
21 public WebResource queryParam(String key, String value)
23 params += (params == "" ? "?" : "&") + key + "=";
24 params += Platform.encodeURI(value);
32 return new URI(endpoint + params);
33 } catch (URISyntaxException e)
40 public Builder accept(String... encoding)
42 return new Builder(getURI(), encoding);
46 public static class Builder {
48 private String[] encoding;
50 public Builder(URI uri, String... encoding)
53 this.encoding = encoding; // application/json
55 // TODO Auto-generated constructor stub
58 public ClientResponse get(Class<?> c) {
59 String data = uri.toString();
60 // c will be ClientResponse
61 data = Platform.getFileAsString(data);
62 return new ClientResponse(data, encoding);