geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: incubator-geronimo/modules/common/src/test-data/org/apache/geronimo/common/net/protocol/resource resource.properties
Date Fri, 27 Feb 2004 00:49:07 GMT
dain        2004/02/26 16:49:07

  Modified:    modules/common/src/java/org/apache/geronimo/common/propertyeditor
                        URLEditor.java
  Removed:     modules/common/src/java/org/apache/geronimo/common/net
                        URLFactory.java
               modules/common/src/java/org/apache/geronimo/common/net/protocol
                        DelegatingURLConnection.java Protocols.java
                        URLStreamHandlerFactory.java
               modules/common/src/java/org/apache/geronimo/common/net/protocol/file
                        FileURLConnection.java Handler.java
               modules/common/src/java/org/apache/geronimo/common/net/protocol/resource
                        Handler.java ResourceURLConnection.java
               modules/common/src/java/org/apache/geronimo/common/task
                        URLMonitorTask.java
               modules/common/src/test/org/apache/geronimo/common/net/protocol
                        ProtocolsTest.java
               modules/common/src/test/org/apache/geronimo/common/net/protocol/file
                        FileProtocolTest.java
               modules/common/src/test/org/apache/geronimo/common/net/protocol/resource
                        ResourceProtocolTest.java
               modules/common/src/test/org/apache/geronimo/common/task
                        MockURLMonitorTaskListener.java
                        URLMonitorTaskTest.java
               modules/common/src/test-data resource.properties
               modules/common/src/test-data/org/apache/geronimo/common/net/protocol/resource
                        resource.properties
  Log:
  Converted to a GBean and moved to system module
  
  Revision  Changes    Path
  1.4       +23 -11    incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/propertyeditor/URLEditor.java
  
  Index: URLEditor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/src/java/org/apache/geronimo/common/propertyeditor/URLEditor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- URLEditor.java	25 Feb 2004 09:57:03 -0000	1.3
  +++ URLEditor.java	27 Feb 2004 00:49:07 -0000	1.4
  @@ -17,18 +17,16 @@
   
   package org.apache.geronimo.common.propertyeditor;
   
  +import java.io.File;
   import java.net.MalformedURLException;
  -
  -import org.apache.geronimo.common.net.URLFactory;
  +import java.net.URL;
   
   /**
    * A property editor for {@link java.net.URL}.
    *
    * @version $Revision$ $Date$
    */
  -public class URLEditor
  -    extends TextPropertyEditorSupport
  -{
  +public class URLEditor extends TextPropertyEditorSupport {
       /**
        * Returns a URL for the input object converted to a string.
        *
  @@ -36,13 +34,27 @@
        *
        * @throws PropertyEditorException   An MalformedURLException occured.
        */
  -    public Object getValue()
  -    {
  +    public Object getValue() {
           try {
  -            return URLFactory.create(getAsText());
  -        }
  -        catch (MalformedURLException e) {
  +            String urlspec = getAsText().trim();
  +            URL url;
  +            try {
  +                url = new URL(urlspec);
  +                if (url.getProtocol().equals("file")) {
  +                    url = createFromFilespec(url.getFile());
  +                }
  +            } catch (Exception e) {
  +                url = createFromFilespec(urlspec);
  +            }
  +
  +            return url;
  +
  +        } catch (MalformedURLException e) {
               throw new PropertyEditorException(e);
           }
  +    }
  +
  +    private static URL createFromFilespec(final String filespec) throws MalformedURLException
{
  +        return new File(filespec).toURI().toURL();
       }
   }
  
  
  

Mime
View raw message