velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r554740 - /velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java
Date Mon, 09 Jul 2007 19:08:27 GMT
Author: nbubna
Date: Mon Jul  9 12:08:26 2007
New Revision: 554740

URL: http://svn.apache.org/viewvc?view=rev&rev=554740
Log:
add support for easy Data config

Modified:
    velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java

Modified: velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java
URL: http://svn.apache.org/viewvc/velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java?view=diff&rev=554740&r1=554739&r2=554740
==============================================================================
--- velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java
(original)
+++ velocity/tools/branches/2.x/src/main/java/org/apache/velocity/tools/config/EasyFactoryConfiguration.java
Mon Jul  9 12:08:26 2007
@@ -118,6 +118,37 @@
         return this;
     }
 
+    public EasyData data(String key, Object value)
+    {
+        Data datum = new Data();
+        datum.setKey(key);
+        datum.setValue(value);
+        addData(datum);
+        return new EasyData(datum, this);
+    }
+
+    public EasyFactoryConfiguration data(String key, String type, Object value)
+    {
+        EasyData datum = data(key, value);
+        datum.type(type);
+        return this;
+    }
+
+    public EasyFactoryConfiguration string(String key, Object value)
+    {
+        return data(key, "string", value);
+    }
+
+    public EasyFactoryConfiguration number(String key, Object value)
+    {
+        return data(key, "number", value);
+    }
+
+    public EasyFactoryConfiguration bool(String key, Object value)
+    {
+        return data(key, "boolean", value);
+    }
+
     public EasyWrap<ToolboxConfiguration> toolbox(String scope)
     {
         ToolboxConfiguration toolbox = new ToolboxConfiguration();
@@ -158,6 +189,58 @@
         return this;
     }
 
+
+    public class EasyData
+    {
+        private Data datum;
+        private Configuration parent;
+
+        public EasyData(Data datum, Configuration parent)
+        {
+            this.datum = datum;
+            this.parent = parent;
+        }
+
+        public Data getData()
+        {
+            return this.datum;
+        }
+
+        public Configuration getParent()
+        {
+            return this.parent;
+        }
+
+        public EasyData type(String type)
+        {
+            this.datum.setType(type);
+            return this;
+        }
+
+        public EasyData target(Class clazz)
+        {
+            this.datum.setTargetClass(clazz);
+            return this;
+        }
+
+        public EasyData classname(String classname)
+        {
+            this.datum.setClassname(classname);
+            return this;
+        }
+
+        public EasyData converter(String converter)
+        {
+            this.datum.setConverter(converter);
+            return this;
+        }
+
+        public EasyData converter(Class clazz)
+        {
+            this.datum.setConverter(clazz);
+            return this;
+        }
+    }
 
 
     public class EasyWrap<C extends Configuration>



Mime
View raw message