diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-20 11:38:00 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-20 12:59:07 +0200 |
| commit | 28d3cf2659c787f6f5d4fa8dec6e6d378c577aee (patch) | |
| tree | 221a0000b4557e79063183ebb97b7eff5b8c64bb /main/src/cgeo | |
| parent | f49842de614383ecbebe91085a7d00691d5fa2e1 (diff) | |
| download | cgeo-28d3cf2659c787f6f5d4fa8dec6e6d378c577aee.zip cgeo-28d3cf2659c787f6f5d4fa8dec6e6d378c577aee.tar.gz cgeo-28d3cf2659c787f6f5d4fa8dec6e6d378c577aee.tar.bz2 | |
Add optional table parameter to Viewport#sqlWhere()
Diffstat (limited to 'main/src/cgeo')
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/Viewport.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java index 32f542b..4c810d6 100644 --- a/main/src/cgeo/geocaching/geopoint/Viewport.java +++ b/main/src/cgeo/geocaching/geopoint/Viewport.java @@ -2,6 +2,7 @@ package cgeo.geocaching.geopoint; import cgeo.geocaching.ICoordinates; +import java.util.Locale; import java.util.Set; @@ -146,13 +147,15 @@ public class Viewport { /** * Return the "where" part of the string appropriate for a SQL query. * + * @param dbTable + * the database table to use as prefix, or null if no prefix is required * @return the string without the "where" keyword */ - public String sqlWhere() { - return "latitude >= " + getLatitudeMin() + " and " + - "latitude <= " + getLatitudeMax() + " and " + - "longitude >= " + getLongitudeMin() + " and " + - "longitude <= " + getLongitudeMax(); + public String sqlWhere(final String dbTable) { + final String prefix = dbTable == null ? "" : (dbTable + "."); + return String.format((Locale) null, + "%slatitude >= %s and %slatitude <= %s and %slongitude >= %s and %slongitude <= %s", + prefix, getLatitudeMin(), prefix, getLatitudeMax(), prefix, getLongitudeMin(), prefix, getLongitudeMax()); } /** @@ -168,7 +171,7 @@ public class Viewport { /** * Return a viewport that contains the current viewport as well as another point. - * + * * @param coords * the point we want in the viewport * @return either the same or an expanded viewport |
