diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2014-11-23 17:19:18 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2014-11-23 17:22:43 +0100 |
| commit | 5ba497ef1487c76f4673fd9a7f3c62512b8cef6f (patch) | |
| tree | bd12d4ad36075b5d47747063c84e0937143811b4 | |
| parent | 121d4285d747ce2ec707ad3cb7a9166833699fb6 (diff) | |
| download | cgeo-5ba497ef1487c76f4673fd9a7f3c62512b8cef6f.zip cgeo-5ba497ef1487c76f4673fd9a7f3c62512b8cef6f.tar.gz cgeo-5ba497ef1487c76f4673fd9a7f3c62512b8cef6f.tar.bz2 | |
reduce visibility
All changes done with UCDetector. This can help in seeing which packages
are not yet self contained (e.g. all the remaining public constants in
GCConstants).
47 files changed, 271 insertions, 267 deletions
diff --git a/main/src/cgeo/geocaching/Trackable.java b/main/src/cgeo/geocaching/Trackable.java index 479852b..15416bc 100644 --- a/main/src/cgeo/geocaching/Trackable.java +++ b/main/src/cgeo/geocaching/Trackable.java @@ -17,7 +17,7 @@ import java.util.LinkedList; import java.util.List; public class Trackable implements ILogable { - static final public int SPOTTED_UNSET = 0; + static final private int SPOTTED_UNSET = 0; static final public int SPOTTED_CACHE = 1; static final public int SPOTTED_USER = 2; static final public int SPOTTED_UNKNOWN = 3; @@ -54,7 +54,7 @@ public class Trackable implements ILogable { return guid; } - public void setGuid(String guid) { + public void setGuid(final String guid) { this.guid = guid; } @@ -63,7 +63,7 @@ public class Trackable implements ILogable { return geocode; } - public void setGeocode(String geocode) { + public void setGeocode(final String geocode) { this.geocode = StringUtils.upperCase(geocode); } @@ -71,7 +71,7 @@ public class Trackable implements ILogable { return iconUrl; } - public void setIconUrl(String iconUrl) { + public void setIconUrl(final String iconUrl) { this.iconUrl = iconUrl; } @@ -80,7 +80,7 @@ public class Trackable implements ILogable { return name; } - public void setName(String name) { + public void setName(final String name) { this.name = name; } @@ -88,7 +88,7 @@ public class Trackable implements ILogable { return type; } - public void setType(String type) { + public void setType(final String type) { this.type = type; } @@ -96,7 +96,7 @@ public class Trackable implements ILogable { return released; } - public void setReleased(Date released) { + public void setReleased(final Date released) { if (released == null) { this.released = null; } @@ -109,7 +109,7 @@ public class Trackable implements ILogable { return distance; } - public void setDistance(float distance) { + public void setDistance(final float distance) { this.distance = distance; } @@ -117,7 +117,7 @@ public class Trackable implements ILogable { return origin; } - public void setOrigin(String origin) { + public void setOrigin(final String origin) { this.origin = origin; } @@ -125,7 +125,7 @@ public class Trackable implements ILogable { return owner; } - public void setOwner(String owner) { + public void setOwner(final String owner) { this.owner = owner; } @@ -133,7 +133,7 @@ public class Trackable implements ILogable { return ownerGuid; } - public void setOwnerGuid(String ownerGuid) { + public void setOwnerGuid(final String ownerGuid) { this.ownerGuid = ownerGuid; } @@ -141,7 +141,7 @@ public class Trackable implements ILogable { return spottedName; } - public void setSpottedName(String spottedName) { + public void setSpottedName(final String spottedName) { this.spottedName = spottedName; } @@ -149,7 +149,7 @@ public class Trackable implements ILogable { return spottedType; } - public void setSpottedType(int spottedType) { + public void setSpottedType(final int spottedType) { this.spottedType = spottedType; } @@ -157,7 +157,7 @@ public class Trackable implements ILogable { return spottedGuid; } - public void setSpottedGuid(String spottedGuid) { + public void setSpottedGuid(final String spottedGuid) { this.spottedGuid = spottedGuid; } @@ -165,7 +165,7 @@ public class Trackable implements ILogable { return goal; } - public void setGoal(String goal) { + public void setGoal(final String goal) { this.goal = goal; } @@ -173,7 +173,7 @@ public class Trackable implements ILogable { return details; } - public void setDetails(String details) { + public void setDetails(final String details) { this.details = details; } @@ -181,7 +181,7 @@ public class Trackable implements ILogable { return image; } - public void setImage(String image) { + public void setImage(final String image) { this.image = image; } @@ -190,7 +190,7 @@ public class Trackable implements ILogable { return logs; } - public void setLogs(List<LogEntry> logs) { + public void setLogs(final List<LogEntry> logs) { this.logs = logs != null ? logs : new ArrayList<LogEntry>(); } @@ -215,7 +215,7 @@ public class Trackable implements ILogable { return trackingcode; } - public void setTrackingcode(String trackingcode) { + public void setTrackingcode(final String trackingcode) { this.trackingcode = trackingcode; } @@ -231,7 +231,7 @@ public class Trackable implements ILogable { return images; } - static public List<LogType> getPossibleLogTypes() { + static List<LogType> getPossibleLogTypes() { final List<LogType> logTypes = new ArrayList<>(); logTypes.add(LogType.RETRIEVED_IT); logTypes.add(LogType.GRABBED_IT); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java index 2394be0..00b0954 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java @@ -7,7 +7,7 @@ import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; -public abstract class AbstractRadarApp extends AbstractPointNavigationApp { +abstract class AbstractRadarApp extends AbstractPointNavigationApp { protected static final String RADAR_EXTRA_LONGITUDE = "longitude"; protected static final String RADAR_EXTRA_LATITUDE = "latitude"; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java index 391462b..5abe2fc 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java @@ -13,8 +13,8 @@ import android.content.Intent; /** * For use with any Android Wear geocaching apps which can handle the intent action below. */ -public class AndroidWearApp extends AbstractPointNavigationApp { - public static final String INTENT_ACTION = "cgeo.geocaching.wear.NAVIGATE_TO"; +class AndroidWearApp extends AbstractPointNavigationApp { + private static final String INTENT_ACTION = "cgeo.geocaching.wear.NAVIGATE_TO"; public AndroidWearApp() { super(getString(R.string.cache_menu_android_wear), R.id.cache_app_android_wear, INTENT_ACTION, null); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java index 194b229..5031dd8 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java @@ -8,6 +8,6 @@ import android.app.Activity; * interface for navigation to a coordinate. This one cannot be enabled/disabled. * */ -public interface GeopointNavigationApp { +interface GeopointNavigationApp { void navigate(final Activity activity, final Geopoint coords); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java index 1b5aa87..ccfd7a1 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java @@ -11,7 +11,7 @@ import android.app.Activity; import android.content.Intent; import android.net.Uri; -public class GoogleMapsDirectionApp extends AbstractPointNavigationApp { +class GoogleMapsDirectionApp extends AbstractPointNavigationApp { protected GoogleMapsDirectionApp() { super(getString(R.string.cache_menu_maps_directions), R.id.cache_app_google_maps_direction, null); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java index 1979fba..0e6e97a 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java @@ -12,7 +12,7 @@ abstract class GoogleNavigationApp extends AbstractPointNavigationApp { private final String mode; - protected GoogleNavigationApp(final int nameResourceId, final int id, final String mode) { + private GoogleNavigationApp(final int nameResourceId, final int id, final String mode) { super(getString(nameResourceId), id, null); this.mode = mode; } @@ -23,7 +23,7 @@ abstract class GoogleNavigationApp extends AbstractPointNavigationApp { } @Override - public void navigate(Activity activity, Geopoint coords) { + public void navigate(final Activity activity, final Geopoint coords) { try { activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri .parse("google.navigation:ll=" + coords.getLatitude() + "," diff --git a/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java b/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java index f1a504f..9403dcd 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java @@ -9,28 +9,28 @@ import com.mapswithme.maps.api.MapsWithMeApi; import android.app.Activity; -public class MapsWithMeApp extends AbstractPointNavigationApp { +class MapsWithMeApp extends AbstractPointNavigationApp { protected MapsWithMeApp() { super(getString(R.string.cache_menu_mapswithme), R.id.cache_app_mapswithme, null); } @Override - public void navigate(Activity activity, Geopoint coords) { + public void navigate(final Activity activity, final Geopoint coords) { navigate(activity, coords, getString(R.string.unknown)); } @Override - public void navigate(Activity activity, Geocache cache) { + public void navigate(final Activity activity, final Geocache cache) { navigate(activity, cache.getCoords(), cache.getName()); } - private static void navigate(Activity activity, Geopoint coords, String label) { + private static void navigate(final Activity activity, final Geopoint coords, final String label) { MapsWithMeApi.showPointOnMap(activity, coords.getLatitude(), coords.getLongitude(), label); } @Override - public void navigate(Activity activity, Waypoint waypoint) { + public void navigate(final Activity activity, final Waypoint waypoint) { navigate(activity, waypoint.getCoords(), waypoint.getName()); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index db68129..f346fc0 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -195,7 +195,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { * * @return */ - public static List<NavigationAppsEnum> getInstalledNavigationApps() { + static List<NavigationAppsEnum> getInstalledNavigationApps() { final List<NavigationAppsEnum> installedNavigationApps = new ArrayList<>(); for (final NavigationAppsEnum appEnum : NavigationAppsEnum.values()) { if (appEnum.app.isInstalled()) { @@ -208,7 +208,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { /** * @return all navigation apps, which are installed and activated in the settings */ - public static List<NavigationAppsEnum> getActiveNavigationApps() { + static List<NavigationAppsEnum> getActiveNavigationApps() { final List<NavigationAppsEnum> activeApps = new ArrayList<>(); for (final NavigationAppsEnum appEnum : getInstalledNavigationApps()) { if (Settings.isUseNavigationApp(appEnum)) { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java index 00a09e3..5d667c3 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java @@ -12,7 +12,7 @@ import android.net.Uri; * handler * */ -public class SygicNavigationApp extends AbstractPointNavigationApp { +class SygicNavigationApp extends AbstractPointNavigationApp { private static final String PACKAGE = "com.sygic.aura"; @@ -21,8 +21,8 @@ public class SygicNavigationApp extends AbstractPointNavigationApp { } @Override - public void navigate(Activity activity, Geopoint coords) { - String str = "http://com.sygic.aura/coordinate|" + coords.getLongitude() + "|" + coords.getLatitude() + "|show"; + public void navigate(final Activity activity, final Geopoint coords) { + final String str = "http://com.sygic.aura/coordinate|" + coords.getLongitude() + "|" + coords.getLatitude() + "|show"; activity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str))); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java index c26ec3e..ba85a1d 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/WaypointNavigationApp.java @@ -8,7 +8,7 @@ import android.app.Activity; * interface for navigation to a waypoint * */ -public interface WaypointNavigationApp { +interface WaypointNavigationApp { void navigate(final Activity activity, final Waypoint waypoint); boolean isEnabled(final Waypoint waypoint); diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel13.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel13.java index eb2be4b..946d20e 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel13.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel13.java @@ -8,7 +8,7 @@ import android.graphics.Point; import android.view.WindowManager; @TargetApi(value = 13) -public class AndroidLevel13 implements AndroidLevel13Interface { +class AndroidLevel13 implements AndroidLevel13Interface { @Override public int getDisplayWidth() { @@ -17,7 +17,7 @@ public class AndroidLevel13 implements AndroidLevel13Interface { @Override public Point getDisplaySize() { - Point dimensions = new Point(); + final Point dimensions = new Point(); ((WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay().getSize(dimensions); return dimensions; diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel13Emulation.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel13Emulation.java index 56c784f..8e2e7ec 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel13Emulation.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel13Emulation.java @@ -8,7 +8,7 @@ import android.view.Display; import android.view.WindowManager; @SuppressWarnings("deprecation") -public class AndroidLevel13Emulation implements AndroidLevel13Interface { +class AndroidLevel13Emulation implements AndroidLevel13Interface { @Override public int getDisplayWidth() { diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel13Interface.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel13Interface.java index 8483e38..6d3f3c3 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel13Interface.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel13Interface.java @@ -2,7 +2,7 @@ package cgeo.geocaching.compatibility; import android.graphics.Point; -public interface AndroidLevel13Interface { +interface AndroidLevel13Interface { int getDisplayWidth(); Point getDisplaySize(); diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel19.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel19.java index ed4849f..6b15a00 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel19.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel19.java @@ -5,12 +5,12 @@ import android.app.Activity; import android.content.Intent; @TargetApi(19) -public class AndroidLevel19 implements AndroidLevel19Interface { +class AndroidLevel19 implements AndroidLevel19Interface { @Override public void importGpxFromStorageAccessFramework(final Activity activity, final int requestCode) { // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser. - Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); + final Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // Filter to only show results that can be "opened", such as a file (as opposed to a list // of contacts or timezones) diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel19Emulation.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel19Emulation.java index 99f140f..7404c82 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel19Emulation.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel19Emulation.java @@ -2,10 +2,10 @@ package cgeo.geocaching.compatibility; import android.app.Activity; -public class AndroidLevel19Emulation implements AndroidLevel19Interface { +class AndroidLevel19Emulation implements AndroidLevel19Interface { @Override - public void importGpxFromStorageAccessFramework(Activity activity, int requestCode) { + public void importGpxFromStorageAccessFramework(final Activity activity, final int requestCode) { // do nothing } diff --git a/main/src/cgeo/geocaching/compatibility/AndroidLevel19Interface.java b/main/src/cgeo/geocaching/compatibility/AndroidLevel19Interface.java index 9a27cd8..de397a6 100644 --- a/main/src/cgeo/geocaching/compatibility/AndroidLevel19Interface.java +++ b/main/src/cgeo/geocaching/compatibility/AndroidLevel19Interface.java @@ -2,6 +2,6 @@ package cgeo.geocaching.compatibility; import android.app.Activity; -public interface AndroidLevel19Interface { +interface AndroidLevel19Interface { void importGpxFromStorageAccessFramework(Activity activity, final int requestCode); } diff --git a/main/src/cgeo/geocaching/connector/GeocachingAustraliaConnector.java b/main/src/cgeo/geocaching/connector/GeocachingAustraliaConnector.java index 3c72c89..5535472 100644 --- a/main/src/cgeo/geocaching/connector/GeocachingAustraliaConnector.java +++ b/main/src/cgeo/geocaching/connector/GeocachingAustraliaConnector.java @@ -5,7 +5,7 @@ import cgeo.geocaching.Geocache; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; -public class GeocachingAustraliaConnector extends AbstractConnector { +class GeocachingAustraliaConnector extends AbstractConnector { @Override public String getName() { diff --git a/main/src/cgeo/geocaching/connector/GeopeitusConnector.java b/main/src/cgeo/geocaching/connector/GeopeitusConnector.java index 8b82c1b..0dc7a44 100644 --- a/main/src/cgeo/geocaching/connector/GeopeitusConnector.java +++ b/main/src/cgeo/geocaching/connector/GeopeitusConnector.java @@ -5,7 +5,7 @@ import cgeo.geocaching.Geocache; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; -public class GeopeitusConnector extends AbstractConnector { +class GeopeitusConnector extends AbstractConnector { @Override public String getName() { @@ -28,7 +28,7 @@ public class GeopeitusConnector extends AbstractConnector { } @Override - public boolean canHandle(@NonNull String geocode) { + public boolean canHandle(@NonNull final String geocode) { return StringUtils.startsWith(geocode, "GE") && isNumericId(geocode.substring(2)); } diff --git a/main/src/cgeo/geocaching/connector/NoLoggingManager.java b/main/src/cgeo/geocaching/connector/NoLoggingManager.java index e2e5d4c..afec2e9 100644 --- a/main/src/cgeo/geocaching/connector/NoLoggingManager.java +++ b/main/src/cgeo/geocaching/connector/NoLoggingManager.java @@ -11,7 +11,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; -public class NoLoggingManager extends AbstractLoggingManager { +class NoLoggingManager extends AbstractLoggingManager { @Override public void init() { @@ -19,12 +19,12 @@ public class NoLoggingManager extends AbstractLoggingManager { } @Override - public LogResult postLog(Geocache cache, LogType logType, Calendar date, String log, String logPassword, List<TrackableLog> trackableLogs) { + public LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, final String logPassword, final List<TrackableLog> trackableLogs) { return new LogResult(StatusCode.LOG_POST_ERROR, ""); } @Override - public ImageResult postLogImage(String logId, String imageCaption, String imageDescription, Uri imageUri) { + public ImageResult postLogImage(final String logId, final String imageCaption, final String imageDescription, final Uri imageUri) { return new ImageResult(StatusCode.LOG_POST_ERROR, ""); } diff --git a/main/src/cgeo/geocaching/connector/UnknownConnector.java b/main/src/cgeo/geocaching/connector/UnknownConnector.java index a2eb8e4..a88f2c5 100644 --- a/main/src/cgeo/geocaching/connector/UnknownConnector.java +++ b/main/src/cgeo/geocaching/connector/UnknownConnector.java @@ -5,7 +5,7 @@ import cgeo.geocaching.Geocache; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; -public class UnknownConnector extends AbstractConnector { +class UnknownConnector extends AbstractConnector { @Override public String getName() { @@ -13,7 +13,7 @@ public class UnknownConnector extends AbstractConnector { } @Override - public String getCacheUrl(@NonNull Geocache cache) { + public String getCacheUrl(@NonNull final Geocache cache) { return null; // we have no url for these caches } diff --git a/main/src/cgeo/geocaching/connector/WaymarkingConnector.java b/main/src/cgeo/geocaching/connector/WaymarkingConnector.java index d6eaab5..2ed54a0 100644 --- a/main/src/cgeo/geocaching/connector/WaymarkingConnector.java +++ b/main/src/cgeo/geocaching/connector/WaymarkingConnector.java @@ -5,7 +5,7 @@ import cgeo.geocaching.Geocache; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; -public class WaymarkingConnector extends AbstractConnector { +class WaymarkingConnector extends AbstractConnector { @Override public String getName() { @@ -13,7 +13,7 @@ public class WaymarkingConnector extends AbstractConnector { } @Override - public String getCacheUrl(@NonNull Geocache cache) { + public String getCacheUrl(@NonNull final Geocache cache) { return getCacheUrlPrefix() + cache.getGeocode(); } @@ -23,7 +23,7 @@ public class WaymarkingConnector extends AbstractConnector { } @Override - public boolean isOwner(Geocache cache) { + public boolean isOwner(final Geocache cache) { // this connector has no user management return false; } @@ -34,7 +34,7 @@ public class WaymarkingConnector extends AbstractConnector { } @Override - public boolean canHandle(@NonNull String geocode) { + public boolean canHandle(@NonNull final String geocode) { return StringUtils.startsWith(geocode, "WM"); } } diff --git a/main/src/cgeo/geocaching/connector/ec/ECApi.java b/main/src/cgeo/geocaching/connector/ec/ECApi.java index 64177af..9cd08c5 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECApi.java +++ b/main/src/cgeo/geocaching/connector/ec/ECApi.java @@ -35,18 +35,22 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; -public class ECApi { +final class ECApi { private static final String API_HOST = "https://extremcaching.com/exports/"; private static final ECLogin ecLogin = ECLogin.getInstance(); private static final SynchronizedDateFormat LOG_DATE_FORMAT = new SynchronizedDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ", TimeZone.getTimeZone("UTC"), Locale.US); - public static String getIdFromGeocode(final String geocode) { + private ECApi() { + // utility class with static methods + } + + static String getIdFromGeocode(final String geocode) { return StringUtils.removeStartIgnoreCase(geocode, "EC"); } - public static Geocache searchByGeoCode(final String geocode) { + static Geocache searchByGeoCode(final String geocode) { final Parameters params = new Parameters("id", getIdFromGeocode(geocode)); final HttpResponse response = apiRequest("gpx.php", params); @@ -57,7 +61,7 @@ public class ECApi { return null; } - public static Collection<Geocache> searchByBBox(final Viewport viewport) { + static Collection<Geocache> searchByBBox(final Viewport viewport) { if (viewport.getLatitudeSpan() == 0 || viewport.getLongitudeSpan() == 0) { return Collections.emptyList(); @@ -74,7 +78,7 @@ public class ECApi { } - public static Collection<Geocache> searchByCenter(final Geopoint center) { + static Collection<Geocache> searchByCenter(final Geopoint center) { final Parameters params = new Parameters("fnc", "center"); params.add("distance", "20"); @@ -85,11 +89,11 @@ public class ECApi { return importCachesFromJSON(response); } - public static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log) { + static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log) { return postLog(cache, logType, date, log, false); } - public static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, boolean isRetry) { + private static LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, final boolean isRetry) { final Parameters params = new Parameters("cache_id", cache.getGeocode()); params.add("type", logType.type); params.add("log", log); @@ -163,7 +167,7 @@ public class ECApi { try { return new GPX10Parser(StoredList.TEMPORARY_LIST.id).parse(response.getEntity().getContent(), null); - } catch (Exception e) { + } catch (final Exception e) { Log.e("Error importing gpx from extremcaching.com", e); return Collections.emptyList(); } diff --git a/main/src/cgeo/geocaching/connector/ec/ECLoggingManager.java b/main/src/cgeo/geocaching/connector/ec/ECLoggingManager.java index ded2d71..cbeaf67 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECLoggingManager.java +++ b/main/src/cgeo/geocaching/connector/ec/ECLoggingManager.java @@ -13,13 +13,13 @@ import android.net.Uri; import java.util.Calendar; import java.util.List; -public class ECLoggingManager extends AbstractLoggingManager { +class ECLoggingManager extends AbstractLoggingManager { private final ECConnector connector; private final Geocache cache; - private LogCacheActivity activity; + private final LogCacheActivity activity; - public ECLoggingManager(final LogCacheActivity activity, final ECConnector connector, final Geocache cache) { + ECLoggingManager(final LogCacheActivity activity, final ECConnector connector, final Geocache cache) { this.connector = connector; this.cache = cache; this.activity = activity; diff --git a/main/src/cgeo/geocaching/connector/ec/ECLogin.java b/main/src/cgeo/geocaching/connector/ec/ECLogin.java index 35c2db4..342cbc6 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECLogin.java +++ b/main/src/cgeo/geocaching/connector/ec/ECLogin.java @@ -23,7 +23,7 @@ import java.io.IOException; public class ECLogin extends AbstractLogin { private final CgeoApplication app = CgeoApplication.getInstance(); - protected String sessionId = null; + private String sessionId = null; private ECLogin() { // singleton @@ -38,7 +38,7 @@ public class ECLogin extends AbstractLogin { } @Override - protected StatusCode login(boolean retry) { + protected StatusCode login(final boolean retry) { final ImmutablePair<String, String> login = Settings.getCredentials(ECConnector.getInstance()); if (StringUtils.isEmpty(login.left) || StringUtils.isEmpty(login.right)) { @@ -50,9 +50,9 @@ public class ECLogin extends AbstractLogin { setActualStatus(app.getString(R.string.init_login_popup_working)); final Parameters params = new Parameters("user", login.left, "pass", login.right); - HttpResponse loginResponse = Network.postRequest("https://extremcaching.com/exports/apilogin.php", params); + final HttpResponse loginResponse = Network.postRequest("https://extremcaching.com/exports/apilogin.php", params); - String loginData = Network.getResponseData(loginResponse); + final String loginData = Network.getResponseData(loginResponse); if (StringUtils.isBlank(loginData)) { Log.e("ECLogin.login: Failed to retrieve login data"); @@ -87,7 +87,7 @@ public class ECLogin extends AbstractLogin { * @param data * @return <code>true</code> if user is logged in, <code>false</code> otherwise */ - public boolean getLoginStatus(@Nullable final String data) { + private boolean getLoginStatus(@Nullable final String data) { if (StringUtils.isBlank(data) || StringUtils.equals(data, "[]")) { Log.e("ECLogin.getLoginStatus: No or empty data given"); return false; diff --git a/main/src/cgeo/geocaching/connector/gc/GCConstants.java b/main/src/cgeo/geocaching/connector/gc/GCConstants.java index 872e5df..05639cf 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCConstants.java +++ b/main/src/cgeo/geocaching/connector/gc/GCConstants.java @@ -15,174 +15,173 @@ import java.util.regex.Pattern; public final class GCConstants { static final String GC_URL = "http://www.geocaching.com/"; - static final String GC_TILE_URL = "http://tiles.geocaching.com/"; + private static final String GC_TILE_URL = "http://tiles.geocaching.com/"; /** Live Map */ - public final static @NonNull String URL_LIVE_MAP = GC_URL + "map/default.aspx"; + final static @NonNull String URL_LIVE_MAP = GC_URL + "map/default.aspx"; /** Live Map pop-up */ - public final static @NonNull String URL_LIVE_MAP_DETAILS = GC_TILE_URL + "map.details"; + final static @NonNull String URL_LIVE_MAP_DETAILS = GC_TILE_URL + "map.details"; /** Caches in a tile */ - public final static @NonNull String URL_MAP_INFO = GC_TILE_URL + "map.info"; + final static @NonNull String URL_MAP_INFO = GC_TILE_URL + "map.info"; /** Tile itself */ - public final static @NonNull String URL_MAP_TILE = GC_TILE_URL + "map.png"; + final static @NonNull String URL_MAP_TILE = GC_TILE_URL + "map.png"; /** Format used by geocaching.com when user is not logged in. */ public static final String DEFAULT_GC_DATE = "MM/dd/yyyy"; /** * Patterns for parsing the result of a (detailed) search */ - public final static Pattern PATTERN_HINT = Pattern.compile("<div id=\"div_hint\"[^>]*>(.*?)</div>", Pattern.DOTALL); - public final static Pattern PATTERN_DESC = Pattern.compile("<span id=\"ctl00_ContentBody_LongDescription\">(.*?)</span>\\s*</div>\\s*<p>\\s*</p>\\s*<p id=\"ctl00_ContentBody_hints\">", Pattern.DOTALL); - public final static Pattern PATTERN_SHORTDESC = Pattern.compile("<span id=\"ctl00_ContentBody_ShortDescription\">(.*?)</span>\\s*</div>", Pattern.DOTALL); - public final static Pattern PATTERN_GEOCODE = Pattern.compile("class=\"CoordInfoCode\">(GC[0-9A-Z]+)</span>"); - public final static Pattern PATTERN_CACHEID = Pattern.compile("/seek/log\\.aspx\\?ID=(\\d+)"); - public final static Pattern PATTERN_GUID = Pattern.compile(Pattern.quote("&wid=") + "([0-9a-z\\-]+)" + Pattern.quote("&")); - public final static Pattern PATTERN_SIZE = Pattern.compile("<div id=\"ctl00_ContentBody_size\" class=\"CacheSize[^\"]*\">[^<]*<p[^>]*>[^S]*Size[^:]*:[^<]*<span[^>]*>[^<]*<img src=\"[^\"]*/icons/container/[a-z_]+\\.gif\" alt=\"\\w+: ([^\"]+)\"[^>]*>[^<]*<small>[^<]*</small>[^<]*</span>[^<]*</p>"); - public final static Pattern PATTERN_LATLON = Pattern.compile("<span id=\"uxLatLon\"[^>]*>(.*?)</span>"); - public final static Pattern PATTERN_LATLON_ORIG = Pattern.compile("\\{\"isUserDefined\":true[^}]+?\"oldLatLngDisplay\":\"([^\"]+)\"\\}"); - public final static Pattern PATTERN_LOCATION = Pattern.compile(Pattern.quote("<span id=\"ctl00_ContentBody_Location\">In ") + "(?:<a href=[^>]*>)?(.*?)<"); - public final static Pattern PATTERN_PERSONALNOTE = Pattern.compile("<span id=\"cache_note\"[^>]*>(.*?)</span>", Pattern.DOTALL); - public final static Pattern PATTERN_NAME = Pattern.compile("<span id=\"ctl00_ContentBody_CacheName\">(.*?)</span>"); - public final static Pattern PATTERN_DIFFICULTY = Pattern.compile("<span id=\"ctl00_ContentBody_uxLegendScale\"[^>]*>[^<]*<img src=\"[^\"]*/images/stars/stars([0-9_]+)\\.gif\""); - public final static Pattern PATTERN_TERRAIN = Pattern.compile("<span id=\"ctl00_ContentBody_Localize[\\d]+\"[^>]*>[^<]*<img src=\"[^\"]*/images/stars/stars([0-9_]+)\\.gif\""); - public final static Pattern PATTERN_OWNER_USERID = Pattern.compile("other caches <a href=\"/seek/nearest\\.aspx\\?u=(.*?)\">hidden</a> or"); - public final static Pattern PATTERN_FOUND = Pattern.compile("ctl00_ContentBody_GeoNav_logText\">(Found It|Attended)"); - public final static Pattern PATTERN_FOUND_ALTERNATIVE = Pattern.compile("<div class=\"StatusInformationWidget FavoriteWidget\""); - public final static Pattern PATTERN_OWNER_DISPLAYNAME = Pattern.compile("<div id=\"ctl00_ContentBody_mcd1\">[^<]+<a href=\"[^\"]+\">([^<]+)</a>"); - public final static Pattern PATTERN_TYPE = Pattern.compile("<a href=\"/seek/nearest.aspx\\?tx=([0-9a-f-]+)"); - public final static Pattern PATTERN_HIDDEN = Pattern.compile("<div id=\"ctl00_ContentBody_mcd2\">\\W*Hidden[\\s:]*([^<]+?)</div>"); - public final static Pattern PATTERN_HIDDENEVENT = Pattern.compile("Event\\s*Date\\s*:\\s*([^<]+)<div id=\"calLinks\">", Pattern.DOTALL); - public final static Pattern PATTERN_FAVORITE = Pattern.compile("<div id=\"pnlFavoriteCache\">"); // without 'class="hideMe"' inside the tag ! - public final static Pattern PATTERN_FAVORITECOUNT = Pattern.compile("<span class=\"favorite-value\">\\D*([0-9]+?)\\D*</span>"); - public final static Pattern PATTERN_COUNTLOGS = Pattern.compile("<span id=\"ctl00_ContentBody_lblFindCounts\"><p(.+?)</p></span>"); - public final static Pattern PATTERN_LOGBOOK = Pattern.compile("initalLogs = (\\{.+\\});"); // The "inital" typo really comes from gc.com site + final static Pattern PATTERN_HINT = Pattern.compile("<div id=\"div_hint\"[^>]*>(.*?)</div>", Pattern.DOTALL); + final static Pattern PATTERN_DESC = Pattern.compile("<span id=\"ctl00_ContentBody_LongDescription\">(.*?)</span>\\s*</div>\\s*<p>\\s*</p>\\s*<p id=\"ctl00_ContentBody_hints\">", Pattern.DOTALL); + final static Pattern PATTERN_SHORTDESC = Pattern.compile("<span id=\"ctl00_ContentBody_ShortDescription\">(.*?)</span>\\s*</div>", Pattern.DOTALL); + final static Pattern PATTERN_GEOCODE = Pattern.compile("class=\"CoordInfoCode\">(GC[0-9A-Z]+)</span>"); + final static Pattern PATTERN_CACHEID = Pattern.compile("/seek/log\\.aspx\\?ID=(\\d+)"); + final static Pattern PATTERN_GUID = Pattern.compile(Pattern.quote("&wid=") + "([0-9a-z\\-]+)" + Pattern.quote("&")); + final static Pattern PATTERN_SIZE = Pattern.compile("<div id=\"ctl00_ContentBody_size\" class=\"CacheSize[^\"]*\">[^<]*<p[^>]*>[^S]*Size[^:]*:[^<]*<span[^>]*>[^<]*<img src=\"[^\"]*/icons/container/[a-z_]+\\.gif\" alt=\"\\w+: ([^\"]+)\"[^>]*>[^<]*<small>[^<]*</small>[^<]*</span>[^<]*</p>"); + final static Pattern PATTERN_LATLON = Pattern.compile("<span id=\"uxLatLon\"[^>]*>(.*?)</span>"); + final static Pattern PATTERN_LATLON_ORIG = Pattern.compile("\\{\"isUserDefined\":true[^}]+?\"oldLatLngDisplay\":\"([^\"]+)\"\\}"); + final static Pattern PATTERN_LOCATION = Pattern.compile(Pattern.quote("<span id=\"ctl00_ContentBody_Location\">In ") + "(?:<a href=[^>]*>)?(.*?)<"); + final static Pattern PATTERN_PERSONALNOTE = Pattern.compile("<span id=\"cache_note\"[^>]*>(.*?)</span>", Pattern.DOTALL); + final static Pattern PATTERN_NAME = Pattern.compile("<span id=\"ctl00_ContentBody_CacheName\">(.*?)</span>"); + final static Pattern PATTERN_DIFFICULTY = Pattern.compile("<span id=\"ctl00_ContentBody_uxLegendScale\"[^>]*>[^<]*<img src=\"[^\"]*/images/stars/stars([0-9_]+)\\.gif\""); + final static Pattern PATTERN_TERRAIN = Pattern.compile("<span id=\"ctl00_ContentBody_Localize[\\d]+\"[^>]*>[^<]*<img src=\"[^\"]*/images/stars/stars([0-9_]+)\\.gif\""); + final static Pattern PATTERN_OWNER_USERID = Pattern.compile("other caches <a href=\"/seek/nearest\\.aspx\\?u=(.*?)\">hidden</a> or"); + final static Pattern PATTERN_FOUND = Pattern.compile("ctl00_ContentBody_GeoNav_logText\">(Found It|Attended)"); + final static Pattern PATTERN_FOUND_ALTERNATIVE = Pattern.compile("<div class=\"StatusInformationWidget FavoriteWidget\""); + final static Pattern PATTERN_OWNER_DISPLAYNAME = Pattern.compile("<div id=\"ctl00_ContentBody_mcd1\">[^<]+<a href=\"[^\"]+\">([^<]+)</a>"); + final static Pattern PATTERN_TYPE = Pattern.compile("<a href=\"/seek/nearest.aspx\\?tx=([0-9a-f-]+)"); + final static Pattern PATTERN_HIDDEN = Pattern.compile("<div id=\"ctl00_ContentBody_mcd2\">\\W*Hidden[\\s:]*([^<]+?)</div>"); + final static Pattern PATTERN_HIDDENEVENT = Pattern.compile("Event\\s*Date\\s*:\\s*([^<]+)<div id=\"calLinks\">", Pattern.DOTALL); + final static Pattern PATTERN_FAVORITE = Pattern.compile("<div id=\"pnlFavoriteCache\">"); // without 'class="hideMe"' inside the tag ! + final static Pattern PATTERN_FAVORITECOUNT = Pattern.compile("<span class=\"favorite-value\">\\D*([0-9]+?)\\D*</span>"); + final static Pattern PATTERN_COUNTLOGS = Pattern.compile("<span id=\"ctl00_ContentBody_lblFindCounts\"><p(.+?)</p></span>"); /** Two groups ! */ - public final static Pattern PATTERN_COUNTLOG = Pattern.compile("<img src=\"/images/logtypes/([0-9]+)\\.png\"[^>]+> (\\d*[,.]?\\d+)"); - public static final Pattern PATTERN_PREMIUMMEMBERS = Pattern.compile("<p class=\"Warning NoBottomSpacing\">This is a Premium Member Only cache.</p>"); - public final static Pattern PATTERN_ATTRIBUTES = Pattern.compile("Attributes\\s*</h3>[^<]*<div class=\"WidgetBody\">((?:[^<]*<img src=\"[^\"]+\" alt=\"[^\"]+\"[^>]*>)+?)[^<]*<p"); + final static Pattern PATTERN_COUNTLOG = Pattern.compile("<img src=\"/images/logtypes/([0-9]+)\\.png\"[^>]+> (\\d*[,.]?\\d+)"); + static final Pattern PATTERN_PREMIUMMEMBERS = Pattern.compile("<p class=\"Warning NoBottomSpacing\">This is a Premium Member Only cache.</p>"); + final static Pattern PATTERN_ATTRIBUTES = Pattern.compile("Attributes\\s*</h3>[^<]*<div class=\"WidgetBody\">((?:[^<]*<img src=\"[^\"]+\" alt=\"[^\"]+\"[^>]*>)+?)[^<]*<p"); /** Two groups ! */ - public final static Pattern PATTERN_ATTRIBUTESINSIDE = Pattern.compile("[^<]*<img src=\"([^\"]+)\" alt=\"([^\"]+?)\""); - public final static Pattern PATTERN_SPOILER_IMAGE = Pattern.compile("<a href=\"(http://imgcdn\\.geocaching\\.com[^.]+\\.(jpg|jpeg|png|gif))\"[^>]+>([^<]+)</a>(?:<br />([^<]+)<br /><br />)?"); - public final static Pattern PATTERN_INVENTORY = Pattern.compile("<span id=\"ctl00_ContentBody_uxTravelBugList_uxInventoryLabel\">\\W*Inventory[^<]*</span>[^<]*</h3>[^<]*<div class=\"WidgetBody\">([^<]*<ul>(([^<]*<li>[^<]*<a href=\"[^\"]+\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>[^<]+<\\/span>[^<]*<\\/a>[^<]*<\\/li>)+)[^<]*<\\/ul>)?"); - public final static Pattern PATTERN_INVENTORYINSIDE = Pattern.compile("[^<]*<li>[^<]*<a href=\"[a-z0-9\\-\\_\\.\\?\\/\\:\\@]*\\/track\\/details\\.aspx\\?guid=([0-9a-z\\-]+)[^\"]*\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>([^<]+)<\\/span>[^<]*<\\/a>[^<]*<\\/li>"); - public final static Pattern PATTERN_WATCHLIST = Pattern.compile(Pattern.quote("watchlist.aspx") + ".{1,50}" + Pattern.quote("action=rem")); - public final static Pattern PATTERN_RELATED_WEB_PAGE = Pattern.compile("id=\"ctl00_ContentBody_uxCacheUrl\" title=\"Related Web Page\" href=\"(.*?)\">"); + final static Pattern PATTERN_ATTRIBUTESINSIDE = Pattern.compile("[^<]*<img src=\"([^\"]+)\" alt=\"([^\"]+?)\""); + final static Pattern PATTERN_SPOILER_IMAGE = Pattern.compile("<a href=\"(http://imgcdn\\.geocaching\\.com[^.]+\\.(jpg|jpeg|png|gif))\"[^>]+>([^<]+)</a>(?:<br />([^<]+)<br /><br />)?"); + final static Pattern PATTERN_INVENTORY = Pattern.compile("<span id=\"ctl00_ContentBody_uxTravelBugList_uxInventoryLabel\">\\W*Inventory[^<]*</span>[^<]*</h3>[^<]*<div class=\"WidgetBody\">([^<]*<ul>(([^<]*<li>[^<]*<a href=\"[^\"]+\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>[^<]+<\\/span>[^<]*<\\/a>[^<]*<\\/li>)+)[^<]*<\\/ul>)?"); + final static Pattern PATTERN_INVENTORYINSIDE = Pattern.compile("[^<]*<li>[^<]*<a href=\"[a-z0-9\\-\\_\\.\\?\\/\\:\\@]*\\/track\\/details\\.aspx\\?guid=([0-9a-z\\-]+)[^\"]*\"[^>]*>[^<]*<img src=\"[^\"]+\"[^>]*>[^<]*<span>([^<]+)<\\/span>[^<]*<\\/a>[^<]*<\\/li>"); + final static Pattern PATTERN_WATCHLIST = Pattern.compile(Pattern.quote("watchlist.aspx") + ".{1,50}" + Pattern.quote("action=rem")); + final static Pattern PATTERN_RELATED_WEB_PAGE = Pattern.compile("id=\"ctl00_ContentBody_uxCacheUrl\" title=\"Related Web Page\" href=\"(.*?)\">"); // Info box top-right public static final Pattern PATTERN_LOGIN_NAME = Pattern.compile("\"SignedInProfileLink\">(.*?)</a>"); public static final Pattern PATTERN_MEMBER_STATUS = Pattern.compile("<span id=\"ctl00_litPMLevel\">([^<]+)</span>"); - public static final String MEMBER_STATUS_RENEW = "<a id=\"ctl00_hlRenew"; + static final String MEMBER_STATUS_RENEW = "<a id=\"ctl00_hlRenew"; public static final String MEMBER_STATUS_PREMIUM = "Premium Member"; public static final String MEMBER_STATUS_CHARTER = "Charter Member"; /** Use replaceAll("[,.]","") on the resulting string before converting to an int */ - public static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("<strong[^>]*>.*?([\\d,.]+) Caches? Found", Pattern.DOTALL); - public static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("src=\"(https?://(imgcdn\\.geocaching\\.com|[^>\"]+\\.cloudfront\\.net)/avatar/[0-9a-f-]+\\.jpg)\"[^>]*alt=\""); - public static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("ctl00_ContentBody_lbUsername\">.*<strong>(.*)</strong>"); - public static final Pattern PATTERN_CUSTOMDATE = Pattern.compile("<option selected=\"selected\" value=\"([ /.Mdy-]+)\">"); - public static final Pattern PATTERN_MAP_LOGGED_IN = Pattern.compile("<a href=\"https?://www.geocaching.com/my/\" class=\"CommonUsername\""); + static final Pattern PATTERN_CACHES_FOUND = Pattern.compile("<strong[^>]*>.*?([\\d,.]+) Caches? Found", Pattern.DOTALL); + static final Pattern PATTERN_AVATAR_IMAGE_PROFILE_PAGE = Pattern.compile("src=\"(https?://(imgcdn\\.geocaching\\.com|[^>\"]+\\.cloudfront\\.net)/avatar/[0-9a-f-]+\\.jpg)\"[^>]*alt=\""); + static final Pattern PATTERN_LOGIN_NAME_LOGIN_PAGE = Pattern.compile("ctl00_ContentBody_lbUsername\">.*<strong>(.*)</strong>"); + static final Pattern PATTERN_CUSTOMDATE = Pattern.compile("<option selected=\"selected\" value=\"([ /.Mdy-]+)\">"); + static final Pattern PATTERN_MAP_LOGGED_IN = Pattern.compile("<a href=\"https?://www.geocaching.com/my/\" class=\"CommonUsername\""); /** * Patterns for parsing trackables */ - public final static Pattern PATTERN_TRACKABLE_GUID = Pattern.compile("<a id=\"ctl00_ContentBody_lnkPrint\" title=\"[^\"]*\" href=\".*sheet\\.aspx\\?guid=([a-z0-9\\-]+)\"[^>]*>[^<]*</a>"); - public final static Pattern PATTERN_TRACKABLE_GEOCODE = Pattern.compile("<strong>(TB[0-9A-Z]+)[^<]*</strong> to reference this item."); + final static Pattern PATTERN_TRACKABLE_GUID = Pattern.compile("<a id=\"ctl00_ContentBody_lnkPrint\" title=\"[^\"]*\" href=\".*sheet\\.aspx\\?guid=([a-z0-9\\-]+)\"[^>]*>[^<]*</a>"); + final static Pattern PATTERN_TRACKABLE_GEOCODE = Pattern.compile("<strong>(TB[0-9A-Z]+)[^<]*</strong> to reference this item."); // multiple error codes, depending on the search term for the trackable code - public final static String ERROR_TB_DOES_NOT_EXIST = "does not exist in the system"; - public final static String ERROR_TB_ELEMENT_EXCEPTION = "ElementNotFound Exception"; - public final static String ERROR_TB_ARITHMETIC_OVERFLOW = "operation resulted in an overflow"; - public final static String ERROR_TB_NOT_ACTIVATED = "hasn't been activated"; + final static String ERROR_TB_DOES_NOT_EXIST = "does not exist in the system"; + final static String ERROR_TB_ELEMENT_EXCEPTION = "ElementNotFound Exception"; + final static String ERROR_TB_ARITHMETIC_OVERFLOW = "operation resulted in an overflow"; + final static String ERROR_TB_NOT_ACTIVATED = "hasn't been activated"; /** * some parts of the webpage don't correctly encode the name, therefore this pattern must be checked with a * trackable name that needs HTML encoding */ - public final static Pattern PATTERN_TRACKABLE_NAME = Pattern.compile("<span id=\"ctl00_ContentBody_lbHeading\">(.*?)</span>"); + final static Pattern PATTERN_TRACKABLE_NAME = Pattern.compile("<span id=\"ctl00_ContentBody_lbHeading\">(.*?)</span>"); /** Two groups ! */ - public final static Pattern PATTERN_TRACKABLE_OWNER = Pattern.compile("<a id=\"ctl00_ContentBody_BugDetails_BugOwner\"[^>]+href=\"https?://www.geocaching.com/profile/\\?guid=(.*?)\">(.*?)</a>"); - public final static Pattern PATTERN_TRACKABLE_RELEASES = Pattern.compile("<dt>\\W*Released:[^<]*</dt>[^<]*<dd>[^<]*<span id=\"ctl00_ContentBody_BugDetails_BugReleaseDate\">([^<]+)<\\/span>[^<]*</dd>"); - public final static Pattern PATTERN_TRACKABLE_ORIGIN = Pattern.compile("<dt>\\W*Origin:[^<]*</dt>[^<]*<dd>[^<]*<span id=\"ctl00_ContentBody_BugDetails_BugOrigin\">([^<]+)<\\/span>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_OWNER = Pattern.compile("<a id=\"ctl00_ContentBody_BugDetails_BugOwner\"[^>]+href=\"https?://www.geocaching.com/profile/\\?guid=(.*?)\">(.*?)</a>"); + final static Pattern PATTERN_TRACKABLE_RELEASES = Pattern.compile("<dt>\\W*Released:[^<]*</dt>[^<]*<dd>[^<]*<span id=\"ctl00_ContentBody_BugDetails_BugReleaseDate\">([^<]+)<\\/span>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_ORIGIN = Pattern.compile("<dt>\\W*Origin:[^<]*</dt>[^<]*<dd>[^<]*<span id=\"ctl00_ContentBody_BugDetails_BugOrigin\">([^<]+)<\\/span>[^<]*</dd>"); /** Two groups ! */ - public final static Pattern PATTERN_TRACKABLE_SPOTTEDCACHE = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\" title=\"[^\"]*\" href=\"[^\"]*/seek/cache_details.aspx\\?guid=([a-z0-9\\-]+)\">In ([^<]+)</a>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_SPOTTEDCACHE = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\" title=\"[^\"]*\" href=\"[^\"]*/seek/cache_details.aspx\\?guid=([a-z0-9\\-]+)\">In ([^<]+)</a>[^<]*</dd>"); /** Two groups ! */ - public final static Pattern PATTERN_TRACKABLE_SPOTTEDUSER = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\" href=\"[^\"]*/profile/\\?guid=([a-z0-9\\-]+)\">In the hands of ([^<]+).</a>[^<]*</dd>"); - public final static Pattern PATTERN_TRACKABLE_SPOTTEDUNKNOWN = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\">Unknown Location[^<]*</a>[^<]*</dd>"); - public final static Pattern PATTERN_TRACKABLE_SPOTTEDOWNER = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\">In the hands of the owner[^<]*</a>[^<]*</dd>"); - public final static Pattern PATTERN_TRACKABLE_GOAL = Pattern.compile("<div id=\"TrackableGoal\">[^<]*<p>(.*?)</p>[^<]*</div>", Pattern.DOTALL); + final static Pattern PATTERN_TRACKABLE_SPOTTEDUSER = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\" href=\"[^\"]*/profile/\\?guid=([a-z0-9\\-]+)\">In the hands of ([^<]+).</a>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_SPOTTEDUNKNOWN = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\">Unknown Location[^<]*</a>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_SPOTTEDOWNER = Pattern.compile("<dt>\\W*Recently Spotted:[^<]*</dt>[^<]*<dd>[^<]*<a id=\"ctl00_ContentBody_BugDetails_BugLocation\">In the hands of the owner[^<]*</a>[^<]*</dd>"); + final static Pattern PATTERN_TRACKABLE_GOAL = Pattern.compile("<div id=\"TrackableGoal\">[^<]*<p>(.*?)</p>[^<]*</div>", Pattern.DOTALL); /** Four groups */ - public final static Pattern PATTERN_TRACKABLE_DETAILSIMAGE = Pattern.compile("<h3>\\W*About This Item[^<]*</h3>[^<]*<div id=\"TrackableDetails\">([^<]*<p>([^<]*<img id=\"ctl00_ContentBody_BugDetails_BugImage\" class=\"[^\"]+\" src=\"([^\"]+)\"[^>]*>)?[^<]*</p>)?[^<]*<p[^>]*>(.*)</p>[^<]*</div> <div id=\"ctl00_ContentBody_BugDetails_uxAbuseReport\">"); - public final static Pattern PATTERN_TRACKABLE_ICON = Pattern.compile("<img id=\"ctl00_ContentBody_BugTypeImage\" class=\"TravelBugHeaderIcon\" src=\"([^\"]+)\"[^>]*>"); - public final static Pattern PATTERN_TRACKABLE_TYPE = Pattern.compile("<img id=\"ctl00_ContentBody_BugTypeImage\" class=\"TravelBugHeaderIcon\" src=\"[^\"]+\" alt=\"([^\"]+)\"[^>]*>"); - public final static Pattern PATTERN_TRACKABLE_DISTANCE = Pattern.compile("<h4[^>]*\\W*Tracking History \\(([0-9.,]+(km|mi))[^\\)]*\\)"); - public final static Pattern PATTERN_TRACKABLE_LOG = Pattern.compile("<tr class=\"Data BorderTop .+?/images/logtypes/([^.]+)\\.png[^>]+> ([^<]+)</td>.+?guid.+?>([^<]+)</a>.+?(?:guid=([^\"]+)\">(<span[^>]+>)?([^<]+)</.+?)?<td colspan=\"4\">\\s*<div>(.*?)</div>\\s*(?:<ul.+?ul>)?\\s*</td>\\s*</tr>"); - public final static Pattern PATTERN_TRACKABLE_LOG_IMAGES = Pattern.compile("<li><a href=\"([^\"]+)\".+?LogImgTitle.+?>([^<]*)</"); + final static Pattern PATTERN_TRACKABLE_DETAILSIMAGE = Pattern.compile("<h3>\\W*About This Item[^<]*</h3>[^<]*<div id=\"TrackableDetails\">([^<]*<p>([^<]*<img id=\"ctl00_ContentBody_BugDetails_BugImage\" class=\"[^\"]+\" src=\"([^\"]+)\"[^>]*>)?[^<]*</p>)?[^<]*<p[^>]*>(.*)</p>[^<]*</div> <div id=\"ctl00_ContentBody_BugDetails_uxAbuseReport\">"); + final static Pattern PATTERN_TRACKABLE_ICON = Pattern.compile("<img id=\"ctl00_ContentBody_BugTypeImage\" class=\"TravelBugHeaderIcon\" src=\"([^\"]+)\"[^>]*>"); + final static Pattern PATTERN_TRACKABLE_TYPE = Pattern.compile("<img id=\"ctl00_ContentBody_BugTypeImage\" class=\"TravelBugHeaderIcon\" src=\"[^\"]+\" alt=\"([^\"]+)\"[^>]*>"); + final static Pattern PATTERN_TRACKABLE_DISTANCE = Pattern.compile("<h4[^>]*\\W*Tracking History \\(([0-9.,]+(km|mi))[^\\)]*\\)"); + final static Pattern PATTERN_TRACKABLE_LOG = Pattern.compile("<tr class=\"Data BorderTop .+?/images/logtypes/([^.]+)\\.png[^>]+> ([^<]+)</td>.+?guid.+?>([^<]+)</a>.+?(?:guid=([^\"]+)\">(<span[^>]+>)?([^<]+)</.+?)?<td colspan=\"4\">\\s*<div>(.*?)</div>\\s*(?:<ul.+?ul>)?\\s*</td>\\s*</tr>"); + final static Pattern PATTERN_TRACKABLE_LOG_IMAGES = Pattern.compile("<li><a href=\"([^\"]+)\".+?LogImgTitle.+?>([^<]*)</"); /** * Patterns for parsing the result of a search (next) */ - public final static Pattern PATTERN_SEARCH_TYPE = Pattern.compile("<td class=\"Merge\">.*?<img src=\"[^\"]*/images/wpttypes/[^.]+\\.gif\" alt=\"([^\"]+)\" title=\"[^\"]+\"[^>]*>[^<]*</a>"); - public final static Pattern PATTERN_SEARCH_GUIDANDDISABLED = Pattern.compile("SearchResultsWptType.*?<a href=\"[^\"]*\" class=\"lnk ([^\"]*)\"><span>([^<]*)</span>[^|]*[|][^|]*[|]([^<]*)<"); + final static Pattern PATTERN_SEARCH_TYPE = Pattern.compile("<td class=\"Merge\">.*?<img src=\"[^\"]*/images/wpttypes/[^.]+\\.gif\" alt=\"([^\"]+)\" title=\"[^\"]+\"[^>]*>[^<]*</a>"); + final static Pattern PATTERN_SEARCH_GUIDANDDISABLED = Pattern.compile("SearchResultsWptType.*?<a href=\"[^\"]*\" class=\"lnk ([^\"]*)\"><span>([^<]*)</span>[^|]*[|][^|]*[|]([^<]*)<"); /** Two groups **/ - public final static Pattern PATTERN_SEARCH_TRACKABLES = Pattern.compile("<a id=\"ctl00_ContentBody_dlResults_ctl[0-9]+_uxTravelBugList\" class=\"tblist\" data-tbcount=\"([0-9]+)\" data-id=\"[^\"]*\"[^>]*>(.*)</a>"); + final static Pattern PATTERN_SEARCH_TRACKABLES = Pattern.compile("<a id=\"ctl00_ContentBody_dlResults_ctl[0-9]+_uxTravelBugList\" class=\"tblist\" data-tbcount=\"([0-9]+)\" data-id=\"[^\"]*\"[^>]*>(.*)</a>"); /** Second group used */ - public final static Pattern PATTERN_SEARCH_TRACKABLESINSIDE = Pattern.compile("(<img src=\"[^\"]+\" alt=\"([^\"]+)\" title=\"[^\"]*\" />[^<]*)"); - public final static Pattern PATTERN_SEARCH_DIRECTION_DISTANCE = Pattern.compile("<img src=\"/images/icons/compass/([^\\.]+)\\.gif\"[^>]*>[^<]*<br />([^<]+)</span>"); - public final static Pattern PATTERN_SEARCH_DIFFICULTY_TERRAIN = Pattern.compile("<span class=\"small\">([0-5]([\\.,]5)?)/([0-5]([\\.,]5)?)</span><br />"); - public final static Pattern PATTERN_SEARCH_CONTAINER = Pattern.compile("<img src=\"/images/icons/container/([^\\.]+)\\.gif\""); - public final static Pattern PATTERN_SEARCH_GEOCODE = Pattern.compile("\\|\\W*(GC[0-9A-Z]+)[^\\|]*\\|"); - public final static Pattern PATTERN_SEARCH_ID = Pattern.compile("name=\"CID\"[^v]*value=\"(\\d+)\""); - public final static Pattern PATTERN_SEARCH_FAVORITE = Pattern.compile("favorite-rank\">([0-9,.]+)</span>"); - public final static Pattern PATTERN_SEARCH_TOTALCOUNT = Pattern.compile("<span>Total Records\\D*(\\d+)<"); - public final static Pattern PATTERN_SEARCH_RECAPTCHA = Pattern.compile("<script[^>]*src=\"[^\"]*/recaptcha/api/challenge\\?k=([^\"]+)\"[^>]*>"); + final static Pattern PATTERN_SEARCH_TRACKABLESINSIDE = Pattern.compile("(<img src=\"[^\"]+\" alt=\"([^\"]+)\" title=\"[^\"]*\" />[^<]*)"); + final static Pattern PATTERN_SEARCH_DIRECTION_DISTANCE = Pattern.compile("<img src=\"/images/icons/compass/([^\\.]+)\\.gif\"[^>]*>[^<]*<br />([^<]+)</span>"); + final static Pattern PATTERN_SEARCH_DIFFICULTY_TERRAIN = Pattern.compile("<span class=\"small\">([0-5]([\\.,]5)?)/([0-5]([\\.,]5)?)</span><br />"); + final static Pattern PATTERN_SEARCH_CONTAINER = Pattern.compile("<img src=\"/images/icons/container/([^\\.]+)\\.gif\""); + final static Pattern PATTERN_SEARCH_GEOCODE = Pattern.compile("\\|\\W*(GC[0-9A-Z]+)[^\\|]*\\|"); + final static Pattern PATTERN_SEARCH_ID = Pattern.compile("name=\"CID\"[^v]*value=\"(\\d+)\""); + final static Pattern PATTERN_SEARCH_FAVORITE = Pattern.compile("favorite-rank\">([0-9,.]+)</span>"); + final static Pattern PATTERN_SEARCH_TOTALCOUNT = Pattern.compile("<span>Total Records\\D*(\\d+)<"); + final static Pattern PATTERN_SEARCH_RECAPTCHA = Pattern.compile("<script[^>]*src=\"[^\"]*/recaptcha/api/challenge\\?k=([^\"]+)\"[^>]*>"); public final static Pattern PATTERN_SEARCH_RECAPTCHACHALLENGE = Pattern.compile("challenge : '([^']+)'"); - public final static Pattern PATTERN_SEARCH_HIDDEN_DATE = Pattern.compile("<td style=\"width:70px\">[^<]+<span class=\"small\">([^<]+)</span>"); + final static Pattern PATTERN_SEARCH_HIDDEN_DATE = Pattern.compile("<td style=\"width:70px\">[^<]+<span class=\"small\">([^<]+)</span>"); /** * Patterns for waypoints */ - public final static Pattern PATTERN_WPTYPE = Pattern.compile("\\/wpttypes\\/sm\\/(.+)\\.jpg"); - public final static Pattern PATTERN_WPPREFIXORLOOKUPORLATLON = Pattern.compile(">([^<]*<[^>]+>)?([^<]+)(<[^>]+>[^<]*)?<\\/td>"); - public final static Pattern PATTERN_WPNAME = Pattern.compile(">[^<]*<a[^>]+>([^<]*)<\\/a>"); - public final static Pattern PATTERN_WPNOTE = Pattern.compile("colspan=\"6\">(.*)" + Pattern.quote("</td>"), Pattern.DOTALL); + final static Pattern PATTERN_WPTYPE = Pattern.compile("\\/wpttypes\\/sm\\/(.+)\\.jpg"); + final static Pattern PATTERN_WPPREFIXORLOOKUPORLATLON = Pattern.compile(">([^<]*<[^>]+>)?([^<]+)(<[^>]+>[^<]*)?<\\/td>"); + final static Pattern PATTERN_WPNAME = Pattern.compile(">[^<]*<a[^>]+>([^<]*)<\\/a>"); + final static Pattern PATTERN_WPNOTE = Pattern.compile("colspan=\"6\">(.*)" + Pattern.quote("</td>"), Pattern.DOTALL); /** * Patterns for different purposes */ /** replace line break and paragraph tags */ - public final static Pattern PATTERN_LINEBREAK = Pattern.compile("<(br|p)[^>]*>"); - public final static Pattern PATTERN_TYPEBOX = Pattern.compile("<select name=\"ctl00\\$ContentBody\\$LogBookPanel1\\$ddLogType\" id=\"ctl00_ContentBody_LogBookPanel1_ddLogType\"[^>]*>" + final static Pattern PATTERN_LINEBREAK = Pattern.compile("<(br|p)[^>]*>"); + final static Pattern PATTERN_TYPEBOX = Pattern.compile("<select name=\"ctl00\\$ContentBody\\$LogBookPanel1\\$ddLogType\" id=\"ctl00_ContentBody_LogBookPanel1_ddLogType\"[^>]*>" + "(([^<]*<option[^>]*>[^<]+</option>)+)[^<]*</select>", Pattern.CASE_INSENSITIVE); - public final static Pattern PATTERN_TYPE2 = Pattern.compile("<option( selected=\"selected\")? value=\"(\\d+)\">[^<]+</option>", Pattern.CASE_INSENSITIVE); + final static Pattern PATTERN_TYPE2 = Pattern.compile("<option( selected=\"selected\")? value=\"(\\d+)\">[^<]+</option>", Pattern.CASE_INSENSITIVE); // FIXME: pattern is over specified - public final static Pattern PATTERN_TRACKABLE = Pattern.compile("<tr id=\"ctl00_ContentBody_LogBookPanel1_uxTrackables_repTravelBugs_ctl[0-9]+_row\"[^>]*>" + final static Pattern PATTERN_TRACKABLE = Pattern.compile("<tr id=\"ctl00_ContentBody_LogBookPanel1_uxTrackables_repTravelBugs_ctl[0-9]+_row\"[^>]*>" + "[^<]*<td>[^<]*<a href=\"[^\"]+\">([A-Z0-9]+)</a>[^<]*</td>[^<]*<td>([^<]+)</td>[^<]*<td>" + "[^<]*<select name=\"ctl00\\$ContentBody\\$LogBookPanel1\\$uxTrackables\\$repTravelBugs\\$ctl([0-9]+)\\$ddlAction\"[^>]*>" + "([^<]*<option value=\"([0-9]+)(_[a-z]+)?\">[^<]+</option>)+" + "[^<]*</select>[^<]*</td>[^<]*</tr>", Pattern.CASE_INSENSITIVE); - public final static Pattern PATTERN_MAINTENANCE = Pattern.compile("<span id=\"ctl00_ContentBody_LogBookPanel1_lbConfirm\"[^>]*>([^<]*<font[^>]*>)?([^<]+)(</font>[^<]*)?</span>", Pattern.CASE_INSENSITIVE); - public final static Pattern PATTERN_OK1 = Pattern.compile("<h2[^>]*>[^<]*<span id=\"ctl00_ContentBody_lbHeading\"[^>]*>[^<]*</span>[^<]*</h2>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - public final static Pattern PATTERN_OK2 = Pattern.compile("<div id=[\"|']ctl00_ContentBody_LogBookPanel1_ViewLogPanel[\"|']>", Pattern.CASE_INSENSITIVE); - public final static Pattern PATTERN_IMAGE_UPLOAD_URL = Pattern.compile("title=\"Click for Larger Image\"\\s*src=\"(.*?)\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - public final static Pattern PATTERN_VIEWSTATEFIELDCOUNT = Pattern.compile("id=\"__VIEWSTATEFIELDCOUNT\"[^(value)]+value=\"(\\d+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - public final static Pattern PATTERN_VIEWSTATES = Pattern.compile("id=\"__VIEWSTATE(\\d*)\"[^(value)]+value=\"([^\"]+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - public final static Pattern PATTERN_USERTOKEN = Pattern.compile("userToken\\s*=\\s*'([^']+)'"); - public final static Pattern PATTERN_LIST_PQ = Pattern.compile(Pattern.quote("(") + "(\\d+)" + Pattern.quote(")") + ".+?guid=(.+?)\".*?title=\"(.+?)\""); + final static Pattern PATTERN_MAINTENANCE = Pattern.compile("<span id=\"ctl00_ContentBody_LogBookPanel1_lbConfirm\"[^>]*>([^<]*<font[^>]*>)?([^<]+)(</font>[^<]*)?</span>", Pattern.CASE_INSENSITIVE); + final static Pattern PATTERN_OK1 = Pattern.compile("<h2[^>]*>[^<]*<span id=\"ctl00_ContentBody_lbHeading\"[^>]*>[^<]*</span>[^<]*</h2>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + final static Pattern PATTERN_OK2 = Pattern.compile("<div id=[\"|']ctl00_ContentBody_LogBookPanel1_ViewLogPanel[\"|']>", Pattern.CASE_INSENSITIVE); + final static Pattern PATTERN_IMAGE_UPLOAD_URL = Pattern.compile("title=\"Click for Larger Image\"\\s*src=\"(.*?)\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + final static Pattern PATTERN_VIEWSTATEFIELDCOUNT = Pattern.compile("id=\"__VIEWSTATEFIELDCOUNT\"[^(value)]+value=\"(\\d+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + final static Pattern PATTERN_VIEWSTATES = Pattern.compile("id=\"__VIEWSTATE(\\d*)\"[^(value)]+value=\"([^\"]+)\"[^>]+>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + final static Pattern PATTERN_USERTOKEN = Pattern.compile("userToken\\s*=\\s*'([^']+)'"); + final static Pattern PATTERN_LIST_PQ = Pattern.compile(Pattern.quote("(") + "(\\d+)" + Pattern.quote(")") + ".+?guid=(.+?)\".*?title=\"(.+?)\""); /** Live Map since 14.02.2012 */ - public final static Pattern PATTERN_USERSESSION = Pattern.compile("UserSession\\('([^']+)'"); - public final static Pattern PATTERN_SESSIONTOKEN = Pattern.compile("sessionToken:'([^']+)'"); + final static Pattern PATTERN_USERSESSION = Pattern.compile("UserSession\\('([^']+)'"); + final static Pattern PATTERN_SESSIONTOKEN = Pattern.compile("sessionToken:'([^']+)'"); - public final static Pattern PATTERN_LOG_IMAGE_UPLOAD = Pattern.compile("/seek/upload\\.aspx\\?LID=(\\d+)", Pattern.CASE_INSENSITIVE); + final static Pattern PATTERN_LOG_IMAGE_UPLOAD = Pattern.compile("/seek/upload\\.aspx\\?LID=(\\d+)", Pattern.CASE_INSENSITIVE); - public final static String STRING_PREMIUMONLY_2 = "Sorry, the owner of this listing has made it viewable to Premium Members only."; - public final static String STRING_PREMIUMONLY_1 = "has chosen to make this cache listing visible to Premium Members only."; - public final static String STRING_UNPUBLISHED_OTHER = "you cannot view this cache listing until it has been published"; - public final static String STRING_UNPUBLISHED_FROM_SEARCH = "class=\"UnpublishedCacheSearchWidget"; // do not include closing brace as the CSS can contain additional styles - public final static String STRING_UNKNOWN_ERROR = "An Error Has Occurred"; - public final static String STRING_DISABLED = "<li>This cache is temporarily unavailable."; - public final static String STRING_ARCHIVED = "<li>This cache has been archived,"; - public final static String STRING_CACHEDETAILS = "id=\"cacheDetails\""; + final static String STRING_PREMIUMONLY_2 = "Sorry, the owner of this listing has made it viewable to Premium Members only."; + final static String STRING_PREMIUMONLY_1 = "has chosen to make this cache listing visible to Premium Members only."; + final static String STRING_UNPUBLISHED_OTHER = "you cannot view this cache listing until it has been published"; + final static String STRING_UNPUBLISHED_FROM_SEARCH = "class=\"UnpublishedCacheSearchWidget"; // do not include closing brace as the CSS can contain additional styles + final static String STRING_UNKNOWN_ERROR = "An Error Has Occurred"; + final static String STRING_DISABLED = "<li>This cache is temporarily unavailable."; + final static String STRING_ARCHIVED = "<li>This cache has been archived,"; + final static String STRING_CACHEDETAILS = "id=\"cacheDetails\""; /** Number of logs to retrieve from GC.com */ - public final static int NUMBER_OF_LOGS = 35; + final static int NUMBER_OF_LOGS = 35; /** Maximum number of chars for personal note. **/ public final static int PERSONAL_NOTE_MAX_CHARS = 500; diff --git a/main/src/cgeo/geocaching/connector/gc/GCLoggingManager.java b/main/src/cgeo/geocaching/connector/gc/GCLoggingManager.java index bf021b9..ce32ac6 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCLoggingManager.java +++ b/main/src/cgeo/geocaching/connector/gc/GCLoggingManager.java @@ -28,7 +28,7 @@ import java.util.Calendar; import java.util.Collections; import java.util.List; -public class GCLoggingManager extends AbstractLoggingManager implements LoaderManager.LoaderCallbacks<String> { +class GCLoggingManager extends AbstractLoggingManager implements LoaderManager.LoaderCallbacks<String> { private final LogCacheActivity activity; private final Geocache cache; @@ -38,14 +38,14 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa private List<LogType> possibleLogTypes; private boolean hasLoaderError = true; - public GCLoggingManager(final LogCacheActivity activity, final Geocache cache) { + GCLoggingManager(final LogCacheActivity activity, final Geocache cache) { this.activity = activity; this.cache = cache; } @Nullable @Override - public Loader<String> onCreateLoader(int arg0, Bundle arg1) { + public Loader<String> onCreateLoader(final int arg0, final Bundle arg1) { if (!Settings.isLogin()) { // allow offline logging ActivityMixin.showToast(activity, activity.getResources().getString(R.string.err_login)); return null; @@ -54,7 +54,7 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa } @Override - public void onLoadFinished(Loader<String> arg0, String page) { + public void onLoadFinished(final Loader<String> arg0, final String page) { if (page == null) { hasLoaderError = true; @@ -71,7 +71,7 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa } @Override - public void onLoaderReset(Loader<String> arg0) { + public void onLoaderReset(final Loader<String> arg0) { // nothing to do } @@ -81,7 +81,7 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa } @Override - public LogResult postLog(Geocache cache, LogType logType, Calendar date, String log, String logPassword, List<TrackableLog> trackableLogs) { + public LogResult postLog(final Geocache cache, final LogType logType, final Calendar date, final String log, final String logPassword, final List<TrackableLog> trackableLogs) { try { final ImmutablePair<StatusCode, String> postResult = GCParser.postLog(cache.getGeocode(), cache.getCacheId(), viewstates, logType, @@ -96,7 +96,7 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa } } return new LogResult(postResult.left, postResult.right); - } catch (Exception e) { + } catch (final Exception e) { Log.e("GCLoggingManager.postLog", e); } @@ -104,11 +104,11 @@ public class GCLoggingManager extends AbstractLoggingManager implements LoaderMa } @Override - public ImageResult postLogImage(String logId, String imageCaption, String imageDescription, Uri imageUri) { + public ImageResult postLogImage(final String logId, final String imageCaption, final String imageDescription, final Uri imageUri) { if (StringUtils.isNotBlank(imageUri.getPath())) { - ImmutablePair<StatusCode, String> imageResult = GCParser.uploadLogImage(logId, imageCaption, imageDescription, imageUri); + final ImmutablePair<StatusCode, String> imageResult = GCParser.uploadLogImage(logId, imageCaption, imageDescription, imageUri); return new ImageResult(imageResult.left, imageResult.right); } diff --git a/main/src/cgeo/geocaching/connector/gc/GCLogin.java b/main/src/cgeo/geocaching/connector/gc/GCLogin.java index 492191b..e2afb77 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCLogin.java +++ b/main/src/cgeo/geocaching/connector/gc/GCLogin.java @@ -35,7 +35,7 @@ public class GCLogin extends AbstractLogin { private final static String ENGLISH = "<a href=\"#\">English ▼</a>"; - public static final String LANGUAGE_CHANGE_URI = "http://www.geocaching.com/my/souvenirs.aspx"; + private static final String LANGUAGE_CHANGE_URI = "http://www.geocaching.com/my/souvenirs.aspx"; private GCLogin() { // singleton @@ -55,7 +55,7 @@ public class GCLogin extends AbstractLogin { } @Override - protected StatusCode login(boolean retry) { + protected StatusCode login(final boolean retry) { final ImmutablePair<String, String> credentials = Settings.getGcCredentials(); final String username = credentials.left; final String password = credentials.right; @@ -165,7 +165,7 @@ public class GCLogin extends AbstractLogin { * @param page * @return <code>true</code> if user is logged in, <code>false</code> otherwise */ - public boolean getLoginStatus(@Nullable final String page) { + boolean getLoginStatus(@Nullable final String page) { if (StringUtils.isBlank(page)) { Log.e("Login.checkLogin: No page given"); return false; @@ -214,7 +214,7 @@ public class GCLogin extends AbstractLogin { * @param previousPage the content of the last loaded page * @return <code>true</code> if a switch was necessary and succesfully performed (non-English -> English) */ - private boolean switchToEnglish(String previousPage) { + private boolean switchToEnglish(final String previousPage) { if (previousPage != null && previousPage.contains(ENGLISH)) { Log.i("Geocaching.com language already set to English"); // get find count @@ -286,11 +286,11 @@ public class GCLogin extends AbstractLogin { return new SimpleDateFormat(format, Locale.ENGLISH).parse(input.trim()); } - public static Date parseGcCustomDate(final String input) throws ParseException { + static Date parseGcCustomDate(final String input) throws ParseException { return parseGcCustomDate(input, Settings.getGcCustomDate()); } - public static String formatGcCustomDate(int year, int month, int day) { + static String formatGcCustomDate(final int year, final int month, final int day) { return new SimpleDateFormat(Settings.getGcCustomDate(), Locale.ENGLISH).format(new GregorianCalendar(year, month - 1, day).getTime()); } @@ -299,7 +299,7 @@ public class GCLogin extends AbstractLogin { * - Array is null * - or all elements are null or empty strings */ - public static boolean isEmpty(String[] a) { + public static boolean isEmpty(final String[] a) { if (a == null) { return true; } @@ -317,7 +317,7 @@ public class GCLogin extends AbstractLogin { * * @return String[] with all view states */ - public static String[] getViewstates(String page) { + public static String[] getViewstates(final String page) { // Get the number of viewstates. // If there is only one viewstate, __VIEWSTATEFIELDCOUNT is not present @@ -365,7 +365,7 @@ public class GCLogin extends AbstractLogin { /** * put viewstates into request parameters */ - public static void putViewstates(final Parameters params, final String[] viewstates) { + static void putViewstates(final Parameters params, final String[] viewstates) { if (ArrayUtils.isEmpty(viewstates)) { return; } @@ -382,7 +382,7 @@ public class GCLogin extends AbstractLogin { * transfers the viewstates variables from a page (response) to parameters * (next request) */ - public static void transferViewstates(final String page, final Parameters params) { + static void transferViewstates(final String page, final Parameters params) { putViewstates(params, getViewstates(page)); } @@ -392,7 +392,7 @@ public class GCLogin extends AbstractLogin { * @param uri * @return */ - public String postRequestLogged(final String uri, final Parameters params) { + String postRequestLogged(final String uri, final Parameters params) { final String data = Network.getResponseData(Network.postRequest(uri, params)); if (getLoginStatus(data)) { @@ -415,7 +415,7 @@ public class GCLogin extends AbstractLogin { * @return */ @Nullable - public String getRequestLogged(@NonNull final String uri, @Nullable final Parameters params) { + String getRequestLogged(@NonNull final String uri, @Nullable final Parameters params) { final HttpResponse response = Network.getRequest(uri, params); final String data = Network.getResponseData(response, canRemoveWhitespace(uri)); diff --git a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java index c6a2afc..793b715 100644 --- a/main/src/cgeo/geocaching/connector/gc/IconDecoder.java +++ b/main/src/cgeo/geocaching/connector/gc/IconDecoder.java @@ -10,7 +10,7 @@ import android.graphics.Bitmap; * icon decoder for cache icons * */ -public abstract class IconDecoder { +abstract class IconDecoder { private static final int CT_TRADITIONAL = 0; private static final int CT_MULTI = 1; private static final int CT_MYSTERY = 2; @@ -25,7 +25,7 @@ public abstract class IconDecoder { private static final int CT_VIRTUAL = 11; private static final int CT_LETTERBOX = 12; - public static boolean parseMapPNG(final Geocache cache, Bitmap bitmap, UTFGridPosition xy, int zoomlevel) { + static boolean parseMapPNG(final Geocache cache, final Bitmap bitmap, final UTFGridPosition xy, final int zoomlevel) { final int topX = xy.getX() * 4; final int topY = xy.getY() * 4; final int bitmapWidth = bitmap.getWidth(); @@ -43,18 +43,18 @@ public abstract class IconDecoder { numberOfDetections = 13; } - int[] pngType = new int[numberOfDetections]; + final int[] pngType = new int[numberOfDetections]; for (int x = topX; x < topX + 4; x++) { for (int y = topY; y < topY + 4; y++) { - int color = bitmap.getPixel(x, y); + final int color = bitmap.getPixel(x, y); if ((color >>> 24) != 255) { continue; //transparent pixels (or semi_transparent) are only shadows of border } - int r = (color & 0xFF0000) >> 16; - int g = (color & 0xFF00) >> 8; - int b = color & 0xFF; + final int r = (color & 0xFF0000) >> 16; + final int g = (color & 0xFF00) >> 8; + final int b = color & 0xFF; if (isPixelDuplicated(r, g, b, zoomlevel)) { continue; @@ -143,7 +143,7 @@ public abstract class IconDecoder { * zoom level of map * @return true if parsing should not be performed */ - private static boolean isPixelDuplicated(int r, int g, int b, int zoomlevel) { + private static boolean isPixelDuplicated(final int r, final int g, final int b, final int zoomlevel) { if (zoomlevel < 12) { if (((r == g) && (g == b)) || ((r == 233) && (g == 233) && (b == 234))) { return true; @@ -194,7 +194,7 @@ public abstract class IconDecoder { * Blue component of pixel (from 0 - 255) * @return Value from 0 to 6 representing detected type or state of the cache. */ - private static int getCacheTypeFromPixel13(int r, int g, int b) { + private static int getCacheTypeFromPixel13(final int r, final int g, final int b) { if (b < 130) { if (r < 41) { return CT_MYSTERY; @@ -256,7 +256,7 @@ public abstract class IconDecoder { * Blue component of pixel (from 0 - 255) * @return Value from 0 to 6 representing detected type or state of the cache. */ - private static int getCacheTypeFromPixel14(int r, int g, int b) { + private static int getCacheTypeFromPixel14(final int r, final int g, final int b) { if (b < 128) { if (r < 214) { if (b < 37) { @@ -489,7 +489,7 @@ public abstract class IconDecoder { * Blue component of pixel (from 0 - 255) * @return Value from 0 to 4 representing detected type or state of the cache. */ - private static int getCacheTypeFromPixel11(int r, int g, int b) { + private static int getCacheTypeFromPixel11(final int r, final int g, final int b) { if (g < 136) { if (r < 90) { return g < 111 ? CT_MYSTERY : CT_TRADITIONAL; diff --git a/main/src/cgeo/geocaching/connector/gc/MapTokens.java b/main/src/cgeo/geocaching/connector/gc/MapTokens.java index 78ce4cb..b41533d 100644 --- a/main/src/cgeo/geocaching/connector/gc/MapTokens.java +++ b/main/src/cgeo/geocaching/connector/gc/MapTokens.java @@ -4,11 +4,11 @@ import android.util.Pair; /** * Wrapper type to make map tokens more type safe than with a String array. - * + * */ public final class MapTokens extends Pair<String, String> { - public MapTokens(String userSession, String sessionToken) { + MapTokens(final String userSession, final String sessionToken) { super(userSession, sessionToken); } diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index 17d129e..93b61f9 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -35,13 +35,13 @@ import java.util.Set; */ public class Tile { - public static final int TILE_SIZE = 256; - public static final int ZOOMLEVEL_MAX = 18; + static final int TILE_SIZE = 256; + static final int ZOOMLEVEL_MAX = 18; public static final int ZOOMLEVEL_MIN = 0; public static final int ZOOMLEVEL_MIN_PERSONALIZED = 12; - static final int[] NUMBER_OF_TILES = new int[ZOOMLEVEL_MAX - ZOOMLEVEL_MIN + 1]; - static final int[] NUMBER_OF_PIXELS = new int[ZOOMLEVEL_MAX - ZOOMLEVEL_MIN + 1]; + private static final int[] NUMBER_OF_TILES = new int[ZOOMLEVEL_MAX - ZOOMLEVEL_MIN + 1]; + private static final int[] NUMBER_OF_PIXELS = new int[ZOOMLEVEL_MAX - ZOOMLEVEL_MIN + 1]; static { for (int z = ZOOMLEVEL_MIN; z <= ZOOMLEVEL_MAX; z++) { NUMBER_OF_TILES[z] = 1 << z; @@ -115,7 +115,7 @@ public class Tile { * href="http://developers.cloudmade.com/projects/tiles/examples/convert-coordinates-to-tile-numbers">Cloudmade</a> */ @NonNull - public Geopoint getCoord(final UTFGridPosition pos) { + Geopoint getCoord(final UTFGridPosition pos) { final double pixX = tileX * TILE_SIZE + pos.x * 4; final double pixY = tileY * TILE_SIZE + pos.y * 4; @@ -146,7 +146,7 @@ public class Tile { * Second point * @return */ - public static int calcZoomLon(final Geopoint left, final Geopoint right, final int numberOfTiles) { + static int calcZoomLon(final Geopoint left, final Geopoint right, final int numberOfTiles) { int zoom = (int) Math.floor( Math.log(360.0 * numberOfTiles / (2.0 * Math.abs(left.getLongitude() - right.getLongitude()))) @@ -179,7 +179,7 @@ public class Tile { * Second point * @return */ - public static int calcZoomLat(final Geopoint bottom, final Geopoint top, final int numberOfTiles) { + static int calcZoomLat(final Geopoint bottom, final Geopoint top, final int numberOfTiles) { int zoom = (int) Math.ceil( Math.log(2.0 * Math.PI * numberOfTiles / ( @@ -238,7 +238,8 @@ public class Tile { * * @return An observable with one element, which may be <tt>null</tt>. */ - public static Observable<String> requestMapInfo(final String url, final Parameters params, final String referer) { + + static Observable<String> requestMapInfo(final String url, final Parameters params, final String referer) { final HttpResponse response = Network.getRequest(url, params, new Parameters("Referer", referer)); return Async.start(new Func0<String>() { @Override @@ -253,7 +254,7 @@ public class Tile { * * @return An observable with one element, which may be <tt>null</tt>. */ - public static Observable<Bitmap> requestMapTile(final Parameters params) { + static Observable<Bitmap> requestMapTile(final Parameters params) { final HttpResponse response = Network.getRequest(GCConstants.URL_MAP_TILE, params, new Parameters("Referer", GCConstants.URL_LIVE_MAP)); return Async.start(new Func0<Bitmap>() { @Override diff --git a/main/src/cgeo/geocaching/connector/gc/UTFGrid.java b/main/src/cgeo/geocaching/connector/gc/UTFGrid.java index 89a3de8..4db0519 100644 --- a/main/src/cgeo/geocaching/connector/gc/UTFGrid.java +++ b/main/src/cgeo/geocaching/connector/gc/UTFGrid.java @@ -3,22 +3,22 @@ package cgeo.geocaching.connector.gc; import java.util.List; /** - * + * * @see <a href="https://github.com/mapbox/mbtiles-spec/blob/master/1.1/utfgrid.md">Mapbox</a> - * + * */ -public final class UTFGrid { +final class UTFGrid { - public static final int GRID_MAXX = 63; - public static final int GRID_MAXY = 63; + static final int GRID_MAXX = 63; + static final int GRID_MAXY = 63; /** Calculate from a list of positions (x/y) the coords */ - public static UTFGridPosition getPositionInGrid(List<UTFGridPosition> positions) { + static UTFGridPosition getPositionInGrid(final List<UTFGridPosition> positions) { int minX = GRID_MAXX; int maxX = 0; int minY = GRID_MAXY; int maxY = 0; - for (UTFGridPosition pos : positions) { + for (final UTFGridPosition pos : positions) { minX = Math.min(minX, pos.x); maxX = Math.max(maxX, pos.x); minY = Math.min(minY, pos.y); diff --git a/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java b/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java index f9b8e1c..9de7e1e 100644 --- a/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java +++ b/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java @@ -8,13 +8,13 @@ import java.util.regex.Pattern; /** * Representation of a position inside an UTFGrid */ -public final class UTFGridPosition { +final class UTFGridPosition { - public final int x; - public final int y; + final int x; + final int y; private final static Pattern PATTERN_JSON_KEY = Pattern.compile("[^\\d]*" + "(\\d+),\\s*(\\d+)" + "[^\\d]*"); // (12, 34) - public UTFGridPosition(final int x, final int y) { + UTFGridPosition(final int x, final int y) { if (x < 0 || x > UTFGrid.GRID_MAXX) { throw new IllegalArgumentException("x outside bounds"); } @@ -38,7 +38,7 @@ public final class UTFGridPosition { * Key in the format (xx, xx) * @return */ - static UTFGridPosition fromString(String key) { + static UTFGridPosition fromString(final String key) { final MatcherWrapper matcher = new MatcherWrapper(UTFGridPosition.PATTERN_JSON_KEY, key); try { if (matcher.matches()) { @@ -46,7 +46,7 @@ public final class UTFGridPosition { final int y = Integer.parseInt(matcher.group(2)); return new UTFGridPosition(x, y); } - } catch (NumberFormatException ignored) { + } catch (final NumberFormatException ignored) { } return new UTFGridPosition(0, 0); } diff --git a/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java b/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java index 968dce5..a0c5a9f 100644 --- a/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java +++ b/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java @@ -9,7 +9,7 @@ import org.apache.commons.lang3.StringUtils; * abstract super implementation for all cache comparators * */ -public abstract class AbstractCacheComparator implements CacheComparator { +abstract class AbstractCacheComparator implements CacheComparator { @Override public final int compare(final Geocache cache1, final Geocache cache2) { diff --git a/main/src/cgeo/geocaching/sorting/DateComparator.java b/main/src/cgeo/geocaching/sorting/DateComparator.java index 7913941..6d294db 100644 --- a/main/src/cgeo/geocaching/sorting/DateComparator.java +++ b/main/src/cgeo/geocaching/sorting/DateComparator.java @@ -9,10 +9,10 @@ import java.util.Date; /** * compares caches by date */ -public class DateComparator extends AbstractCacheComparator { +class DateComparator extends AbstractCacheComparator { @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { + protected int compareCaches(final Geocache cache1, final Geocache cache2) { final Date date1 = cache1.getHiddenDate(); final Date date2 = cache2.getHiddenDate(); if (date1 != null && date2 != null) { diff --git a/main/src/cgeo/geocaching/sorting/DifficultyComparator.java b/main/src/cgeo/geocaching/sorting/DifficultyComparator.java index 459f38d..10463c8 100644 --- a/main/src/cgeo/geocaching/sorting/DifficultyComparator.java +++ b/main/src/cgeo/geocaching/sorting/DifficultyComparator.java @@ -6,10 +6,10 @@ import cgeo.geocaching.Geocache; * sorts caches by difficulty * */ -public class DifficultyComparator extends AbstractCacheComparator { +class DifficultyComparator extends AbstractCacheComparator { @Override - protected boolean canCompare(Geocache cache) { + protected boolean canCompare(final Geocache cache) { return cache.getDifficulty() != 0.0; } diff --git a/main/src/cgeo/geocaching/sorting/FindsComparator.java b/main/src/cgeo/geocaching/sorting/FindsComparator.java index 7f2ef50..a4c0686 100644 --- a/main/src/cgeo/geocaching/sorting/FindsComparator.java +++ b/main/src/cgeo/geocaching/sorting/FindsComparator.java @@ -2,17 +2,17 @@ package cgeo.geocaching.sorting; import cgeo.geocaching.Geocache; -public class FindsComparator extends AbstractCacheComparator { +class FindsComparator extends AbstractCacheComparator { @Override - protected boolean canCompare(Geocache cache) { + protected boolean canCompare(final Geocache cache) { return cache.getLogCounts() != null; } @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { - int finds1 = cache1.getFindsCount(); - int finds2 = cache2.getFindsCount(); + protected int compareCaches(final Geocache cache1, final Geocache cache2) { + final int finds1 = cache1.getFindsCount(); + final int finds2 = cache2.getFindsCount(); return finds2 - finds1; } diff --git a/main/src/cgeo/geocaching/sorting/GeocodeComparator.java b/main/src/cgeo/geocaching/sorting/GeocodeComparator.java index e700f13..30a2fc8 100644 --- a/main/src/cgeo/geocaching/sorting/GeocodeComparator.java +++ b/main/src/cgeo/geocaching/sorting/GeocodeComparator.java @@ -6,7 +6,7 @@ import cgeo.geocaching.Geocache; * sorts caches by geo code, therefore effectively sorting by cache age * */ -public class GeocodeComparator extends AbstractCacheComparator { +class GeocodeComparator extends AbstractCacheComparator { @Override protected boolean canCompare(final Geocache cache) { diff --git a/main/src/cgeo/geocaching/sorting/InventoryComparator.java b/main/src/cgeo/geocaching/sorting/InventoryComparator.java index 9d19b64..13eadcc 100644 --- a/main/src/cgeo/geocaching/sorting/InventoryComparator.java +++ b/main/src/cgeo/geocaching/sorting/InventoryComparator.java @@ -5,7 +5,7 @@ import cgeo.geocaching.Geocache; /** * sorts caches by number of items in inventory */ -public class InventoryComparator extends AbstractCacheComparator { +class InventoryComparator extends AbstractCacheComparator { @Override protected int compareCaches(final Geocache cache1, final Geocache cache2) { diff --git a/main/src/cgeo/geocaching/sorting/NameComparator.java b/main/src/cgeo/geocaching/sorting/NameComparator.java index 2941b1c..376c8b9 100644 --- a/main/src/cgeo/geocaching/sorting/NameComparator.java +++ b/main/src/cgeo/geocaching/sorting/NameComparator.java @@ -8,15 +8,15 @@ import org.apache.commons.lang3.StringUtils; * sorts caches by name * */ -public class NameComparator extends AbstractCacheComparator { +class NameComparator extends AbstractCacheComparator { @Override - protected boolean canCompare(Geocache cache) { + protected boolean canCompare(final Geocache cache) { return StringUtils.isNotBlank(cache.getName()); } @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { + protected int compareCaches(final Geocache cache1, final Geocache cache2) { return cache1.getNameForSorting().compareToIgnoreCase(cache2.getNameForSorting()); } } diff --git a/main/src/cgeo/geocaching/sorting/PopularityComparator.java b/main/src/cgeo/geocaching/sorting/PopularityComparator.java index 2dbee68..58b3b4c 100644 --- a/main/src/cgeo/geocaching/sorting/PopularityComparator.java +++ b/main/src/cgeo/geocaching/sorting/PopularityComparator.java @@ -6,7 +6,7 @@ import cgeo.geocaching.Geocache; * sorts caches by popularity (favorite count) * */ -public class PopularityComparator extends AbstractCacheComparator { +class PopularityComparator extends AbstractCacheComparator { @Override protected int compareCaches(final Geocache cache1, final Geocache cache2) { diff --git a/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java b/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java index a2da6ee..4c2d914 100644 --- a/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java +++ b/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java @@ -8,12 +8,12 @@ import cgeo.geocaching.Geocache; /** * sorts caches by popularity ratio (favorites per find in %). */ -public class PopularityRatioComparator extends AbstractCacheComparator { +class PopularityRatioComparator extends AbstractCacheComparator { @Override protected int compareCaches(final Geocache cache1, final Geocache cache2) { - int finds1 = cache1.getFindsCount(); - int finds2 = cache2.getFindsCount(); + final int finds1 = cache1.getFindsCount(); + final int finds2 = cache2.getFindsCount(); float ratio1 = 0.0f; if (finds1 != 0) { diff --git a/main/src/cgeo/geocaching/sorting/RatingComparator.java b/main/src/cgeo/geocaching/sorting/RatingComparator.java index 6f2c615..62854fe 100644 --- a/main/src/cgeo/geocaching/sorting/RatingComparator.java +++ b/main/src/cgeo/geocaching/sorting/RatingComparator.java @@ -6,7 +6,7 @@ import cgeo.geocaching.Geocache; * sorts caches by gcvote.com rating * */ -public class RatingComparator extends AbstractCacheComparator { +class RatingComparator extends AbstractCacheComparator { @Override protected int compareCaches(final Geocache cache1, final Geocache cache2) { diff --git a/main/src/cgeo/geocaching/sorting/SizeComparator.java b/main/src/cgeo/geocaching/sorting/SizeComparator.java index c8de586..9e911f5 100644 --- a/main/src/cgeo/geocaching/sorting/SizeComparator.java +++ b/main/src/cgeo/geocaching/sorting/SizeComparator.java @@ -6,15 +6,15 @@ import cgeo.geocaching.Geocache; * sorts caches by size * */ -public class SizeComparator extends AbstractCacheComparator { +class SizeComparator extends AbstractCacheComparator { @Override - protected boolean canCompare(Geocache cache) { + protected boolean canCompare(final Geocache cache) { return cache.getSize() != null; } @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { + protected int compareCaches(final Geocache cache1, final Geocache cache2) { return cache2.getSize().comparable - cache1.getSize().comparable; } }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/sorting/StateComparator.java b/main/src/cgeo/geocaching/sorting/StateComparator.java index 9488bd9..e4403f8 100644 --- a/main/src/cgeo/geocaching/sorting/StateComparator.java +++ b/main/src/cgeo/geocaching/sorting/StateComparator.java @@ -6,7 +6,7 @@ import cgeo.geocaching.Geocache; * sort caches by state (normal, disabled, archived) * */ -public class StateComparator extends AbstractCacheComparator { +class StateComparator extends AbstractCacheComparator { @Override protected int compareCaches(final Geocache cache1, final Geocache cache2) { diff --git a/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java b/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java index b718d3b..fbe3226 100644 --- a/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java +++ b/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java @@ -2,10 +2,10 @@ package cgeo.geocaching.sorting; import cgeo.geocaching.Geocache; -public class StorageTimeComparator extends AbstractCacheComparator { +class StorageTimeComparator extends AbstractCacheComparator { @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { + protected int compareCaches(final Geocache cache1, final Geocache cache2) { if (cache1.getUpdated() < cache2.getUpdated()) { return -1; } diff --git a/main/src/cgeo/geocaching/sorting/TerrainComparator.java b/main/src/cgeo/geocaching/sorting/TerrainComparator.java index 9bbb5f7..e882025 100644 --- a/main/src/cgeo/geocaching/sorting/TerrainComparator.java +++ b/main/src/cgeo/geocaching/sorting/TerrainComparator.java @@ -6,7 +6,7 @@ import cgeo.geocaching.Geocache; * sorts caches by terrain rating * */ -public class TerrainComparator extends AbstractCacheComparator { +class TerrainComparator extends AbstractCacheComparator { @Override protected boolean canCompare(final Geocache cache) { diff --git a/main/src/cgeo/geocaching/sorting/VoteComparator.java b/main/src/cgeo/geocaching/sorting/VoteComparator.java index cd4ad7e..5cf39d7 100644 --- a/main/src/cgeo/geocaching/sorting/VoteComparator.java +++ b/main/src/cgeo/geocaching/sorting/VoteComparator.java @@ -5,10 +5,10 @@ import cgeo.geocaching.Geocache; /** * sorts caches by the users own voting (if available at all) */ -public class VoteComparator extends AbstractCacheComparator { +class VoteComparator extends AbstractCacheComparator { @Override - protected int compareCaches(Geocache cache1, Geocache cache2) { + protected int compareCaches(final Geocache cache1, final Geocache cache2) { // if there is no vote available, put that cache at the end of the list return Float.compare(cache2.getMyVote(), cache1.getMyVote()); } |
