[jboss-cvs] JBossAS SVN: r74349 - projects/vfs/trunk/src/main/java/org/jboss/virtual.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 10 06:03:24 EDT 2008


Author: alesj
Date: 2008-06-10 06:03:24 -0400 (Tue, 10 Jun 2008)
New Revision: 74349

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
Log:
Add url spec compatible transformation helper method.

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java	2008-06-10 09:43:01 UTC (rev 74348)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java	2008-06-10 10:03:24 UTC (rev 74349)
@@ -534,4 +534,31 @@
       VirtualFileHandler handler = file.getHandler();
       return handler.isNested();
    }
+
+   /**
+    * Get spec compatilbe url from virtual file.
+    *
+    * @param file the virtual file
+    * @return spec compatible url
+    * @throws IOException for any error
+    * @throws URISyntaxException for any uri syntax error
+    */
+   public static URL getCompatibleURL(VirtualFile file) throws IOException, URISyntaxException
+   {
+      URL url = file.toURL();
+      // is not nested, so direct VFS URL is not an option
+      if (isNestedFile(file) == false)
+      {
+         String urlString = url.toExternalForm();
+         if (urlString.startsWith("vfs"))
+         {
+            // treat vfszip as file
+            if (urlString.startsWith("vfszip"))
+               url = new URL("file" + urlString.substring(6));
+            else
+               url = new URL(urlString.substring(3)); // (vfs)file and (vfs)jar are ok
+         }
+      }
+      return url;
+   }
 }




More information about the jboss-cvs-commits mailing list