com.sony.csl.j2me.locationapitools
Class LocationProxy
java.lang.Object
com.sony.csl.j2me.locationapitools.LocationProxy
- All Implemented Interfaces:
- LocationListener
public class LocationProxy
- extends java.lang.Object
- implements LocationListener
LocationProxy acts as a proxy (middleman) between a JSR-179 (Location API) LocationProvider object
and (multiple!) objects (instances of classes that implement the LocationProxyListener interface) that
need access to location information.
This is necessary because LocationProvider only supports a single listener object.
- Author:
- mstevens (Sony CSL Paris / Vrije Universiteit Brussel)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOCATIONLISTENER_INTERVAL
public static int LOCATIONLISTENER_INTERVAL
LOCATIONLISTENER_TIMEOUT
public static int LOCATIONLISTENER_TIMEOUT
LOCATIONLISTENER_MAXAGE
public static int LOCATIONLISTENER_MAXAGE
DEFAULT_LOCATIONPROVIDER_CRITERIA
public static Criteria DEFAULT_LOCATIONPROVIDER_CRITERIA
INSTANCE
private static LocationProxy INSTANCE
providerCriteria
private Criteria providerCriteria
listeningInterval
private int listeningInterval
listeningTimeout
private int listeningTimeout
listeningMaxAge
private int listeningMaxAge
provider
private LocationProvider provider
listeners
private java.util.Vector listeners
firstLocationUpdatePassed
private boolean firstLocationUpdatePassed
firstValidLocationUpdatePassed
private boolean firstValidLocationUpdatePassed
lastValidLocation
private Location lastValidLocation
numberOfLocations
private int numberOfLocations
numberOfValidLocations
private int numberOfValidLocations
waitingForLocation
private boolean waitingForLocation
LocationProxy
private LocationProxy()
getInstance
public static LocationProxy getInstance()
throws java.lang.Exception
- Provide singleton instance of this class.
- Returns:
- static instance of this class.
- Throws:
java.lang.Exception
addListener
public void addListener(LocationProxyListener listener)
removeListener
public void removeListener(LocationProxyListener listener)
removeAllListeners
public void removeAllListeners()
getProviderCriteria
public Criteria getProviderCriteria()
- Returns:
- providerCriteria
getListeningInterval
public int getListeningInterval()
- Returns:
- listeningInterval
getListeningTimeout
public int getListeningTimeout()
- Returns:
- listeningTimeout
getListeningMaxAge
public int getListeningMaxAge()
- Returns:
- listeningMaxAge
isConnected
public boolean isConnected()
- Returns:
- connected
getProvider
public LocationProvider getProvider()
- Returns:
- provider
getProviderState
public int getProviderState()
- Returns:
- state of the provider
getNumberOfLocations
public int getNumberOfLocations()
- Returns:
- the numberOfLocations
getNumberOfValidLocations
public int getNumberOfValidLocations()
- Returns:
- the numberOfValidLocations
connect
public boolean connect()
throws java.lang.Exception
- Throws:
java.lang.Exception
connect
public boolean connect(Criteria criteria)
throws java.lang.Exception
- Throws:
java.lang.Exception
connect
public boolean connect(java.util.Vector criteriaVector)
throws java.lang.Exception
- Throws:
java.lang.Exception
connect
public boolean connect(java.util.Vector criteriaVector,
int interval,
int timeout,
int maxAge)
throws java.lang.Exception
- Attempt to connect the proxy instance to a provider that is to be selected according to one of the criteria in the vector.
The criteria are tried in the order in which they appear in the vector. The interval, timeout and maxAge
parameters are used to connect to the first provider that is found.
- Parameters:
criteriaVector
- interval
- timeout
- maxAge
-
- Returns:
- boolean value indicating the success (true) or failure (false) of the connection attempt
- Throws:
java.lang.Exception
connect
public boolean connect(Criteria criteria,
int interval,
int timeout,
int maxAge)
throws java.lang.Exception
- Attempt to connect the proxy instance to a provider that is to be selected according to the supplied criteria.
If a suitable provider is found the interval, timeout and maxAge parameters are used to connect to it.
- Parameters:
criteria
- interval
- timeout
- maxAge
-
- Returns:
- boolean value indicating the success (true) or failure (false) of the connection attempt
- Throws:
java.lang.Exception
disconnect
public void disconnect()
locationUpdated
public void locationUpdated(LocationProvider provider,
Location location)
- Specified by:
locationUpdated
in interface LocationListener
- See Also:
LocationListener.locationUpdated(javax.microedition.location.LocationProvider, javax.microedition.location.Location)
providerStateChanged
public void providerStateChanged(LocationProvider provider,
int newState)
- Specified by:
providerStateChanged
in interface LocationListener
- See Also:
LocationListener.providerStateChanged(javax.microedition.location.LocationProvider, int)
getCurrentLocation
public Location getCurrentLocation(int timeoutSeconds)
getCurrentLocation
public Location getCurrentLocation(int timeoutSeconds,
boolean pausableThread)