KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jasperreports > OgnlValueStackShadowMap


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jasperreports;
6
7 import com.opensymphony.xwork.util.OgnlValueStack;
8
9 import java.util.HashMap JavaDoc;
10 import java.util.Set JavaDoc;
11
12
13 /**
14  * Ported to WebWork2:
15  *
16  * @author <a HREF="hermanns@aixcept.de">Rainer Hermanns</a>
17  * @version $Id: OgnlValueStackShadowMap.java,v 1.3 2004/06/18 19:30:00 plightbo Exp $
18  */

19 public class OgnlValueStackShadowMap extends HashMap JavaDoc {
20     //~ Instance fields ////////////////////////////////////////////////////////
21

22     /**
23      * valueStack reference
24      */

25     OgnlValueStack valueStack;
26
27     /**
28      * entries reference
29      */

30     Set JavaDoc entries;
31
32     //~ Constructors ///////////////////////////////////////////////////////////
33

34     /**
35      * Constructs an instance of OgnlValueStackShadowMap.
36      *
37      * @param valueStack - the underlying valuestack
38      */

39     public OgnlValueStackShadowMap(OgnlValueStack valueStack) {
40         this.valueStack = valueStack;
41     }
42
43     //~ Methods ////////////////////////////////////////////////////////////////
44

45     /**
46      * Implementation of containsKey(), overriding HashMap implementation.
47      *
48      * @param key - The key to check in HashMap and if not found to check on valueStack.
49      * @return <tt>true</tt>, if conatins key, <tt>false</tt> otherwise.
50      * @see java.util.HashMap#containsKey
51      */

52     public boolean containsKey(Object JavaDoc key) {
53         boolean hasKey = super.containsKey(key);
54
55         if (!hasKey) {
56             if (valueStack.findValue((String JavaDoc) key) != null) {
57                 hasKey = true;
58             }
59         }
60
61         return hasKey;
62     }
63
64     /**
65      * Implementation of get(), overriding HashMap implementation.
66      *
67      * @param key - The key to get in HashMap and if not found there from the valueStack.
68      * @return value - The object from HashMap or if null, from the valueStack.
69      * @see java.util.HashMap#get
70      */

71     public Object JavaDoc get(Object JavaDoc key) {
72         Object JavaDoc value = super.get(key);
73
74         if ((value == null) && key instanceof String JavaDoc) {
75             value = valueStack.findValue((String JavaDoc) key);
76         }
77
78         return value;
79     }
80 }
81
Popular Tags