All landmark store access methods are available through the LandmarkStore
class.
The first step in the landmark store use is to create an instance of LandmarkStore
with
the getInstance(String storeName)
method. A landmark
store instance will be returned if a named store can be found. If no landmark
store with a specified name exists, the getInstance
method
returns null
. The default landmark store can be obtained
with a null
parameter. Getting a landmark store instance
is demonstrated in Code sample 7.
Code sample 7: Getting a landmark store instance (TouristRoute's ControlPoints.java class)
try store = LandmarkStore.getInstance(STORENAME); catch(NullPointerException npe)
if (store == null) // code ...
A new landmark store can be created with the createlandmarkStore(String
StoreName)
method. Code sample 8 demonstrates the landmark store
creation. Successfully created landmark stores are accessible through the getInstance()
method.
If landmark store creation failed due to an exception, a default landmark
store can be accessed by using a null
parameter in the getInstance()
method.
Code sample 8: Creating a new landmark store (TouristRoute's ControlPoints.java class)
try LandmarkStore.createLandmarkStore(STORENAME); catch(IllegalArgumentException iae) // Name is too long or landmark store with the specified name // already exists. catch (IOException e) // Landmark store couldn't be created due to an I/O error catch (LandmarkException e) // Implementation does not support creating new landmark stores.