com.veriplace.client
Class DefaultLocationFilter

java.lang.Object
  extended by com.veriplace.client.DefaultLocationFilter
All Implemented Interfaces:
LocationFilter

public class DefaultLocationFilter
extends java.lang.Object
implements LocationFilter

Default implementation of LocationFilter. Can be configured to pass location results and errors unchanged, or to suppress errors as long as an earlier cached location is available.

Since:
2.1

Constructor Summary
DefaultLocationFilter()
          Constructs a DefaultLocationFilter that does no post-processing.
DefaultLocationFilter(boolean useCachedLocation)
          Constructs a DefaultLocationFilter that can optionally suppress certain errors if the application would like to use cached locations.
 
Method Summary
 Location filterLocation(Location returnedLocation, PositionFailureException returnedException)
          Transforms the result of a location request.
 boolean isUseCachedLocation()
          Returns true if this filter will returned cached locations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLocationFilter

public DefaultLocationFilter()
Constructs a DefaultLocationFilter that does no post-processing.


DefaultLocationFilter

public DefaultLocationFilter(boolean useCachedLocation)
Constructs a DefaultLocationFilter that can optionally suppress certain errors if the application would like to use cached locations. This applies only under the following conditions:

If all of those conditions are true, then your request will return the last known location instead of throwing an exception.

Parameters:
useCachedLocation - true if the filter should return cached locations in certain cases; false to retain the default unfiltered behavior
Method Detail

filterLocation

public Location filterLocation(Location returnedLocation,
                               PositionFailureException returnedException)
                        throws GetLocationException
Description copied from interface: LocationFilter
Transforms the result of a location request. If this method returns null, the filter has no effect. If it returns a location object, that becomes the return value of the location request, even if the request would normally have failed. It can also throw a different exception, regardless of whether the request would normally have failed or succeeded.

Specified by:
filterLocation in interface LocationFilter
Parameters:
returnedLocation - the valid location returned by the server, or null if an error occurred
returnedException - the exception that would normally be thrown if an error occurred
Returns:
a new location to return; null to keep the original location, or to throw the original exception if there was an exception
Throws:
GetLocationException - if the location request should fail

isUseCachedLocation

public boolean isUseCachedLocation()
Returns true if this filter will returned cached locations.