[jboss-cvs] JBossAS SVN: r91505 - projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 21 15:20:42 EDT 2009
Author: alesj
Date: 2009-07-21 15:20:42 -0400 (Tue, 21 Jul 2009)
New Revision: 91505
Modified:
projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java
Log:
Add toURL/URI.
Modified: projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java
===================================================================
--- projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java 2009-07-21 17:45:37 UTC (rev 91504)
+++ projects/vfs/branches/dml-zip-rework/src/main/java/org/jboss/virtual/VirtualFile.java 2009-07-21 19:20:42 UTC (rev 91505)
@@ -21,13 +21,16 @@
*/
package org.jboss.virtual;
+import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
-import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.ArrayList;
import java.util.Set;
import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
@@ -214,7 +217,6 @@
* Get a {@code VirtualFile} which represents the parent of this instance.
*
* @return the parent or {@code null} if there is no parent
- * @throws IOException for any problem accessing the virtual file system
*/
public VirtualFile getParent()
{
@@ -348,29 +350,52 @@
*
* @param path the path
* @return the child or {@code null} if not found
- * @throws IOException for any problem accessing the VFS
* @throws IllegalArgumentException if the path is null
*/
public VirtualFile getChild(String path)
{
if (path == null)
throw new IllegalArgumentException("Null path");
+
final List<String> pathParts = PathTokenizer.getTokens(path);
VirtualFile current = this;
for (String part : pathParts)
{
- if (PathTokenizer.isCurrentToken(part)) {
- continue;
- } else if (PathTokenizer.isReverseToken(part)) {
+ if (PathTokenizer.isReverseToken(part))
+ {
final VirtualFile parent = current.parent;
current = parent == null ? current : parent;
- } else {
+ }
+ else if (PathTokenizer.isCurrentToken(part) == false)
+ {
current = new VirtualFile(vfs, part, current);
}
}
return current;
}
+ /**
+ * Get file's URL.
+ *
+ * @return the url
+ * @throws IOException for any io error
+ */
+ public URL toURL() throws IOException
+ {
+ return VFSUtils.getVirtualURL(this);
+ }
+
+ /**
+ * Get file's URI.
+ *
+ * @return the uri
+ * @throws URISyntaxException for any error
+ */
+ public URI toURI() throws URISyntaxException
+ {
+ return VFSUtils.getVirtualURI(this);
+ }
+
public String toString()
{
return "Virtual file \"" + getPathName() + "\" for " + vfs;
More information about the jboss-cvs-commits
mailing list