Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.virtual
Class VirtualFile

    java.lang.Object
      org.jboss.virtual.VirtualFile

All Implemented Interfaces:
  java.io.Serializable

Direct Known Subclasses:
  AssembledDirectory

    public class VirtualFile

extends java.lang.Object
implements java.io.Serializable

A virtual file as seen by the user

Version:
  $Revision: 44334 $
Author:
  Scott.Stark@jboss.org, adrian@jboss.org
See Also:
  Serialized Form

Constructor Summary
`VirtualFile(VirtualFileHandler handler)` Create a new VirtualFile.

Method Summary
`void` | `close()` Close the file resources (stream, etc.)
`void` | `closeStreams()` Close the streams
`boolean` | `equals(java.lang.Object obj)`
`boolean` | `exists()` Tests whether the underlying implementation file still exists.
`VirtualFile` | `findChild(java.lang.String path)` Find a child
`VirtualFileHandler` | `getHandler()` Get the virtual file handler
`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 This always uses `VisitorAttributes.RECURSE`
`java.util.List<VirtualFile>` | `getChildrenRecursively(VirtualFileFilter filter)` Get all the children recursively This always uses `VisitorAttributes.RECURSE`
`long` | `getLastModified()` When the file was last modified
`java.lang.String` | `getName()` Get the simple VF name (X.java)
`VirtualFile` | `getParent()` Get the parent
`java.lang.String` | `getPathName()` Get the VFS relative path name (org/jboss/X.java)
`long` | `getSize()` Get the size
`VFS` | `getVFS()` Get the VFS instance for this virtual file
`boolean` | `hasBeenModified()` Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.
`int` | `hashCode()`
`boolean` | `isHidden()` Whether it is hidden
`boolean` | `isLeaf()` Whether it is a simple leaf of the VFS, i.e. whether it can contain other files
`java.io.InputStream` | `openStream()` Access the file contents.
`java.lang.String` | `toString()`
`java.net.URI` | `toURI()` Get the VF URI (file://root/org/jboss/X.java)
`java.net.URL` | `toURL()` Get the VF URL (file://root/org/jboss/X.java)
`void` | `visit(VirtualFileVisitor visitor)` Visit the virtual file system

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### VirtualFile

    public VirtualFile(VirtualFileHandler handler)

  Create a new VirtualFile.

  Parameters:
    `handler` - the handler
  Throws:
    `java.lang.IllegalArgumentException` - if the handler is null

Method Detail

### getHandler

    public VirtualFileHandler getHandler()

  Get the virtual file handler

  Returns:
    the handler
  Throws:
    `java.lang.IllegalStateException` - if the file is closed

### getName

    public java.lang.String getName()

  Get the simple VF name (X.java)

  Returns:
    the simple file name
  Throws:
    `java.lang.IllegalStateException` - if the file is closed

### getPathName

    public java.lang.String getPathName()

  Get the VFS relative path name (org/jboss/X.java)

  Returns:
    the VFS relative path name
  Throws:
    `java.lang.IllegalStateException` - if the file is closed

### toURL

    public java.net.URL toURL()
                       throws java.net.MalformedURLException,
                              java.net.URISyntaxException

  Get the VF URL (file://root/org/jboss/X.java)

  Returns:
    the full URL to the VF in the VFS.
  Throws:
    `java.net.MalformedURLException` - if a url cannot be parsed
    `java.net.URISyntaxException` - if a uri cannot be parsed
    `java.lang.IllegalStateException` - if the file is closed

### toURI

    public java.net.URI toURI()
                       throws java.net.MalformedURLException,
                              java.net.URISyntaxException

  Get the VF URI (file://root/org/jboss/X.java)

  Returns:
    the full URI to the VF in the VFS.
  Throws:
    `java.net.URISyntaxException` - if a uri cannot be parsed
    `java.lang.IllegalStateException` - if the file is closed
    `java.net.MalformedURLException` - for a bad url

### getLastModified

    public long getLastModified()
                         throws java.io.IOException

  When the file was last modified

  Returns:
    the last modified time
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalStateException` - if the file is closed

### hasBeenModified

    public boolean hasBeenModified()
                            throws java.io.IOException

  Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.

  Returns:
  Throws:
    `java.io.IOException`

### getSize

    public long getSize()
                 throws java.io.IOException

  Get the size

  Returns:
    the size
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalStateException` - if the file is closed

### exists

    public boolean exists()
                   throws java.io.IOException

  Tests whether the underlying implementation file still exists.

  Returns:
    true if the file exists, false otherwise.
  Throws:
    `java.io.IOException` - - thrown on failure to detect existence.

### isLeaf

    public boolean isLeaf()
                   throws java.io.IOException

  Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

  Returns:
    true if a simple file.
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalStateException` - if the file is closed

### isHidden

    public boolean isHidden()
                     throws java.io.IOException

  Whether it is hidden

  Returns:
    true when hidden
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalStateException` - if the file is closed

### openStream

    public java.io.InputStream openStream()
                                   throws java.io.IOException

  Access the file contents.

  Returns:
    an InputStream for the file contents.
  Throws:
    `java.io.IOException` - for any error accessing the file system
    `java.lang.IllegalStateException` - if the file is closed

### closeStreams

    public void closeStreams()

  Close the streams

### close

    public void close()

  Close the file resources (stream, etc.)

### getVFS

    public VFS getVFS()

  Get the VFS instance for this virtual file

  Returns:
    the VFS
  Throws:
    `java.lang.IllegalStateException` - if the file is closed

### getParent

    public VirtualFile getParent()
                          throws java.io.IOException

  Get the parent

  Returns:
    the parent or null if there is no parent
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalStateException` - if the file is closed

### 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 file is closed

### 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 file is closed or it 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 file is closed

### 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 file is closed or it is a leaf node

### visit

    public void visit(VirtualFileVisitor visitor)
               throws java.io.IOException

  Visit the virtual file system

  Parameters:
    `visitor` - the visitor
  Throws:
    `java.io.IOException` - for any problem accessing the virtual file system
    `java.lang.IllegalArgumentException` - if the visitor is null
    `java.lang.IllegalStateException` - if the file is closed or it is a leaf node

### findChild

    public VirtualFile findChild(java.lang.String path)
                          throws java.io.IOException

  Find a child

  Parameters:
    `path` - the 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
    `java.lang.IllegalStateException` - if the file is closed or it 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD