1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.urls; |
22 |
|
|
23 |
|
import jalview.urls.api.UrlProviderI; |
24 |
|
import jalview.util.UrlLink; |
25 |
|
|
26 |
|
import java.util.ArrayList; |
27 |
|
import java.util.HashMap; |
28 |
|
import java.util.List; |
29 |
|
import java.util.Map.Entry; |
30 |
|
import java.util.regex.Pattern; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
@version |
37 |
|
|
38 |
|
|
|
|
| 85.4% |
Uncovered Elements: 6 (41) |
Complexity: 12 |
Complexity Density: 0.46 |
|
39 |
|
public abstract class UrlProviderImpl implements UrlProviderI |
40 |
|
{ |
41 |
|
|
42 |
|
protected static final int MIN_SUBST_LENGTH = 4; |
43 |
|
|
44 |
|
private static final Pattern MIRIAM_PATTERN = Pattern |
45 |
|
.compile("^MIR:\\d{8}$"); |
46 |
|
|
47 |
|
protected String primaryUrl; |
48 |
|
|
|
|
| 81% |
Uncovered Elements: 4 (21) |
Complexity: 7 |
Complexity Density: 0.54 |
|
49 |
21 |
protected String getPrimaryUrl(String seqid,... |
50 |
|
HashMap<String, UrlLink> urls) |
51 |
|
{ |
52 |
21 |
if (seqid.length() < MIN_SUBST_LENGTH) |
53 |
|
{ |
54 |
3 |
return null; |
55 |
|
} |
56 |
18 |
else if (primaryUrl == null) |
57 |
|
{ |
58 |
7 |
return null; |
59 |
|
} |
60 |
11 |
else if (!urls.containsKey(primaryUrl)) |
61 |
|
{ |
62 |
0 |
return null; |
63 |
|
} |
64 |
|
else |
65 |
|
{ |
66 |
11 |
String url = null; |
67 |
11 |
UrlLink urlLink = urls.get(primaryUrl); |
68 |
11 |
String[] primaryUrls = urlLink.makeUrls(seqid, true); |
69 |
11 |
if (primaryUrls == null || primaryUrls[0] == null |
70 |
|
|| primaryUrls[0].length() < MIN_SUBST_LENGTH) |
71 |
|
{ |
72 |
0 |
url = null; |
73 |
|
} |
74 |
|
else |
75 |
|
{ |
76 |
|
|
77 |
11 |
url = primaryUrls[1]; |
78 |
|
} |
79 |
11 |
return url; |
80 |
|
} |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
83 |
0 |
@Override... |
84 |
|
public List<UrlLinkDisplay> getLinksForTable() |
85 |
|
{ |
86 |
0 |
return null; |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
89 |
65 |
protected ArrayList<UrlLinkDisplay> getLinksForTable(... |
90 |
|
HashMap<String, UrlLink> urls, ArrayList<String> selectedUrls, |
91 |
|
boolean selected) |
92 |
|
{ |
93 |
65 |
ArrayList<UrlLinkDisplay> displayLinks = new ArrayList<UrlLinkDisplay>(); |
94 |
65 |
for (Entry<String, UrlLink> entry : urls.entrySet()) |
95 |
|
{ |
96 |
6349 |
String key = entry.getKey(); |
97 |
6349 |
boolean isPrimary = (key.equals(primaryUrl)); |
98 |
6349 |
boolean isSelected; |
99 |
6349 |
if (selectedUrls != null) |
100 |
|
{ |
101 |
6274 |
isSelected = selectedUrls.contains(key); |
102 |
|
} |
103 |
|
else |
104 |
|
{ |
105 |
75 |
isSelected = selected; |
106 |
|
} |
107 |
6349 |
displayLinks.add(new UrlLinkDisplay(key, entry.getValue(), isSelected, |
108 |
|
isPrimary)); |
109 |
|
} |
110 |
65 |
return displayLinks; |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
662 |
protected boolean isMiriamId(String id)... |
114 |
|
{ |
115 |
662 |
return MIRIAM_PATTERN.matcher(id).matches(); |
116 |
|
} |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
20 |
@Override... |
119 |
|
public boolean isUserEntry(String id) |
120 |
|
{ |
121 |
20 |
return !isMiriamId(id); |
122 |
|
} |
123 |
|
} |