blob: c098d12e85866bcb1064f7d8a29305b920c44c82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
package cgeo.geocaching.connector.oc;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.connector.AbstractConnector;
import java.util.regex.Pattern;
public class OCConnector extends AbstractConnector {
private final String host;
private final String name;
private final Pattern codePattern;
private static final Pattern gpxZipFilePattern = Pattern.compile("oc[a-z]{2,3}\\d{5,}\\.zip", Pattern.CASE_INSENSITIVE);
public OCConnector(final String name, final String host, final String prefix) {
this.name = name;
this.host = host;
codePattern = Pattern.compile(prefix + "[A-Z0-9]+", Pattern.CASE_INSENSITIVE);
}
@Override
public boolean canHandle(String geocode) {
if (geocode == null) {
return false;
}
return codePattern.matcher(geocode).matches();
}
@Override
public String getName() {
return name;
}
@Override
public String getCacheUrl(cgCache cache) {
return getCacheUrlPrefix() + cache.getGeocode();
}
@Override
public String getHost() {
return host;
}
@Override
public boolean isZippedGPXFile(String fileName) {
return gpxZipFilePattern.matcher(fileName).matches();
}
@Override
protected String getCacheUrlPrefix() {
return "http://" + host + "/viewcache.php?wp=";
}
}
|