package cgeo.geocaching.connector.gc; import java.util.Locale; import java.util.regex.Pattern; /** * These patterns have been optimized for speed. Improve them only if you can prove * that *YOUR* pattern is faster. Use RegExRealPerformanceTest to show. * * For further information about patterns have a look at * http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html */ public final class GCConstants { static final String GC_URL = "http://www.geocaching.com/"; /** Live Map */ public final static String URL_LIVE_MAP = GC_URL + "map/default.aspx"; /** Live Map pop-up */ public final static String URL_LIVE_MAP_DETAILS = GC_URL + "map/map.details"; /** Caches in a tile */ public final static String URL_MAP_INFO = GC_URL + "map/map.info"; /** Tile itself */ public final static String URL_MAP_TILE = GC_URL + "map/map.png"; /** * Patterns for parsing the result of a (detailed) search */ public final static Pattern PATTERN_HINT = Pattern.compile("
\\s*
\\s*"); public final static Pattern PATTERN_SHORTDESC = Pattern.compile("(.*?)\\s*"); public final static Pattern PATTERN_GEOCODE = Pattern.compile("class=\"CoordInfoCode\">(GC[0-9A-Z]+)"); 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("
]*>[^S]*Size[^:]*:[^<]*]*>[^<]*]*>[^<]*[^<]*[^<]*[^<]*
"); public final static Pattern PATTERN_LATLON = Pattern.compile("]*>(.*?)"); public final static Pattern PATTERN_LATLON_ORIG = Pattern.compile("\\{\"isUserDefined\":true[^}]+?\"oldLatLngDisplay\":\"([^\"]+)\"\\}"); public final static Pattern PATTERN_LOCATION = Pattern.compile(Pattern.quote("In ") + "(?:]*>)?(.*?)<"); public final static Pattern PATTERN_PERSONALNOTE = Pattern.compile("]*>(.*?)
"); public final static Pattern PATTERN_NAME = Pattern.compile("(.*?)"); public final static Pattern PATTERN_DIFFICULTY = Pattern.compile("]*>[^<]*]*>[^<]*]*>[^<]*[^<]*"); public final static Pattern PATTERN_FOUND_ALTERNATIVE = Pattern.compile("This is a Premium Member Only cache.
"); public final static Pattern PATTERN_ATTRIBUTES = Pattern.compile("]+>]+>([^<]+)(?:
([^<]+)
)?");
public final static Pattern PATTERN_INVENTORY = Pattern.compile("\\W*Inventory[^<]*[^<]*[^<]*
You are logged in as[^<]*]*>([^<]+)[^<]*"); public static final Pattern PATTERN_CUSTOMDATE = Pattern.compile("