com.google.gwt.maps.client.geocode
Class CustomGeocodeCache

java.lang.Object
  extended by com.google.gwt.maps.client.geocode.GeocodeCache
      extended by com.google.gwt.maps.client.geocode.CustomGeocodeCache

public class CustomGeocodeCache
extends GeocodeCache

Provides a way to customize the caching behavior of geocoded queries. This class is both functional and a base class so the user can extend it.


Field Summary
 
Fields inherited from class com.google.gwt.maps.client.geocode.GeocodeCache
jsoPeer
 
Constructor Summary
CustomGeocodeCache()
           
 
Method Summary
 com.google.gwt.core.client.JavaScriptObject get(java.lang.String address)
          Returns the reply which was stored under the given address.
 boolean isCacheable(com.google.gwt.core.client.JavaScriptObject reply)
          Returns whether or not the given reply should be cached.
 void put(java.lang.String address, com.google.gwt.core.client.JavaScriptObject reply)
          Stores the given reply under the given address.
 void reset()
          Purges all replies from the cache.
 java.lang.String toCanonical(java.lang.String address)
          Returns what is considered a canonical version of the address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomGeocodeCache

public CustomGeocodeCache()
Method Detail

get

public com.google.gwt.core.client.JavaScriptObject get(java.lang.String address)
Description copied from class: GeocodeCache
Returns the reply which was stored under the given address. If no reply was ever stored for the given address, this method returns null

Specified by:
get in class GeocodeCache
Parameters:
address - the address used as a key to lookup.
Returns:
the previously cached result.

isCacheable

public boolean isCacheable(com.google.gwt.core.client.JavaScriptObject reply)
Description copied from class: GeocodeCache
Returns whether or not the given reply should be cached. By default very rudimentary checks are performed on the reply object. In particular, this class makes sure that the object is not null and that it has the name field . This method may be overridden by extending classes to provide more precise conditions on the reply object.

Specified by:
isCacheable in class GeocodeCache
Parameters:
reply - the reply to test.
Returns:
true if the value can be cached.

put

public void put(java.lang.String address,
                com.google.gwt.core.client.JavaScriptObject reply)
Description copied from class: GeocodeCache
Stores the given reply under the given address. This method calls the GeocodeCache.isCacheable(com.google.gwt.core.client.JavaScriptObject) method to verify that the reply may be cached. If it gets a go-ahead, it caches the reply under the address normalized with the help of the GeocodeCache.toCanonical(java.lang.String) method.

Specified by:
put in class GeocodeCache
Parameters:
address - the address used in the query.
reply - the reply value to cache.

reset

public void reset()
Description copied from class: GeocodeCache
Purges all replies from the cache. After this method returns, the cache is empty.

Specified by:
reset in class GeocodeCache

toCanonical

public java.lang.String toCanonical(java.lang.String address)
Description copied from class: GeocodeCache
Returns what is considered a canonical version of the address. It converts the address parameter to lower case, replaces commas with spaces and replaces multiple spaces with one space.

Specified by:
toCanonical in class GeocodeCache
Parameters:
address - the address to convert to canonical form.
Returns:
the address in canonical form.