org.jboss.virtual
Class VFS

java.lang.Object
  extended by org.jboss.virtual.VFS

public class VFS
extends java.lang.Object

Virtual File System

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org

Constructor Summary
VFS(VFSContext context)
          Create a new VFS.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 VirtualFile findChild(java.lang.String path)
          Find a child from the root
 VirtualFile findChildFromRoot(java.lang.String path)
          Deprecated. 
 java.util.List<VirtualFile> getChildren()
          Get the children
 java.util.List<VirtualFile> getChildren(VirtualFileFilter filter)
          Get the children
 java.util.List<VirtualFile> getChildrenRecursively()
          Get all the children recursively
 java.util.List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter)
          Get all the children recursively
 VirtualFile getRoot()
          Get the root file of this VFS
static VirtualFile getRoot(java.net.URI rootURI)
          Get the root virtual file
static VirtualFile getRoot(java.net.URL rootURL)
          Get the root virtual file
static VFS getVFS(java.net.URI rootURI)
          Get the virtual file system for a root uri
static VFS getVFS(java.net.URL rootURL)
          Get the virtual file system for a root url
static VirtualFile getVirtualFile(java.net.URI rootURI, java.lang.String name)
          Get a virtual file
static VirtualFile getVirtualFile(java.net.URL rootURL, java.lang.String name)
          Get a virtual file
 int hashCode()
           
static void init()
           
 java.lang.String toString()
           
protected  void visit(VirtualFile file, VirtualFileVisitor visitor)
          Visit the virtual file system
 void visit(VirtualFileVisitor visitor)
          Visit the virtual file system from the root
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VFS

public VFS(VFSContext context)
Create a new VFS.

Parameters:
context - the context
Throws:
java.lang.IllegalArgumentException - for a null context
Method Detail

init

public static void init()

getVFS

public static VFS getVFS(java.net.URI rootURI)
                  throws java.io.IOException
Get the virtual file system for a root uri

Parameters:
rootURI - the root URI
Returns:
the virtual file system
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL is null

getRoot

public static VirtualFile getRoot(java.net.URI rootURI)
                           throws java.io.IOException
Get the root virtual file

Parameters:
rootURI - the root uri
Returns:
the virtual file
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL

getVirtualFile

public static VirtualFile getVirtualFile(java.net.URI rootURI,
                                         java.lang.String name)
                                  throws java.io.IOException
Get a virtual file

Parameters:
rootURI - the root uri
name - the path name
Returns:
the virtual file
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL or name is null

getVFS

public static VFS getVFS(java.net.URL rootURL)
                  throws java.io.IOException
Get the virtual file system for a root url

Parameters:
rootURL - the root url
Returns:
the virtual file system
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL is null

getRoot

public static VirtualFile getRoot(java.net.URL rootURL)
                           throws java.io.IOException
Get the root virtual file

Parameters:
rootURL - the root url
Returns:
the virtual file
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL

getVirtualFile

public static VirtualFile getVirtualFile(java.net.URL rootURL,
                                         java.lang.String name)
                                  throws java.io.IOException
Get a virtual file

Parameters:
rootURL - the root url
name - the path name
Returns:
the virtual file
Throws:
java.io.IOException - if there is a problem accessing the VFS
java.lang.IllegalArgumentException - if the rootURL or name is null

getRoot

public VirtualFile getRoot()
                    throws java.io.IOException
Get the root file of this VFS

Returns:
the root
Throws:
java.io.IOException - for any problem accessing the VFS

findChild

public VirtualFile findChild(java.lang.String path)
                      throws java.io.IOException
Find a child from the root

Parameters:
path - the child path
Returns:
the child
Throws:
java.io.IOException - for any problem accessing the VFS (including the child does not exist)
java.lang.IllegalArgumentException - if the path is null

findChildFromRoot

@Deprecated
public VirtualFile findChildFromRoot(java.lang.String path)
                              throws java.io.IOException
Deprecated. 

Find a child from the root

Parameters:
path - the child path
Returns:
the child
Throws:
java.io.IOException - for any problem accessing the VFS (including the child does not exist)
java.lang.IllegalArgumentException - if the path is null

getChildren

public java.util.List<VirtualFile> getChildren()
                                        throws java.io.IOException
Get the children

Returns:
the children
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if the root is a leaf node

getChildren

public java.util.List<VirtualFile> getChildren(VirtualFileFilter filter)
                                        throws java.io.IOException
Get the children

Parameters:
filter - to filter the children
Returns:
the children
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if the root is a leaf node

getChildrenRecursively

public java.util.List<VirtualFile> getChildrenRecursively()
                                                   throws java.io.IOException
Get all the children recursively

This always uses VisitorAttributes.RECURSE

Returns:
the children
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if the root is a leaf node

getChildrenRecursively

public java.util.List<VirtualFile> getChildrenRecursively(VirtualFileFilter filter)
                                                   throws java.io.IOException
Get all the children recursively

This always uses VisitorAttributes.RECURSE

Parameters:
filter - to filter the children
Returns:
the children
Throws:
java.io.IOException - for any problem accessing the virtual file system
java.lang.IllegalStateException - if the root is a leaf node

visit

public void visit(VirtualFileVisitor visitor)
           throws java.io.IOException
Visit the virtual file system from the root

Parameters:
visitor - the visitor
Throws:
java.io.IOException - for any problem accessing the VFS
java.lang.IllegalArgumentException - if the visitor is null
java.lang.IllegalStateException - if the root is a leaf node

visit

protected void visit(VirtualFile file,
                     VirtualFileVisitor visitor)
              throws java.io.IOException
Visit the virtual file system

Parameters:
file - the file
visitor - the visitor
Throws:
java.io.IOException - for any problem accessing the VFS
java.lang.IllegalArgumentException - if the file or visitor is null
java.lang.IllegalStateException - if the root is a leaf node

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object