geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r570994 - in /geronimo/sandbox/gshell/trunk/gshell-clp/src: main/java/org/apache/geronimo/gshell/clp/handler/ main/java/org/apache/geronimo/gshell/clp/setter/ test/java/org/apache/geronimo/gshell/clp/handler/
Date Thu, 30 Aug 2007 00:18:44 GMT
Author: jdillon
Date: Wed Aug 29 17:18:44 2007
New Revision: 570994

URL: http://svn.apache.org/viewvc?rev=570994&view=rev
Log:
Add an ObjectHandler and clearify comment about the use of Object.class

Added:
    geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/ObjectHandler.java
      - copied, changed from r570694, geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/StringHandler.java
    geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/ObjectHandlerTest.java
      - copied, changed from r570694, geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/StringHandlerTest.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
    geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/setter/CollectionFieldSetter.java

Modified: geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java?rev=570994&r1=570993&r2=570994&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
Wed Aug 29 17:18:44 2007
@@ -120,5 +120,6 @@
         register(Double.class, DoubleHandler.class);
         register(double.class, DoubleHandler.class);
         register(String.class, StringHandler.class);
+        register(Object.class, ObjectHandler.class);
     }
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/ObjectHandler.java
(from r570694, geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/StringHandler.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/ObjectHandler.java?p2=geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/ObjectHandler.java&p1=geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/StringHandler.java&r1=570694&r2=570994&rev=570994&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/StringHandler.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/ObjectHandler.java
Wed Aug 29 17:18:44 2007
@@ -24,14 +24,17 @@
 import org.apache.geronimo.gshell.clp.setter.Setter;
 
 /**
- * Handler for string types.
+ * Handler for object types, simply treating them as strings.
+ *
+ * <p>This is for compatibility with multi-valued bits that don't use generics to
+ *    indicate the class of contained elements.
  *
  * @version $Rev$ $Date$
  */
-public class StringHandler
-    extends Handler<String>
+public class ObjectHandler
+    extends Handler<Object>
 {
-    public StringHandler(Descriptor desc, Setter<? super String> setter) {
+    public ObjectHandler(Descriptor desc, Setter<? super Object> setter) {
         super(desc, setter);
     }
 
@@ -41,7 +44,7 @@
 
         String token = params.get(0);
         setter.set(token);
-        
+
         return 1;
     }
 
@@ -49,4 +52,4 @@
     public String getDefaultMetaVariable() {
         return "VAL";
     }
-}
+}
\ No newline at end of file

Modified: geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/setter/CollectionFieldSetter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/setter/CollectionFieldSetter.java?rev=570994&r1=570993&r2=570994&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/setter/CollectionFieldSetter.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/setter/CollectionFieldSetter.java
Wed Aug 29 17:18:44 2007
@@ -61,8 +61,9 @@
                 return (Class)type;
             }
         }
-
-        // FIXME: This is certainly not valid, Should default to String probably
+        
+        // If collection types don't have a parameter type, then the ObjectHandler will be
used
+        // which basically is the same as the StringHandler
         return Object.class;
     }
 

Copied: geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/ObjectHandlerTest.java
(from r570694, geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/StringHandlerTest.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/ObjectHandlerTest.java?p2=geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/ObjectHandlerTest.java&p1=geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/StringHandlerTest.java&r1=570694&r2=570994&rev=570994&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/StringHandlerTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/ObjectHandlerTest.java
Wed Aug 29 17:18:44 2007
@@ -19,16 +19,18 @@
 
 package org.apache.geronimo.gshell.clp.handler;
 
+import java.util.List;
+
 import junit.framework.TestCase;
 import org.apache.geronimo.gshell.clp.CommandLineProcessor;
 import org.apache.geronimo.gshell.clp.Option;
 
 /**
- * Tests for the {@link StringHandler} class.
+ * Tests for the {@link ObjectHandler} class.
  *
  * @version $Rev$ $Date$
  */
-public class StringHandlerTest
+public class ObjectHandlerTest
     extends TestCase
 {
     TestBean bean;
@@ -51,12 +53,14 @@
     public void test1() throws Exception {
         clp.process("-1", "test");
 
-        assertEquals("test", bean.s);
+        assertNotNull(bean.list);
+        assertEquals(1, bean.list.size());
+        assertEquals("test", bean.list.get(0));
     }
 
     private static class TestBean
     {
         @Option(name="-1")
-        String s;
+        List list;
     }
 }



Mime
View raw message