Skip to content

Commit

Permalink
Added getCompatibleURI() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Marko Strukelj committed Jul 29, 2008
1 parent 8b66389 commit eec1ca2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/org/jboss/virtual/VFSUtils.java
Expand Up @@ -732,4 +732,37 @@ public static URL getCompatibleURL(VirtualFile file) throws IOException, URISynt
}
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;
}
}

0 comments on commit eec1ca2

Please sign in to comment.