Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 16 package org.directwebremoting.extend; 17 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import org.directwebremoting.util.LocalUtil; 22 23 29 public final class OutboundContext 30 { 31 37 public OutboundContext() 38 { 39 Map assign; 41 42 try 43 { 44 assign = (Map ) LocalUtil.classForName("java.util.IdentityHashMap").newInstance(); 45 referenceWrappers = false; 46 } 47 catch (Exception ex) 48 { 49 assign = new HashMap (); 50 referenceWrappers = true; 51 } 52 53 map = assign; 54 } 55 56 61 public OutboundVariable get(Object object) 62 { 63 Object key = object; 64 if (referenceWrappers) 65 { 66 key = new ReferenceWrapper(object); 67 } 68 69 return (OutboundVariable) map.get(key); 70 } 71 72 76 public void put(Object object, OutboundVariable ss) 77 { 78 Object key = object; 79 if (referenceWrappers) 80 { 81 key = new ReferenceWrapper(object); 82 } 83 84 map.put(key, ss); 85 } 86 87 91 public String getNextVariableName() 92 { 93 String varName = OUTBOUND_VARIABLE_PREFIX + nextVarIndex; 94 nextVarIndex++; 95 96 return varName; 97 } 98 99 102 public String toString() 103 { 104 return map.toString(); 105 } 106 107 110 private static final String OUTBOUND_VARIABLE_PREFIX = "s"; 111 112 115 private final Map map; 116 117 120 private boolean referenceWrappers; 121 122 125 private int nextVarIndex = 0; 126 127 132 private static class ReferenceWrapper 133 { 134 137 protected ReferenceWrapper(Object object) 138 { 139 this.object = object; 140 } 141 142 145 public int hashCode() 146 { 147 return System.identityHashCode(object); 148 } 149 150 153 public boolean equals(Object obj) 154 { 155 if (!(obj instanceof ReferenceWrapper)) 156 { 157 return false; 158 } 159 160 ReferenceWrapper that = (ReferenceWrapper) obj; 161 return this.object == that.object; 162 } 163 164 167 private Object object; 168 } 169 } 170
| Popular Tags
|