01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.webwork.views.jasperreports;
06:
07: import com.opensymphony.xwork.util.OgnlValueStack;
08:
09: import java.util.HashMap;
10: import java.util.Set;
11:
12: /**
13: * Ported to WebWork2:
14: *
15: * @author <a href="hermanns@aixcept.de">Rainer Hermanns</a>
16: * @version $Id: OgnlValueStackShadowMap.java 1282 2005-10-09 04:26:58Z plightbo $
17: */
18: public class OgnlValueStackShadowMap extends HashMap {
19:
20: /**
21: * valueStack reference
22: */
23: OgnlValueStack valueStack;
24:
25: /**
26: * entries reference
27: */
28: Set entries;
29:
30: /**
31: * Constructs an instance of OgnlValueStackShadowMap.
32: *
33: * @param valueStack - the underlying valuestack
34: */
35: public OgnlValueStackShadowMap(OgnlValueStack valueStack) {
36: this .valueStack = valueStack;
37: }
38:
39: /**
40: * Implementation of containsKey(), overriding HashMap implementation.
41: *
42: * @param key - The key to check in HashMap and if not found to check on valueStack.
43: * @return <tt>true</tt>, if conatins key, <tt>false</tt> otherwise.
44: * @see java.util.HashMap#containsKey
45: */
46: public boolean containsKey(Object key) {
47: boolean hasKey = super .containsKey(key);
48:
49: if (!hasKey) {
50: if (valueStack.findValue((String) key) != null) {
51: hasKey = true;
52: }
53: }
54:
55: return hasKey;
56: }
57:
58: /**
59: * Implementation of get(), overriding HashMap implementation.
60: *
61: * @param key - The key to get in HashMap and if not found there from the valueStack.
62: * @return value - The object from HashMap or if null, from the valueStack.
63: * @see java.util.HashMap#get
64: */
65: public Object get(Object key) {
66: Object value = super .get(key);
67:
68: if ((value == null) && key instanceof String) {
69: value = valueStack.findValue((String) key);
70: }
71:
72: return value;
73: }
74: }
|