示例#1
0
 public List keys() {
   ArrayList keys = new ArrayList();
   for (int x = 0; x < list.size(); x++) {
     keys.add(((Node) list.get(x)).name);
   }
   return keys;
 }
示例#2
0
 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--);
     }
   }
 }
示例#3
0
 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;
 }
示例#4
0
 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);
 }
示例#5
0
 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;
 }
示例#6
0
 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);
 }
示例#7
0
 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;
 }
示例#8
0
 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();
 }
示例#9
0
 protected void reserve(String name, Object value) {
   removeAll(name);
   set(name, value);
   reserved.add(name);
 }
示例#10
0
 public GordianStorage(GordianStorage storage) {
   list.addAll(storage.list);
   reserved.addAll(storage.reserved);
 }