From efe762ae85a8db89b36f0b3fe7bff37b3ae7a8e9 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sat, 19 Nov 2011 08:39:17 +0100 Subject: 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 --- main/src/cgeo/geocaching/cgBase.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'main/src/cgeo/geocaching/cgBase.java') 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 gcIcons = new HashMap(); @@ -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, "

", "").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); } -- cgit v1.1