/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:56:52*/ /*This class drives: StateOrProvince*/ package PoliticalEntities.core; import java.util.*; import PoliticalEntities.*; import PoliticalEntities.json.*; public class Country extends Territory { //Class datatypes //Class association variables private List stateOrProvinces; //Registry of our system. PoliticalEntitiesRegistry registry = PoliticalEntitiesRegistry.getInstance(); //Constructor public Country(String aName) { super(aName); stateOrProvinces = new ArrayList(); registry.add(stateOrProvinces); } public List getStateOrProvinces() { return stateOrProvinces; } public StateOrProvince addStateOrProvince(String aName) { StateOrProvince newStateOrProvince; newStateOrProvince = new StateOrProvince(aName, this); if (!stateOrProvinces.contains(newStateOrProvince)) { registry.add(newStateOrProvince); stateOrProvinces.add(newStateOrProvince); } return newStateOrProvince; } public StateOrProvince addStateOrProvince(StateOrProvince aStateOrProvince) { if (!stateOrProvinces.contains(aStateOrProvince)) stateOrProvinces.add(aStateOrProvince); return aStateOrProvince; } public void delete() { //Delete all many ends first. for (StateOrProvince aStateOrProvince : stateOrProvinces) { aStateOrProvince.delete(); } stateOrProvinces.clear(); } public void deleteStateOrProvince(StateOrProvince aStateOrProvince) { if (stateOrProvinces.contains(aStateOrProvince)) { stateOrProvinces.remove(aStateOrProvince); //registry.removeObj(registry.getKey(aStateOrProvince)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (stateOrProvinces.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); return obj; } }