Skip to Content.
Sympa Menu

notify-dpml - r1944 - in trunk: central/site/src/docs/metro/component/directive main/metro/part/etc/data main/metro/part/src/test/net/dpml/runtime/context main/metro/part/src/test/org/acme

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1944 - in trunk: central/site/src/docs/metro/component/directive main/metro/part/etc/data main/metro/part/src/test/net/dpml/runtime/context main/metro/part/src/test/org/acme
  • Date: Mon, 2 Apr 2007 21:19:08 +0200

Author: mcconnell
Date: 2007-04-02 21:19:07 +0200 (Mon, 02 Apr 2007)
New Revision: 1944

Added:
trunk/central/site/src/docs/metro/component/directive/map.xml
Modified:
trunk/central/site/src/docs/metro/component/directive/context.xml
trunk/central/site/src/docs/metro/component/directive/navigation.xml
trunk/main/metro/part/etc/data/map.xml
trunk/main/metro/part/src/test/net/dpml/runtime/context/MapTestCase.java
trunk/main/metro/part/src/test/org/acme/MapWidget.java
Log:
update context docs, add sample using non-string map entry values, updates to
test case to include non-string example

Modified: trunk/central/site/src/docs/metro/component/directive/context.xml
===================================================================
--- trunk/central/site/src/docs/metro/component/directive/context.xml
2007-04-02 18:00:35 UTC (rev 1943)
+++ trunk/central/site/src/docs/metro/component/directive/context.xml
2007-04-02 19:19:07 UTC (rev 1944)
@@ -40,6 +40,13 @@
<td>If the context entry return type is itself a context
interface
then the context element may be supplied as the value
solution.</td>
</tr>
+ <tr>
+ <td><tt><a href="map.html">map</a></tt></td>
+ <td>Nested entries are used to construct an instance of
java.util.Map.
+ If the entry class attribute is not null, the constructed map
+ will be used as a constructor argument to the class declared
+ by the class attribute.</td>
+ </tr>
</table>

</subsection>

Added: trunk/central/site/src/docs/metro/component/directive/map.xml
===================================================================
--- trunk/central/site/src/docs/metro/component/directive/map.xml
2007-04-02 18:00:35 UTC (rev 1943)
+++ trunk/central/site/src/docs/metro/component/directive/map.xml
2007-04-02 19:19:07 UTC (rev 1944)
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<document>
+
+ <properties>
+ <author email="mcconnell AT dpml.net">Stephen McConnell</author>
+ <title>DPML Metro: Map Entry Directive</title>
+ </properties>
+
+ <body>
+
+ <section name="Map Entry Directive">
+
+ <subsection name="Description">
+
+ <p>
+ Declaration of a context entry wherein nested entries are
+ used to construct an instance of <tt>java.util.Map</tt>.
+ </p>
+
+ </subsection>
+
+ <subsection name="Map Attributes">
+ <table>
+ <tr>
+ <td><tt>key</tt></td>
+ <td>The entry key (required).</td>
+ </tr>
+ <tr>
+ <td><tt>class</tt></td>
+ <td>
+ Optional declaration of a classname to be instantiated using
+ a container resolved map instance. The class must refer to
+ an implementation class that takes a <tt>java.util.Map</tt>
+ as a single constructor argument and must be assignable to the
+ context entry return type.
+ </td>
+ </tr>
+ </table>
+ </subsection>
+
+ <subsection name="Map Nested Elements">
+
+ <table>
+ <tr>
+ <td><tt><a href="entry.html">entry</a></tt></td>
+ <td>Defines a key and value to be added to the map instance.</td>
+ </tr>
+ </table>
+
+ </subsection>
+
+ </section>
+
+ <section name="Examples">
+
+ <subsection name="General Example">
+
+ <p>
+ The following example demonstrates the creation of three
+ map-based context entries. The first entry demonstrates
+ the default construction wherein the container handles
+ the creation a Map instance using nested entries as map
+ key and value bindings. The second example demonstrates
+ the declaration of an alternative map implementation class
+ (in this case the <tt>java.util.TreeMap</tt>) which will
+ be instantiated with the resolved map as a single
+ constructor argument. The third example demonstrates
+ the construction of a map containing color values assigned
+ to keys (note that a default implementation class cannot be
+ resolved for map entries - as such the class attribute must
+ be used for any non-string value declaration).
+ </p>
+
+<source><![CDATA[
+<context>
+ <map key="primary">
+ <entry key="message" value="Hello from the map entry"/>
+ <entry key="foo" value="bar"/>
+ </map>
+ <map key="secondary" class="java.util.TreeMap">
+ <entry key="foo" value="bar"/>
+ <entry key="ping" value="pong"/>
+ </map>
+ <map key="colors">
+ <entry key="red" class="java.awt.Color" method="RED"/>
+ <entry key="white" class="java.awt.Color" method="WHITE"/>
+ <entry key="blue" class="java.awt.Color" method="BLUE"/>
+ </map>
+</context>
+]]></source>
+
+ </subsection>
+
+ </section>
+
+ </body>
+
+</document>

