You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/01/31 21:43:51 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/util NetUtils.java

bloritsch    01/01/31 12:43:51

  Modified:    src/org/apache/cocoon/util Tag: xml-cocoon2 NetUtils.java
  Log:
  Change ordering of URL resolution.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.6   +12 -12    xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java
  
  Index: NetUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/util/Attic/NetUtils.java,v
  retrieving revision 1.1.2.5
  retrieving revision 1.1.2.6
  diff -u -r1.1.2.5 -r1.1.2.6
  --- NetUtils.java	2001/01/31 15:03:56	1.1.2.5
  +++ NetUtils.java	2001/01/31 20:43:50	1.1.2.6
  @@ -19,7 +19,7 @@
    * utility methods
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1.2.5 $ $Date: 2001/01/31 15:03:56 $
  + * @version CVS $Revision: 1.1.2.6 $ $Date: 2001/01/31 20:43:50 $
    */
   
   public class NetUtils {
  @@ -57,22 +57,22 @@
        * @exception MalformedURLException If the location is malformed
        */
       public static URL getURL(String location) throws MalformedURLException {
  -        if (location.indexOf("://") < 0) {
  -            if (NetUtils.root != null) {
  -                return (new File(NetUtils.root, location)).toURL();
  -            }
  -
  -            return (new File(location)).toURL();
  -        } else if (location.startsWith("resource://")) {
  +        if (location.startsWith("resource://")) {
               URL u = ClassUtils.getResource(location.substring("resource://".length()));
               if (u != null) return u;
               else throw new RuntimeException(location + " could not be found. (possible classloader problem)");
           } else if (location.startsWith("context://")) {
  -        URL u = NetUtils.context.getResource(location.substring("context://".length()));
  -        if (u != null) return u;
  -        else throw new RuntimeException(location + " could not be found. (possible classloader problem)");
  -    } else {
  +            URL u = NetUtils.context.getResource(location.substring("context://".length()));
  +            if (u != null) return u;
  +            else throw new RuntimeException(location + " could not be found. (possible classloader problem)");
  +        } else if (location.indexOf("://") > 0) {
               return new URL(location);
  +        } else {
  +            if (NetUtils.root != null) {
  +                return (new File(NetUtils.root, location)).toURL();
  +            }
  +
  +            return (new File(location)).toURL();
           }
       }