[jboss-cvs] JBossAS SVN: r76440 - projects/vfs/trunk/src/main/java/org/jboss/virtual.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 29 16:49:01 EDT 2008
Author: mstruk
Date: 2008-07-29 16:49:01 -0400 (Tue, 29 Jul 2008)
New Revision: 76440
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java
Log:
Added getCompatibleURI() 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-07-29 20:17:08 UTC (rev 76439)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/VFSUtils.java 2008-07-29 20:49:01 UTC (rev 76440)
@@ -732,4 +732,37 @@
}
return url;
}
+
+ /**
+ * Get spec compatilbe uri from virtual file.
+ *
+ * @param file the virtual file
+ * @return spec compatible uri
+ * @throws IOException for any error
+ * @throws URISyntaxException for any uri syntax error
+ */
+ public static URI getCompatibleURI(VirtualFile file) throws IOException, URISyntaxException
+ {
+ if (file == null)
+ throw new IllegalArgumentException("Null file");
+
+ URI uri = file.toURI();
+ if (uri == null)
+ throw new IllegalArgumentException("Null uri: " + file);
+
+ // is not nested, so direct VFS URL is not an option
+ if (isNestedFile(file) == false)
+ {
+ String uriString = uri.toString();
+ if (uriString.startsWith("vfs"))
+ {
+ // treat vfszip as file
+ if (uriString.startsWith("vfszip"))
+ uri = new URI("file" + uriString.substring(6));
+ else
+ uri = new URI(uriString.substring(3)); // (vfs)file and (vfs)jar are ok
+ }
+ }
+ return uri;
+ }
}
More information about the jboss-cvs-commits
mailing list