You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2003/08/29 14:29:22 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/goal DeployURL.java

jdillon     2003/08/29 05:29:22

  Modified:    modules/core/src/java/org/apache/geronimo/deployment/goal
                        DeployURL.java
  Log:
   o condensed normalization into normalizeURL
  
  Revision  Changes    Path
  1.4       +8 -34     incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/goal/DeployURL.java
  
  Index: DeployURL.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/goal/DeployURL.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DeployURL.java	27 Aug 2003 11:40:01 -0000	1.3
  +++ DeployURL.java	29 Aug 2003 12:29:22 -0000	1.4
  @@ -82,7 +82,7 @@
               throw new NullArgumentException("type");
           }
           
  -        this.url = normalize(url);
  +        this.url = normalizeURL(url);
           this.type = type;
       }
   
  @@ -94,44 +94,18 @@
           return type;
       }
       
  -    private static URL normalize(URL url) {
  +    private static URL normalizeURL(URL url) {
           assert url != null;
           
  -        File f = toFile(url);
  -        if (f != null) {
  +        if (url.getProtocol().equals("file")) {
  +            String filename = url.getFile().replace('/', File.separatorChar);
  +            File file = new File(filename);
               try {
  -                url = f.toURI().toURL();
  -            }
  -            catch (MalformedURLException ignore) {
  -                // ignore, return passed in url
  +                url = file.toURI().toURL();
               }
  +            catch (MalformedURLException ignore) {}
           }
           
           return url;
  -    }
  -    
  -    /**
  -     * Convert from a <code>URL</code> to a <code>File</code>.
  -     *
  -     * @param url   File URL.
  -     * @return      The equivalent <code>File</code> object, or <code>null</code>
  -     *              if the URL's protocol is not <code>file</code>
  -     * 
  -     * @todo this method was taken from commons-sandbox-io.  if/when that
  -     *       project is promoted to commons proper, remove this method and use
  -     *       said library.
  -     */
  -    private static File toFile(final URL url) {
  -        if (url == null) {
  -            throw new NullArgumentException("url");
  -        }
  -        
  -        if (!url.getProtocol().equals("file")) {
  -            return null;
  -        }
  -        else {
  -            String filename = url.getFile().replace('/', File.separatorChar);
  -            return new File(filename);
  -        }
       }
   }