1 package org.apache.velocity.context; 2 3 18 19 import java.io.Serializable ; 20 21 import org.apache.velocity.context.Context; 22 import org.apache.velocity.context.InternalContextBase; 23 24 52 53 public abstract class AbstractContext extends InternalContextBase 54 implements Context, Serializable 55 { 56 59 private Context innerContext = null; 60 61 71 public abstract Object internalGet( String key ); 72 73 84 public abstract Object internalPut( String key, Object value ); 85 86 95 public abstract boolean internalContainsKey(Object key); 96 97 106 public abstract Object [] internalGetKeys(); 107 108 117 public abstract Object internalRemove(Object key); 118 119 122 public AbstractContext() 123 { 124 } 125 126 133 public AbstractContext( Context inner ) 134 { 135 innerContext = inner; 136 137 141 142 if (innerContext instanceof InternalEventContext ) 143 { 144 attachEventCartridge( ( (InternalEventContext) innerContext).getEventCartridge() ); 145 } 146 } 147 148 156 public Object put(String key, Object value) 157 { 158 161 162 if (key == null) 163 { 164 return null; 165 } 166 else if (value == null) 167 { 168 return null; 169 } 170 171 return internalPut(key, value); 172 } 173 174 184 public Object get(String key) 185 { 186 189 190 if (key == null) 191 { 192 return null; 193 } 194 195 199 200 Object o = internalGet( key ); 201 202 if (o == null && innerContext != null) 203 { 204 o = innerContext.get( key ); 205 } 206 207 return o; 208 } 209 210 217 public boolean containsKey(Object key) 218 { 219 if (key == null) 220 { 221 return false; 222 } 223 224 return internalContainsKey(key); 225 } 226 227 232 public Object [] getKeys() 233 { 234 return internalGetKeys(); 235 } 236 237 244 public Object remove(Object key) 245 { 246 if (key == null) 247 { 248 return null; 249 } 250 251 return internalRemove(key); 252 } 253 254 259 public Context getChainedContext() 260 { 261 return innerContext; 262 } 263 264 } 265 266 267 268 | Popular Tags |