geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r576614 - in /geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src: main/java/org/apache/geronimo/gshell/clp/handler/ test/java/org/apache/geronimo/gshell/clp/handler/
Date Mon, 17 Sep 2007 22:34:37 GMT
Author: jdillon
Date: Mon Sep 17 15:34:32 2007
New Revision: 576614

URL: http://svn.apache.org/viewvc?rev=576614&view=rev
Log:
Support URI types

Added:
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/UriHandler.java
      - copied, changed from r576612, geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/FileHandler.java
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/UriHandlerTest.java
      - copied, changed from r576612, geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/FileHandlerTest.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java

Modified: geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java?rev=576614&r1=576613&r2=576614&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/Handlers.java
Mon Sep 17 15:34:32 2007
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -115,6 +116,7 @@
         register(Boolean.class, BooleanHandler.class);
         register(boolean.class, BooleanHandler.class);
         register(File.class, FileHandler.class);
+        register(URI.class, UriHandler.class);
         register(Integer.class, IntegerHandler.class);
         register(int.class, IntegerHandler.class);
         register(Double.class, DoubleHandler.class);

Copied: geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/UriHandler.java
(from r576612, geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/FileHandler.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/UriHandler.java?p2=geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/UriHandler.java&p1=geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/FileHandler.java&r1=576612&r2=576614&rev=576614&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/FileHandler.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/handler/UriHandler.java
Mon Sep 17 15:34:32 2007
@@ -19,7 +19,8 @@
 
 package org.apache.geronimo.gshell.clp.handler;
 
-import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 import org.apache.geronimo.gshell.clp.Descriptor;
 import org.apache.geronimo.gshell.clp.ProcessingException;
@@ -30,10 +31,10 @@
  *
  * @version $Rev$ $Date$
  */
-public class FileHandler
-    extends Handler<File>
+public class UriHandler
+    extends Handler<URI>
 {
-    public FileHandler(final Descriptor desc, final Setter<? super File> setter) {
+    public UriHandler(final Descriptor desc, final Setter<? super URI> setter) {
         super(desc, setter);
     }
 
@@ -42,13 +43,19 @@
         assert params != null;
 
         String token = params.get(0);
-        setter.set(new File(token));
-        
+
+        try {
+            setter.set(new URI(token));
+        }
+        catch (URISyntaxException e) {
+            throw new ProcessingException(e);
+        }
+
         return 1;
     }
 
     @Override
     public String getDefaultMetaVariable() {
-        return "FILE";
+        return "URI";
     }
-}
+}
\ No newline at end of file

Copied: geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/UriHandlerTest.java
(from r576612, geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/FileHandlerTest.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/UriHandlerTest.java?p2=geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/UriHandlerTest.java&p1=geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/FileHandlerTest.java&r1=576612&r2=576614&rev=576614&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/FileHandlerTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/src/test/java/org/apache/geronimo/gshell/clp/handler/UriHandlerTest.java
Mon Sep 17 15:34:32 2007
@@ -19,18 +19,18 @@
 
 package org.apache.geronimo.gshell.clp.handler;
 
-import java.io.File;
+import java.net.URI;
 
 import junit.framework.TestCase;
 import org.apache.geronimo.gshell.clp.CommandLineProcessor;
 import org.apache.geronimo.gshell.clp.Option;
 
 /**
- * Tests for the {@link FileHandler} class.
+ * Tests for the {@link UriHandler} class.
  *
  * @version $Rev$ $Date$
  */
-public class FileHandlerTest
+public class UriHandlerTest
     extends TestCase
 {
     TestBean bean;
@@ -51,16 +51,16 @@
     }
 
     public void test1() throws Exception {
-        clp.process("-1", "/tmp");
+        clp.process("-1", "foo:bar");
 
-        File f = new File("/tmp");
+        URI l = new URI("foo:bar");
 
-        assertEquals(f, bean.f);
+        assertEquals(l, bean.l);
     }
 
     private static class TestBean
     {
         @Option(name="-1")
-        File f;
+        URI l;
     }
 }



Mime
View raw message