diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2011-11-19 08:39:17 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2011-11-19 08:39:17 +0100 |
| commit | efe762ae85a8db89b36f0b3fe7bff37b3ae7a8e9 (patch) | |
| tree | 906de400a1bc35fbd5f87f8f9eec85755e1c795f /main/src/cgeo/geocaching/cgBase.java | |
| parent | d51848cfdc0c647de75bbdce7c006b685a7a49d1 (diff) | |
| download | cgeo-efe762ae85a8db89b36f0b3fe7bff37b3ae7a8e9.zip cgeo-efe762ae85a8db89b36f0b3fe7bff37b3ae7a8e9.tar.gz cgeo-efe762ae85a8db89b36f0b3fe7bff37b3ae7a8e9.tar.bz2 | |
don't use regular expressions for String replacement
* prefer StringUtils.replace over String.replaceAll
* have new test to verify this change
* remove cgBase instance from LogTemplates
Diffstat (limited to 'main/src/cgeo/geocaching/cgBase.java')
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 4ede03f..1acaf87 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -149,7 +149,7 @@ public class cgBase { private static String idBrowser = "Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.86 Safari/533.4"; final private cgeoapplication app; - final Context context; + private static Context context; final private Resources res; final private static Map<String, Integer> gcIcons = new HashMap<String, Integer>(); @@ -1073,7 +1073,7 @@ public class cgBase { // replace linebreak and paragraph tags String hint = GCConstants.PATTERN_LINEBREAK.matcher(result).replaceAll("\n"); if (hint != null) { - cache.setHint(hint.replaceAll(GCConstants.PATTERN_PARAGRAPH, "").trim()); + cache.setHint(StringUtils.replace(hint, "</p>", "").trim()); } } @@ -2486,7 +2486,7 @@ public class cgBase { } public static String urlencode_rfc3986(String text) { - final String encoded = URLEncoder.encode(text).replace("+", "%20").replaceAll("%7E", "~"); + final String encoded = StringUtils.replace(URLEncoder.encode(text).replace("+", "%20"), "%7E", "~"); return encoded; } @@ -3235,7 +3235,7 @@ public class cgBase { * milliseconds since the epoch * @return the formatted string */ - public String formatTime(long date) { + public static String formatTime(long date) { return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_TIME); } @@ -3247,7 +3247,7 @@ public class cgBase { * milliseconds since the epoch * @return the formatted string */ - public String formatDate(long date) { + public static String formatDate(long date) { return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE); } @@ -3260,7 +3260,7 @@ public class cgBase { * milliseconds since the epoch * @return the formatted string */ - public String formatFullDate(long date) { + public static String formatFullDate(long date) { return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR); } @@ -3273,7 +3273,7 @@ public class cgBase { * milliseconds since the epoch * @return the formatted string */ - public String formatShortDate(long date) { + public static String formatShortDate(long date) { return DateUtils.formatDateTime(context, date, DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NUMERIC_DATE); } |