Modified: trunk/central/site/src/docs/metro/component/directive/navigation.xml
===================================================================
--- trunk/central/site/src/docs/metro/component/directive/navigation.xml
2007-04-02 18:00:35 UTC (rev 1943)
+++ trunk/central/site/src/docs/metro/component/directive/navigation.xml
2007-04-02 19:19:07 UTC (rev 1944)
@@ -28,6 +28,7 @@
<item name="Component" href="component.html"/>
<!--<item name="Categories" href="categories.html"/>-->
<item name="Context" href="context.html"/>
+ <item name="Map" href="map.html"/>
<item name="Entry" href="entry.html"/>
<item name="Param" href="value.html"/>
<item name="Parts" href="parts.html"/>

Modified: trunk/main/metro/part/etc/data/map.xml
===================================================================
--- trunk/main/metro/part/etc/data/map.xml 2007-04-02 18:00:35 UTC (rev
1943)
+++ trunk/main/metro/part/etc/data/map.xml 2007-04-02 19:19:07 UTC (rev
1944)
@@ -13,6 +13,11 @@
<entry key="foo" value="bar"/>
<entry key="ping" value="pong"/>
</map>
+ <map key="colors">
+ <entry key="red" class="java.awt.Color" method="RED"/>
+ <entry key="blue" class="java.awt.Color" method="BLUE"/>
+ <entry key="green" class="java.awt.Color" method="GREEN"/>
+ </map>
</context>
</component>


Modified:
trunk/main/metro/part/src/test/net/dpml/runtime/context/MapTestCase.java
===================================================================
--- trunk/main/metro/part/src/test/net/dpml/runtime/context/MapTestCase.java
2007-04-02 18:00:35 UTC (rev 1943)
+++ trunk/main/metro/part/src/test/net/dpml/runtime/context/MapTestCase.java
2007-04-02 19:19:07 UTC (rev 1944)
@@ -18,6 +18,7 @@

package net.dpml.runtime.context;

+import java.awt.Color;
import java.util.Map;
import java.util.SortedMap;

@@ -54,4 +55,17 @@
assertEquals( "foo", "bar", foo );
assertEquals( "ping", "pong", ping );
}
+
+ public void testColors() throws Exception
+ {
+ MapWidget widget =
+ load( MapWidget.class, "map.xml", "map" );
+ Map<String,Color> map = widget.getContext().getColors();
+ Color red = map.get( "red" );
+ Color green = map.get( "green" );
+ Color blue = map.get( "blue" );
+ assertEquals( "red", Color.RED, red );
+ assertEquals( "green", Color.GREEN, green );
+ assertEquals( "blue", Color.BLUE, blue );
+ }
}

Modified: trunk/main/metro/part/src/test/org/acme/MapWidget.java
===================================================================
--- trunk/main/metro/part/src/test/org/acme/MapWidget.java 2007-04-02
18:00:35 UTC (rev 1943)
+++ trunk/main/metro/part/src/test/org/acme/MapWidget.java 2007-04-02
19:19:07 UTC (rev 1944)
@@ -18,6 +18,7 @@

package org.acme;

+import java.awt.Color;
import java.util.Map;
import java.util.SortedMap;

@@ -33,6 +34,7 @@
{
Map<String,String> getPrimary();
SortedMap<String,String> getSecondary();
+ Map<String,Color> getColors();
}

private Context m_context;




  • r1944 - in trunk: central/site/src/docs/metro/component/directive main/metro/part/etc/data main/metro/part/src/test/net/dpml/runtime/context main/metro/part/src/test/org/acme, mcconnell at BerliOS, 04/02/2007

Archive powered by MHonArc 2.6.24.

Top of Page