| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.javascript.web; |
| 22 |
|
|
| 23 |
|
import jalview.util.Platform; |
| 24 |
|
|
| 25 |
|
import java.net.MalformedURLException; |
| 26 |
|
import java.net.URI; |
| 27 |
|
import java.net.URISyntaxException; |
| 28 |
|
import java.net.URL; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| |
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 34 |
|
public class WebResource |
| 35 |
|
{ |
| 36 |
|
|
| 37 |
|
private String endpoint, params = ""; |
| 38 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 39 |
0 |
public WebResource(String endpoint)... |
| 40 |
|
{ |
| 41 |
0 |
this.endpoint = endpoint; |
| 42 |
|
} |
| 43 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 44 |
0 |
public WebResource queryParam(String key, String value)... |
| 45 |
|
{ |
| 46 |
0 |
params += (params == "" ? "?" : "&") + key + "=" |
| 47 |
|
+ Platform.encodeURI(value); |
| 48 |
0 |
return this; |
| 49 |
|
} |
| 50 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 51 |
0 |
public URI getURI()... |
| 52 |
|
{ |
| 53 |
0 |
try |
| 54 |
|
{ |
| 55 |
0 |
return new URI(endpoint + params); |
| 56 |
|
} catch (URISyntaxException e) |
| 57 |
|
{ |
| 58 |
0 |
e.printStackTrace(); |
| 59 |
0 |
return null; |
| 60 |
|
} |
| 61 |
|
} |
| 62 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 63 |
0 |
public Builder accept(String... encoding)... |
| 64 |
|
{ |
| 65 |
0 |
return new Builder(getURI(), encoding); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 68 |
|
public static class Builder |
| 69 |
|
{ |
| 70 |
|
private URI uri; |
| 71 |
|
|
| 72 |
|
private String[] encoding; |
| 73 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 74 |
0 |
public Builder(URI uri, String... encoding)... |
| 75 |
|
{ |
| 76 |
0 |
this.uri = uri; |
| 77 |
0 |
this.encoding = encoding; |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@param |
| 84 |
|
|
| 85 |
|
@return |
| 86 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 87 |
0 |
public ClientResponse get(Class<?> c)... |
| 88 |
|
{ |
| 89 |
0 |
try |
| 90 |
|
{ |
| 91 |
0 |
return new ClientResponse(new URL(uri.toString()), encoding); |
| 92 |
|
} catch (MalformedURLException e) |
| 93 |
|
{ |
| 94 |
0 |
return null; |
| 95 |
|
} |
| 96 |
|
} |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
} |