blob: c81011f0cd17c35e12cc9b5cc236a7160cefd7ce (
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
55
56
|
package cgeo.geocaching.connector.ox;
import cgeo.geocaching.SearchResult;
import cgeo.geocaching.Settings;
import cgeo.geocaching.cgCache;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.connector.AbstractConnector;
import cgeo.geocaching.utils.CancellableHandler;
import java.util.regex.Pattern;
/**
* connector for OpenCaching.com
*
*/
public class OXConnector extends AbstractConnector {
private static final Pattern PATTERN_GEOCODE = Pattern.compile("OX[A-Z0-9]+", Pattern.CASE_INSENSITIVE);
@Override
public boolean canHandle(String geocode) {
return PATTERN_GEOCODE.matcher(geocode).matches();
}
@Override
public String getCacheUrl(cgCache cache) {
return "http://www.opencaching.com/#!geocache/" + cache.getGeocode();
}
@Override
public String getName() {
return "OpenCaching.com";
}
@Override
public String getHost() {
return "www.opencaching.com";
}
@Override
public String getLicenseText(cgCache cache) {
// NOT TO BE TRANSLATED
return "<a href=\"" + getCacheUrl(cache) + "\">" + getName() + "</a> data licensed under the Creative Commons BY-SA 3.0 License";
}
@Override
public SearchResult searchByGeocode(String geocode, String guid, cgeoapplication app, CancellableHandler handler) {
final cgCache cache = OpenCachingApi.searchByGeoCode(geocode);
if (cache == null) {
return null;
}
final SearchResult searchResult = new SearchResult();
searchResult.addCache(cache);
return searchResult.filterSearchResults(false, false, Settings.getCacheType());
}
}
|