/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 13:12:55*/ /*This class drives: Level*/ package Warehouse.core; import java.util.*; import Warehouse.*; import Warehouse.json.*; public class Row { //Class datatypes private int depth; private int number; //Class association variables private List levels; //Registry of our system. WarehouseRegistry registry = WarehouseRegistry.getInstance(); //Constructor public Row(int aDepth, int aNumber) { depth = aDepth; number = aNumber; levels = new ArrayList(); registry.add(levels); } public boolean setDepth(int aDepth) { depth = aDepth; return true; } public boolean setNumber(int aNumber) { number = aNumber; return true; } public int getDepth() { return depth; } public int getNumber() { return number; } public List getLevels() { return levels; } public Level addLevel(int aHeight, int aNumber, Row aRow) { Level newLevel; newLevel = new Level(aHeight, aNumber, this); if (!levels.contains(newLevel)) { registry.add(newLevel); levels.add(newLevel); } return newLevel; } public Level addLevel(Level aLevel) { if (!levels.contains(aLevel)) levels.add(aLevel); return aLevel; } public void delete() { //Delete all many ends first. for (Level aLevel : levels) { aLevel.delete(); } levels.clear(); } public void deleteLevel(Level aLevel) { if (levels.contains(aLevel)) { levels.remove(aLevel); //registry.removeObj(registry.getKey(aLevel)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (levels.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("depth", getDepth()); obj.put("number", getNumber()); return obj; } }