commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r540426 - in /jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils: BasicDynaBean.java DynaBeanMapDecorator.java LazyDynaBean.java LazyDynaMap.java
Date Tue, 22 May 2007 05:34:48 GMT
Author: niallp
Date: Mon May 21 22:34:47 2007
New Revision: 540426

URL: http://svn.apache.org/viewvc?view=rev&rev=540426
Log:
Provide a getMap() method in DynaBeanMapDecorator in BasicDynaBean that uses DynaBeanMapDecorator
to provide a Map representation of the DynaBean

Modified:
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BasicDynaBean.java
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/DynaBeanMapDecorator.java
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
    jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaMap.java

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BasicDynaBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BasicDynaBean.java?view=diff&rev=540426&r1=540425&r2=540426
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BasicDynaBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/BasicDynaBean.java
Mon May 21 22:34:47 2007
@@ -76,6 +76,27 @@
      */
     protected HashMap values = new HashMap();
 
+    /** Map decorator for this DynaBean */
+    private transient Map mapDecorator;
+
+    /**
+     * Return a Map representation of this DynaBean.
+     * </p>
+     * This, for example, could be used in JSTL in the following way to access
+     * a DynaBean's <code>fooProperty</code>:
+     * <ul><li><code>${myDynaBean.<b>map</b>.fooProperty}</code></li></ul>
+     *
+     * @return a Map representation of this DynaBean
+     */
+    public Map getMap() {
+
+        // cache the Map
+        if (mapDecorator == null) {
+            mapDecorator = new DynaBeanMapDecorator(this);
+        }
+        return mapDecorator;
+
+    }
 
     // ------------------------------------------------------ DynaBean Methods
 

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/DynaBeanMapDecorator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/DynaBeanMapDecorator.java?view=diff&rev=540426&r1=540425&r2=540426
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/DynaBeanMapDecorator.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/DynaBeanMapDecorator.java
Mon May 21 22:34:47 2007
@@ -74,7 +74,7 @@
 
     private DynaBean dynaBean;
     private boolean readOnly;
-    private Set keySet;
+    private transient Set keySet;
 
     // ------------------- Constructors ----------------------------------
 
@@ -331,7 +331,7 @@
      *
      * @return the decorated {@link DynaBean}.
      */
-    protected DynaBean getDynaBean() {
+    public DynaBean getDynaBean() {
         return dynaBean;
     }
 

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java?view=diff&rev=540426&r1=540425&r2=540426
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaBean.java
Mon May 21 22:34:47 2007
@@ -140,6 +140,9 @@
      */
     protected Map values;
 
+    /** Map decorator for this DynaBean */
+    private transient Map mapDecorator;
+
     /**
      * The <code>MutableDynaClass</code> "base class" that this DynaBean
      * is associated with.
@@ -188,11 +191,20 @@
     // ------------------- Public Methods ----------------------------------
 
     /**
-     * Return the Map backing this <code>DynaBean</code>
-     * @return the underlying Map
+     * Return a Map representation of this DynaBean.
+     * </p>
+     * This, for example, could be used in JSTL in the following way to access
+     * a DynaBean's <code>fooProperty</code>:
+     * <ul><li><code>${myDynaBean.<b>map</b>.fooProperty}</code></li></ul>
+     *
+     * @return a Map representation of this DynaBean
      */
     public Map getMap() {
-        return values;
+        // cache the Map
+        if (mapDecorator == null) {
+            mapDecorator = new DynaBeanMapDecorator(this);
+        }
+        return mapDecorator;
     }
 
     /**

Modified: jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaMap.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaMap.java?view=diff&rev=540426&r1=540425&r2=540426
==============================================================================
--- jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaMap.java
(original)
+++ jakarta/commons/proper/beanutils/trunk/src/java/org/apache/commons/beanutils/LazyDynaMap.java
Mon May 21 22:34:47 2007
@@ -150,6 +150,14 @@
         this.values = values;
     }
 
+    /**
+     * Return the underlying Map backing this <code>DynaBean</code>
+     * @return the underlying Map
+     */
+    public Map getMap() {
+        return values;
+    }
+
     // ------------------- DynaBean Methods ----------------------------------
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message