/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:56:52*/ /*This class drives: Territory*/ package PoliticalEntities.core; import java.util.*; import PoliticalEntities.*; import PoliticalEntities.json.*; public class Territory extends PoliticalEntity { //Class datatypes //Class association variables private List borderss; private List territorys; private List interGovernmentalOrganizations; //Registry of our system. PoliticalEntitiesRegistry registry = PoliticalEntitiesRegistry.getInstance(); //Constructor public Territory(String aName) { super(aName); borderss = new ArrayList(); registry.add(borderss); territorys = new ArrayList(); registry.add(territorys); interGovernmentalOrganizations = new ArrayList(); registry.add(interGovernmentalOrganizations); } public List getBorderss() { return borderss; } public List getTerritorys() { return territorys; } public List getInterGovernmentalOrganizations() { return interGovernmentalOrganizations; } public Territory addBorders(String aName) { Territory newTerritory; newTerritory = new Territory(aName); if (!borderss.contains(newTerritory)) { registry.add(newTerritory); borderss.add(newTerritory); } return newTerritory; } public Territory addBorders(Territory aBorders) { if (!borderss.contains(aBorders)) borderss.add(aBorders); return aBorders; } public Territory addTerritory(String aName) { Territory newTerritory; newTerritory = new Territory(aName); if (!territorys.contains(newTerritory)) { registry.add(newTerritory); territorys.add(newTerritory); } return newTerritory; } public Territory addTerritory(Territory aTerritory) { if (!territorys.contains(aTerritory)) territorys.add(aTerritory); return aTerritory; } public InterGovernmentalOrganization addInterGovernmentalOrganization( String aName) { InterGovernmentalOrganization newInterGovernmentalOrganization; newInterGovernmentalOrganization = new InterGovernmentalOrganization(aName); if (!interGovernmentalOrganizations .contains(newInterGovernmentalOrganization)) { registry.add(newInterGovernmentalOrganization); interGovernmentalOrganizations.add(newInterGovernmentalOrganization); } return newInterGovernmentalOrganization; } public InterGovernmentalOrganization addInterGovernmentalOrganization( InterGovernmentalOrganization aInterGovernmentalOrganization) { if (!interGovernmentalOrganizations .contains(aInterGovernmentalOrganization)) interGovernmentalOrganizations.add(aInterGovernmentalOrganization); return aInterGovernmentalOrganization; } public void delete() { //Delete all many ends first. for (Territory aTerritory : borderss) { aTerritory.delete(); } borderss.clear(); //Delete all many ends first. for (Territory aTerritory : territorys) { aTerritory.delete(); } territorys.clear(); } public void deleteBorders(Territory aTerritory) { if (borderss.contains(aTerritory)) { borderss.remove(aTerritory); //registry.removeObj(registry.getKey(aTerritory)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteTerritory(Territory aTerritory) { if (territorys.contains(aTerritory)) { territorys.remove(aTerritory); //registry.removeObj(registry.getKey(aTerritory)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteInterGovernmentalOrganization( InterGovernmentalOrganization aInterGovernmentalOrganization) { if (interGovernmentalOrganizations.contains(aInterGovernmentalOrganization)) { interGovernmentalOrganizations.remove(aInterGovernmentalOrganization); //registry.removeObj(registry.getKey(aInterGovernmentalOrganization)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (borderss.size() == 0 && territorys.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; } }