/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 12:12:16*/ /*This class drives: PollInElection*/ package ElectorialSystem.core; import java.util.*; import ElectorialSystem.*; import ElectorialSystem.json.*; public class PollingStation { //Class datatypes private int number; private String address; //Class association variables private List pollInElections; //Registry of our system. ElectorialSystemRegistry registry = ElectorialSystemRegistry.getInstance(); //Constructor public PollingStation(int aNumber, String aAddress) { number = aNumber; address = aAddress; pollInElections = new ArrayList(); registry.add(pollInElections); } public boolean setNumber(int aNumber) { number = aNumber; return true; } public boolean setAddress(String aAddress) { address = aAddress; return true; } public int getNumber() { return number; } public String getAddress() { return address; } public List getPollInElections() { return pollInElections; } public PollInElection addPollInElection(int aNumber, Election aElection) { PollInElection newPollInElection; newPollInElection = new PollInElection(aNumber, aElection); if (!pollInElections.contains(newPollInElection)) { registry.add(newPollInElection); pollInElections.add(newPollInElection); } return newPollInElection; } public PollInElection addPollInElection(PollInElection aPollInElection) { if (!pollInElections.contains(aPollInElection)) pollInElections.add(aPollInElection); return aPollInElection; } public void delete() { //Delete all many ends first. for (PollInElection aPollInElection : pollInElections) { aPollInElection.delete(); } pollInElections.clear(); } public void deletePollInElection(PollInElection aPollInElection) { if (pollInElections.contains(aPollInElection)) { pollInElections.remove(aPollInElection); //registry.removeObj(registry.getKey(aPollInElection)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (pollInElections.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)); obj.put("number", getNumber()); obj.put("address", getAddress()); return obj; } }