1 package org.sapia.soto.state; 2 3 import org.apache.commons.jexl.JexlContext; 4 5 import java.util.Collection ; 6 import java.util.HashSet ; 7 import java.util.Iterator ; 8 import java.util.Map ; 9 import java.util.Set ; 10 11 12 20 public class ScopeMap implements java.util.Map , JexlContext { 21 private Map _scopes; 22 private String [] _scopeNames; 23 24 public ScopeMap(Map scopes, String [] scopeNames) { 25 _scopes = scopes; 26 _scopeNames = scopeNames; 27 } 28 29 32 public Map getVars() { 33 return this; 34 } 35 36 39 public void setVars(Map arg0) { 40 } 41 42 45 public void clear() { 46 } 47 48 51 public boolean containsKey(Object key) { 52 Scope sc; 53 54 if (_scopeNames == null) { 55 for (int i = 0; i < _scopeNames.length; i++) { 56 sc = (Scope) _scopes.get(_scopeNames[i]); 57 58 if (sc != null) { 59 if (sc.getVal(key) != null) { 60 return true; 61 } 62 } 63 } 64 } else { 65 for (Iterator iter = _scopes.values().iterator(); iter.hasNext();) { 66 sc = (Scope) iter.next(); 67 68 if (sc.getVal(key) != null) { 69 return true; 70 } 71 } 72 } 73 74 return false; 75 } 76 77 80 public boolean containsValue(Object arg0) { 81 return false; 82 } 83 84 87 public Set entrySet() { 88 return new HashSet (); 89 } 90 91 94 public Object get(Object key) { 95 Scope sc; 96 Object toReturn = null; 97 98 if (_scopeNames != null) { 99 for (int i = 0; i < _scopeNames.length; i++) { 100 sc = (Scope) _scopes.get(_scopeNames[i]); 101 102 if (sc != null) { 103 if ((toReturn = sc.getVal(key)) != null) { 104 return toReturn; 105 } 106 } 107 } 108 } else { 109 for (Iterator iter = _scopes.values().iterator(); iter.hasNext();) { 110 sc = (Scope) iter.next(); 111 112 if ((toReturn = sc.getVal(key)) != null) { 113 return toReturn; 114 } 115 } 116 } 117 118 return toReturn; 119 } 120 121 124 public boolean isEmpty() { 125 return false; 126 } 127 128 131 public Set keySet() { 132 return new HashSet (); 133 } 134 135 138 public Object put(Object arg0, Object arg1) { 139 throw new UnsupportedOperationException ( 140 "public Object put(Object arg0, Object arg1)"); 141 } 142 143 146 public void putAll(Map arg0) { 147 throw new UnsupportedOperationException ("public void putAll(Map arg0)"); 148 } 149 150 153 public Object remove(Object arg0) { 154 throw new UnsupportedOperationException ("public Object remove(Object arg0)"); 155 } 156 157 160 public int size() { 161 return 0; 162 } 163 164 167 public Collection values() { 168 return new HashSet (); 169 } 170 } 171 | Popular Tags |