maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ogusa...@apache.org
Subject svn commit: r727260 - /maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
Date Wed, 17 Dec 2008 03:42:02 GMT
Author: ogusakov
Date: Tue Dec 16 19:41:59 2008
New Revision: 727260

URL: http://svn.apache.org/viewvc?rev=727260&view=rev
Log:
enhanced toStream() for more flexible protocol treatment - thanks Ben

Modified:
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java

Modified: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java?rev=727260&r1=727259&r2=727260&view=diff
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
(original)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/FileUtil.java
Tue Dec 16 19:41:59 2008
@@ -82,6 +82,8 @@
 
   public static final int    K = 1024;
   public static final int    DEFAULT_BUFFER_SIZE = 10 * K;
+  
+  public static final String [] URL_PROTOCOLS = new String [] {"http://","https://","file://"};
   //---------------------------------------------------------------------------------------------------------------
   private static final IMercuryLogger LOG = MercuryLoggerManager.getLogger( FileUtil.class
);
   private static final Language LANG = new DefaultLanguage( FileUtil.class );
@@ -959,10 +961,11 @@
     if( Util.isEmpty( resource ) )
       return null;
     
-    if( resource.startsWith( "file://" )
-        || resource.startsWith( "http://" )
-    )
-      return new URL(resource).openStream();
+    String lowerRes = resource.toLowerCase();
+    
+    for( String p : URL_PROTOCOLS )
+        if( lowerRes.startsWith( p ) )
+          return new URL(resource).openStream();
 
     return new FileInputStream( new File(resource) );
   }



Mime
View raw message