aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/cgCache.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/cgCache.java')
-rw-r--r--main/src/cgeo/geocaching/cgCache.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index cb1747a..19df7e3 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -11,6 +11,7 @@ import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.connector.gc.Tile;
import cgeo.geocaching.enumerations.CacheAttribute;
+import cgeo.geocaching.enumerations.CacheRealm;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
@@ -27,6 +28,7 @@ import cgeo.geocaching.utils.LazyInitializedList;
import cgeo.geocaching.utils.Log;
import cgeo.geocaching.utils.LogTemplateProvider;
import cgeo.geocaching.utils.LogTemplateProvider.LogContext;
+import cgeo.geocaching.utils.MatcherWrapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -47,7 +49,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
@@ -541,6 +542,10 @@ public class cgCache implements ICache, IWaypoint {
return getConnector().supportsOwnCoordinates();
}
+ public CacheRealm getCacheRealm() {
+ return getConnector().getCacheRealm();
+ }
+
@Override
public float getDifficulty() {
return difficulty;
@@ -751,7 +756,7 @@ public class cgCache implements ICache, IWaypoint {
@Override
public String getNameForSorting() {
if (null == nameForSorting) {
- final Matcher matcher = NUMBER_PATTERN.matcher(name);
+ final MatcherWrapper matcher = new MatcherWrapper(NUMBER_PATTERN, name);
if (matcher.find()) {
nameForSorting = name.replace(matcher.group(), StringUtils.leftPad(matcher.group(), 6, '0'));
}
@@ -1309,7 +1314,7 @@ public class cgCache implements ICache, IWaypoint {
final Pattern coordPattern = Pattern.compile("\\b[nNsS]{1}\\s*\\d"); // begin of coordinates
int count = 1;
String note = getPersonalNote();
- Matcher matcher = coordPattern.matcher(note);
+ MatcherWrapper matcher = new MatcherWrapper(coordPattern, note);
while (matcher.find()) {
try {
final Geopoint point = new Geopoint(note.substring(matcher.start()));
@@ -1326,7 +1331,7 @@ public class cgCache implements ICache, IWaypoint {
}
note = note.substring(matcher.start() + 1);
- matcher = coordPattern.matcher(note);
+ matcher = new MatcherWrapper(coordPattern, note);
}
} catch (Exception e) {
Log.e("cgCache.parseWaypointsFromNote: " + e.toString());
@@ -1568,7 +1573,7 @@ public class cgCache implements ICache, IWaypoint {
}
// 12:34
final Pattern time = Pattern.compile("\\b(\\d{1,2})\\:(\\d\\d)\\b");
- final Matcher matcher = time.matcher(getDescription());
+ final MatcherWrapper matcher = new MatcherWrapper(time, getDescription());
while (matcher.find()) {
try {
final int hours = Integer.valueOf(matcher.group(1));
@@ -1584,7 +1589,7 @@ public class cgCache implements ICache, IWaypoint {
final String hourLocalized = cgeoapplication.getInstance().getString(R.string.cache_time_full_hours);
if (StringUtils.isNotBlank(hourLocalized)) {
final Pattern fullHours = Pattern.compile("\\b(\\d{1,2})\\s+" + Pattern.quote(hourLocalized), Pattern.CASE_INSENSITIVE);
- final Matcher matcherHours = fullHours.matcher(getDescription());
+ final MatcherWrapper matcherHours = new MatcherWrapper(fullHours, getDescription());
if (matcherHours.find()) {
try {
final int hours = Integer.valueOf(matcherHours.group(1));