Fields Summary |
---|
private static final String | CREATE_LANDMARKSTORE_SUPPORTEDLandmarkStore Create property |
private static final String | DELETE_LANDMARKSTORE_SUPPORTEDLandmarkStore Delete property |
private static final String | DELETE_CATEGORY_SUPPORTEDCategory Delete property |
private static final LandmarkStore | defaultStoreThe default instance of a store |
private static Hashtable | storesA map of names of stores to actual stores |
private static boolean | storesInitializedIndicates whether landmark stores were loaded |
private String | storeNameThe name of the record store |
Methods Summary |
---|
public void | addCategory(java.lang.String categoryName)
Util.checkForPermission(Permissions.LANDMARK_CATEGORY);
if (categoryName == null) {
throw new NullPointerException("Category name is null");
}
// save categories into persistent storage
LocationPersistentStorage.getInstance().
addCategory(categoryName, storeName);
|
public void | addLandmark(Landmark landmark, java.lang.String category)
Util.checkForPermission(Permissions.LANDMARK_WRITE);
if (landmark == null) { // NullPointerException should be caused
throw new NullPointerException("Landmark is null");
}
LocationPersistentStorage.getInstance().addLandmark(storeName,
landmark.getInstance(), category);
|
public static void | createLandmarkStore(java.lang.String storeName)
if (Configuration.getProperty(CREATE_LANDMARKSTORE_SUPPORTED).
equals("true")) {
Util.checkForPermission(Permissions.LANDMARK_MANAGE);
if (storeName == null) {
throw new NullPointerException("storeName can not be null");
}
// verify that the name is correct and store does not exist
int storeLen = storeName.length();
if (storeLen == 0) {
throw new IllegalArgumentException("The store: name has " +
"incorrect length");
}
if (getInstance(storeName) != null) {
throw new IllegalArgumentException("The store: " + storeName +
" already exists");
}
LocationPersistentStorage.getInstance().addStoreName(storeName);
} else {
throw new LandmarkException(
"Implementation does not support " +
"creating new landmark stores");
}
|
public void | deleteCategory(java.lang.String categoryName)
if (Configuration.getProperty(DELETE_CATEGORY_SUPPORTED).
equals("true")) {
Util.checkForPermission(Permissions.LANDMARK_CATEGORY);
if (categoryName == null) {
throw new NullPointerException();
}
LocationPersistentStorage.getInstance().
deleteCategory(categoryName, storeName);
} else {
throw new LandmarkException(
"Implementation does not support " +
"deleting categories");
}
|
public void | deleteLandmark(Landmark lm)
Util.checkForPermission(Permissions.LANDMARK_WRITE);
if (lm == null) {
throw new NullPointerException();
}
LocationPersistentStorage.getInstance().deleteLandmark(
storeName, lm.getInstance());
|
public static void | deleteLandmarkStore(java.lang.String storeName)
if (Configuration.getProperty(DELETE_LANDMARKSTORE_SUPPORTED).
equals("true")) {
Util.checkForPermission(Permissions.LANDMARK_MANAGE);
if (storeName == null) {
throw new NullPointerException();
}
LocationPersistentStorage.getInstance().removeStoreName(storeName);
} else {
throw new LandmarkException(
"Implementation does not support " +
"deleting landmark stores");
}
|
public java.util.Enumeration | getCategories()
try {
return getCategoriesVector().elements();
} catch (IOException e) {
return new Vector().elements();
}
|
private java.util.Vector | getCategoriesVector()
return LocationPersistentStorage.getInstance().
getCategories(storeName);
|
public static synchronized javax.microedition.location.LandmarkStore | getInstance(java.lang.String storeName)
Util.checkForPermission(Permissions.LANDMARK_READ);
LandmarkStore current = null;
try {
if (storeName == null) {
return defaultStore;
} else {
String[] storeNames = LocationPersistentStorage.
getInstance().listStoreNames();
if (storeNames != null) {
for (int i = 0; i < storeNames.length; i++) {
if (storeNames[i].equals(storeName)) {
current = new LandmarkStore(storeName);
break;
}
}
}
}
} catch (IOException e) { // return null
}
return current;
|
public java.util.Enumeration | getLandmarks(java.lang.String category, double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
if ((minLongitude == 180) || (maxLongitude == 180)) {
throw new IllegalArgumentException("Longtitude out of range " +
"must not equal 180");
}
if (minLatitude > maxLatitude) {
throw new IllegalArgumentException("Minimum latitude cannot be " +
"larger than the maximum latitude");
}
Util.checkRange(minLatitude, -90, 90,
"Latitude out of range [-90.0, 90]: ");
Util.checkRange(maxLatitude, -90, 90,
"Latitude out of range [-90.0, 90]: ");
Util.checkRange(maxLongitude, -180, 180,
"Longitude out of range [-180.0, 180]: ");
Util.checkRange(minLongitude, -180, 180,
"Longitude out of range [-180.0, 180]: ");
Enumeration en = LocationPersistentStorage.getInstance().
getLandmarksEnumeration(storeName, category, null,
minLatitude, maxLatitude,
minLongitude, maxLongitude);
if (en == null) {
return null;
}
Vector vecLandmarks = new Vector();
while (en.hasMoreElements()) {
vecLandmarks.addElement(
new Landmark((LandmarkImpl)en.nextElement()));
}
return vecLandmarks.elements();
|
public java.util.Enumeration | getLandmarks(java.lang.String category, java.lang.String name)
Enumeration en = LocationPersistentStorage.getInstance().
getLandmarksEnumeration(storeName, category, name,
-90, 90, -180, 180);
if (en == null) {
return null;
}
Vector vecLandmarks = new Vector();
while (en.hasMoreElements()) {
vecLandmarks.addElement(
new Landmark((LandmarkImpl)en.nextElement()));
}
return vecLandmarks.elements();
|
public java.util.Enumeration | getLandmarks()
return getLandmarks(null, null);
|
public static java.lang.String[] | listLandmarkStores()
Util.checkForPermission(Permissions.LANDMARK_READ);
return LocationPersistentStorage.getInstance().listStoreNames();
|
public void | removeLandmarkFromCategory(Landmark lm, java.lang.String category)
Util.checkForPermission(Permissions.LANDMARK_WRITE);
if (lm == null || category == null) {
throw new NullPointerException();
}
LocationPersistentStorage.getInstance().removeLandmarkFromCategory(
storeName, lm.getInstance(), category);
|
public void | updateLandmark(Landmark lm)
Util.checkForPermission(Permissions.LANDMARK_WRITE);
if (lm == null) {
throw new NullPointerException();
}
LocationPersistentStorage.getInstance().updateLandmark(
storeName, lm.getInstance());
|