aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-06-08 09:09:06 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-06-08 09:09:06 +0200
commit97df73c9ca484902a5ab2744c7c5beb57d550b42 (patch)
tree8a67b26ef1a069705fe073fed326efc657c695f2 /main
parentc6a3b41c0afbf0eff9ea6683a9f836793e4cb12f (diff)
downloadcgeo-97df73c9ca484902a5ab2744c7c5beb57d550b42.zip
cgeo-97df73c9ca484902a5ab2744c7c5beb57d550b42.tar.gz
cgeo-97df73c9ca484902a5ab2744c7c5beb57d550b42.tar.bz2
refactoring: extract constant
* also optimize append for character only
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OkapiClient.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
index af59604..da7708f 100644
--- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
@@ -52,6 +52,8 @@ import java.util.TimeZone;
final public class OkapiClient {
+ private static final char SEPARATOR = '|';
+ private static final String SEPARATOR_STRING = Character.toString(SEPARATOR);
private static final SimpleDateFormat logDateFormat;
static {
@@ -135,7 +137,7 @@ final public class OkapiClient {
// Assumes level 3 OAuth
public static List<Geocache> getCachesAround(final Geopoint center, OCApiConnector connector) {
- String centerString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, center) + "|" + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, center);
+ String centerString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, center) + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, center);
final Parameters params = new Parameters("search_method", METHOD_SEARCH_NEAREST);
final Map<String, String> valueMap = new LinkedHashMap<String, String>();
valueMap.put("center", centerString);
@@ -169,9 +171,9 @@ final public class OkapiClient {
}
String bboxString = GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, viewport.bottomLeft)
- + "|" + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.bottomLeft)
- + "|" + GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, viewport.topRight)
- + "|" + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.topRight);
+ + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.bottomLeft)
+ + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LAT_DECDEGREE_RAW, viewport.topRight)
+ + SEPARATOR + GeopointFormatter.format(GeopointFormatter.Format.LON_DECDEGREE_RAW, viewport.topRight);
final Parameters params = new Parameters("search_method", METHOD_SEARCH_BBOX);
final Map<String, String> valueMap = new LinkedHashMap<String, String>();
valueMap.put("bbox", bboxString);
@@ -482,8 +484,8 @@ final public class OkapiClient {
}
private static Geopoint parseCoords(final String location) {
- final String latitude = StringUtils.substringBefore(location, "|");
- final String longitude = StringUtils.substringAfter(location, "|");
+ final String latitude = StringUtils.substringBefore(location, SEPARATOR_STRING);
+ final String longitude = StringUtils.substringAfter(location, SEPARATOR_STRING);
if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) {
return new Geopoint(latitude, longitude);
}
@@ -512,8 +514,8 @@ final public class OkapiClient {
}
private static void setLocation(final Geocache cache, final String location) {
- final String latitude = StringUtils.substringBefore(location, "|");
- final String longitude = StringUtils.substringAfter(location, "|");
+ final String latitude = StringUtils.substringBefore(location, SEPARATOR_STRING);
+ final String longitude = StringUtils.substringAfter(location, SEPARATOR_STRING);
cache.setCoords(new Geopoint(latitude, longitude));
}
@@ -579,7 +581,7 @@ final public class OkapiClient {
}
if (connector.getSupportedAuthLevel() == OAuthLevel.Level3) {
- return SERVICE_CACHE_CORE_FIELDS + "|" + SERVICE_CACHE_CORE_L3_FIELDS;
+ return SERVICE_CACHE_CORE_FIELDS + SEPARATOR + SERVICE_CACHE_CORE_L3_FIELDS;
}
return SERVICE_CACHE_CORE_FIELDS;
@@ -594,13 +596,13 @@ final public class OkapiClient {
StringBuilder res = new StringBuilder(500);
res.append(SERVICE_CACHE_CORE_FIELDS);
- res.append("|").append(SERVICE_CACHE_ADDITIONAL_FIELDS);
+ res.append(SEPARATOR).append(SERVICE_CACHE_ADDITIONAL_FIELDS);
if (connector.getSupportedAuthLevel() == OAuthLevel.Level3) {
- res.append("|").append(SERVICE_CACHE_CORE_L3_FIELDS);
- res.append("|").append(SERVICE_CACHE_ADDITIONAL_L3_FIELDS);
+ res.append(SEPARATOR).append(SERVICE_CACHE_CORE_L3_FIELDS);
+ res.append(SEPARATOR).append(SERVICE_CACHE_ADDITIONAL_L3_FIELDS);
}
if (connector.getApiSupport() == ApiSupport.current) {
- res.append("|").append(SERVICE_CACHE_ADDITIONAL_CURRENT_FIELDS);
+ res.append(SEPARATOR).append(SERVICE_CACHE_ADDITIONAL_CURRENT_FIELDS);
}
return res.toString();