public List keys() { ArrayList keys = new ArrayList(); for (int x = 0; x < list.size(); x++) { keys.add(((Node) list.get(x)).name); } return keys; }
public void removeAll(String name) { for (int x = 0; x < list.size(); x++) { if (((Node) list.get(x)).name.equals(name)) { // goes backwards to check next element list.remove(x--); } } }
public Object put(String name, Object object) { if (reserved.contains(name)) { throw new IllegalStateException("Cannot set final element - \"" + name + "\""); } if (object == null) { throw new NullPointerException("Tried to set " + name + " as null."); } list.add(0, new Node(name, object)); return object; }
public void remove(String name) throws InternalNotFoundException { Iterator i = list.iterator(); while (i.hasNext()) { Node n = (Node) i.next(); if (n.name.equals(name)) { list.remove(n); return; } } throw new InternalNotFoundException(name); }
public Object set(String name, Object object) { if (reserved.contains(name)) { throw new IllegalStateException("Cannot set final element - \"" + name + "\""); } if (object == null) { throw new NullPointerException("Tried to set " + name + " as null."); } for (int x = 0; x < list.size(); x++) { if (((Node) list.get(x)).name.equals(name)) { // operate on node to affect container scopes ((Node) list.get(x)).object = object; return object; } } put(name, object); return object; }
public Object get(String name) throws InternalNotFoundException { Iterator i = list.iterator(); while (i.hasNext()) { Node n = (Node) i.next(); if (n.name.equals(name)) { return n.object; } } throw new InternalNotFoundException(name); }
public boolean contains(String name) { Iterator i = list.iterator(); while (i.hasNext()) { Node n = (Node) i.next(); if (n.name.equals(name)) { return true; } } return false; }
public Object[] getAll(String name) { Iterator i = list.iterator(); List l = new ArrayList(); while (i.hasNext()) { Node n = (Node) i.next(); if (n.name.equals(name)) { l.add(n.object); } } return l.toArray(); }
protected void reserve(String name, Object value) { removeAll(name); set(name, value); reserved.add(name); }
public GordianStorage(GordianStorage storage) { list.addAll(storage.list); reserved.addAll(storage.reserved); }