home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / script / SimpleBindings.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.4 KB  |  94 lines

  1. package javax.script;
  2.  
  3. import java.util.Collection;
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Set;
  7.  
  8. public class SimpleBindings implements Bindings {
  9.    private Map<String, Object> map;
  10.  
  11.    public SimpleBindings(Map<String, Object> var1) {
  12.       if (var1 == null) {
  13.          throw new NullPointerException();
  14.       } else {
  15.          this.map = var1;
  16.       }
  17.    }
  18.  
  19.    public SimpleBindings() {
  20.       this(new HashMap());
  21.    }
  22.  
  23.    public Object put(String var1, Object var2) {
  24.       this.checkKey(var1);
  25.       return this.map.put(var1, var2);
  26.    }
  27.  
  28.    public void putAll(Map<? extends String, ? extends Object> var1) {
  29.       if (var1 == null) {
  30.          throw new NullPointerException("toMerge map is null");
  31.       } else {
  32.          for(Map.Entry var3 : var1.entrySet()) {
  33.             String var4 = (String)var3.getKey();
  34.             this.checkKey(var4);
  35.             this.put(var4, var3.getValue());
  36.          }
  37.  
  38.       }
  39.    }
  40.  
  41.    public void clear() {
  42.       this.map.clear();
  43.    }
  44.  
  45.    public boolean containsKey(Object var1) {
  46.       this.checkKey(var1);
  47.       return this.map.containsKey(var1);
  48.    }
  49.  
  50.    public boolean containsValue(Object var1) {
  51.       return this.map.containsValue(var1);
  52.    }
  53.  
  54.    public Set<Map.Entry<String, Object>> entrySet() {
  55.       return this.map.entrySet();
  56.    }
  57.  
  58.    public Object get(Object var1) {
  59.       this.checkKey(var1);
  60.       return this.map.get(var1);
  61.    }
  62.  
  63.    public boolean isEmpty() {
  64.       return this.map.isEmpty();
  65.    }
  66.  
  67.    public Set<String> keySet() {
  68.       return this.map.keySet();
  69.    }
  70.  
  71.    public Object remove(Object var1) {
  72.       this.checkKey(var1);
  73.       return this.map.remove(var1);
  74.    }
  75.  
  76.    public int size() {
  77.       return this.map.size();
  78.    }
  79.  
  80.    public Collection<Object> values() {
  81.       return this.map.values();
  82.    }
  83.  
  84.    private void checkKey(Object var1) {
  85.       if (var1 == null) {
  86.          throw new NullPointerException("key can not be null");
  87.       } else if (!(var1 instanceof String)) {
  88.          throw new ClassCastException("key should be a String");
  89.       } else if (var1.equals("")) {
  90.          throw new IllegalArgumentException("key can not be empty");
  91.       }
  92.    }
  93. }
  94.