示例#1
0
 public void persistLocations() {
   JSONArray jsonLocations = new JSONArray();
   for (Location location : locations) {
     jsonLocations.add(location.jsonify());
   }
   json.put("locations", jsonLocations);
 }
示例#2
0
 public Location getLocation(int id) {
   for (Location location : locations) {
     if (location.getId() == id) {
       return location;
     }
   }
   return null;
 }
示例#3
0
 private void restoreLocations() {
   JSONArray jsonLocations = (JSONArray) json.get("locations");
   int size = jsonLocations.size();
   for (int i = 0; i < size; ++i) {
     JSONObject jsonLocation = (JSONObject) jsonLocations.get(i);
     Location location = Location.createFromJSON(jsonLocation);
     locations.add(location);
   }
 }