From eb4ee7a9d4d0f132546b164c3483d62eb9e9f0db Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 8 Oct 2015 15:08:33 +1300 Subject: Clean up reported PMD issues --- .../traccar/geocode/BingMapsReverseGeocoder.java | 2 +- .../traccar/geocode/FactualReverseGeocoder.java | 2 +- .../traccar/geocode/GisgraphyReverseGeocoder.java | 2 +- src/org/traccar/geocode/GoogleReverseGeocoder.java | 22 +++++++++------------- src/org/traccar/geocode/JsonReverseGeocoder.java | 6 +----- .../traccar/geocode/MapQuestReverseGeocoder.java | 2 +- .../traccar/geocode/NominatimReverseGeocoder.java | 2 +- .../traccar/geocode/OpenCageReverseGeocoder.java | 2 +- src/org/traccar/geocode/ReverseGeocoder.java | 2 +- 9 files changed, 17 insertions(+), 25 deletions(-) (limited to 'src/org/traccar/geocode') diff --git a/src/org/traccar/geocode/BingMapsReverseGeocoder.java b/src/org/traccar/geocode/BingMapsReverseGeocoder.java index 34c3e4922..8c47febef 100644 --- a/src/org/traccar/geocode/BingMapsReverseGeocoder.java +++ b/src/org/traccar/geocode/BingMapsReverseGeocoder.java @@ -29,7 +29,7 @@ public class BingMapsReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonArray result = json.getJsonArray("resourceSets"); if (result != null) { JsonObject location = result.getJsonObject(0).getJsonArray("resources").getJsonObject(0).getJsonObject("address"); diff --git a/src/org/traccar/geocode/FactualReverseGeocoder.java b/src/org/traccar/geocode/FactualReverseGeocoder.java index 8f32cf624..6e5a48423 100644 --- a/src/org/traccar/geocode/FactualReverseGeocoder.java +++ b/src/org/traccar/geocode/FactualReverseGeocoder.java @@ -28,7 +28,7 @@ public class FactualReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonObject result = json.getJsonObject("response").getJsonObject("data"); if (result != null) { Address address = new Address(); diff --git a/src/org/traccar/geocode/GisgraphyReverseGeocoder.java b/src/org/traccar/geocode/GisgraphyReverseGeocoder.java index 59c4de723..ef9209fca 100644 --- a/src/org/traccar/geocode/GisgraphyReverseGeocoder.java +++ b/src/org/traccar/geocode/GisgraphyReverseGeocoder.java @@ -28,7 +28,7 @@ public class GisgraphyReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { Address address = new Address(); JsonObject result = json.getJsonArray("result").getJsonObject(0); diff --git a/src/org/traccar/geocode/GoogleReverseGeocoder.java b/src/org/traccar/geocode/GoogleReverseGeocoder.java index ade49a38b..ca1d42000 100644 --- a/src/org/traccar/geocode/GoogleReverseGeocoder.java +++ b/src/org/traccar/geocode/GoogleReverseGeocoder.java @@ -30,7 +30,7 @@ public class GoogleReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonArray results = json.getJsonArray("results"); if (!results.isEmpty()) { @@ -43,35 +43,31 @@ public class GoogleReverseGeocoder extends JsonReverseGeocoder { String value = component.getString("short_name"); - for (JsonString type : component.getJsonArray("types").getValuesAs(JsonString.class)) { + typesLoop: for (JsonString type : component.getJsonArray("types").getValuesAs(JsonString.class)) { switch (type.getString()) { case "street_number": address.setHouse(value); - break; + break typesLoop; case "route": address.setStreet(value); - break; + break typesLoop; case "locality": address.setSettlement(value); - break; + break typesLoop; case "administrative_area_level_2": address.setDistrict(value); - break; + break typesLoop; case "administrative_area_level_1": address.setState(value); - break; + break typesLoop; case "country": address.setCountry(value); - break; + break typesLoop; case "postal_code": address.setPostcode(value); - break; - default: - continue; + break typesLoop; } - - break; } } diff --git a/src/org/traccar/geocode/JsonReverseGeocoder.java b/src/org/traccar/geocode/JsonReverseGeocoder.java index 25b8e7853..88150a299 100644 --- a/src/org/traccar/geocode/JsonReverseGeocoder.java +++ b/src/org/traccar/geocode/JsonReverseGeocoder.java @@ -18,14 +18,10 @@ package org.traccar.geocode; import com.ning.http.client.AsyncCompletionHandler; import com.ning.http.client.Response; import org.traccar.Context; -import org.traccar.helper.Log; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonReader; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.AbstractMap; import java.util.Collections; import java.util.LinkedHashMap; @@ -84,6 +80,6 @@ public abstract class JsonReverseGeocoder implements ReverseGeocoder { }); } - protected abstract Address parseAddress(JsonObject json); + public abstract Address parseAddress(JsonObject json); } diff --git a/src/org/traccar/geocode/MapQuestReverseGeocoder.java b/src/org/traccar/geocode/MapQuestReverseGeocoder.java index 7141ea020..be3f51b04 100644 --- a/src/org/traccar/geocode/MapQuestReverseGeocoder.java +++ b/src/org/traccar/geocode/MapQuestReverseGeocoder.java @@ -29,7 +29,7 @@ public class MapQuestReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonArray result = json.getJsonArray("results"); if (result != null) { JsonArray locations = result.getJsonObject(0).getJsonArray("locations"); diff --git a/src/org/traccar/geocode/NominatimReverseGeocoder.java b/src/org/traccar/geocode/NominatimReverseGeocoder.java index 763987eae..933d9389c 100644 --- a/src/org/traccar/geocode/NominatimReverseGeocoder.java +++ b/src/org/traccar/geocode/NominatimReverseGeocoder.java @@ -28,7 +28,7 @@ public class NominatimReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonObject result = json.getJsonObject("address"); if (result != null) { diff --git a/src/org/traccar/geocode/OpenCageReverseGeocoder.java b/src/org/traccar/geocode/OpenCageReverseGeocoder.java index 1ad4aaf91..3104cb56a 100644 --- a/src/org/traccar/geocode/OpenCageReverseGeocoder.java +++ b/src/org/traccar/geocode/OpenCageReverseGeocoder.java @@ -29,7 +29,7 @@ public class OpenCageReverseGeocoder extends JsonReverseGeocoder { } @Override - protected Address parseAddress(JsonObject json) { + public Address parseAddress(JsonObject json) { JsonArray result = json.getJsonArray("results"); if (result != null) { JsonObject location = result.getJsonObject(0).getJsonObject("components"); diff --git a/src/org/traccar/geocode/ReverseGeocoder.java b/src/org/traccar/geocode/ReverseGeocoder.java index 1367e82dc..5d985fb31 100644 --- a/src/org/traccar/geocode/ReverseGeocoder.java +++ b/src/org/traccar/geocode/ReverseGeocoder.java @@ -17,7 +17,7 @@ package org.traccar.geocode; public interface ReverseGeocoder { - public interface ReverseGeocoderCallback { + interface ReverseGeocoderCallback { void onResult(String address); -- cgit v1.2.3