org.jboss.virtual.plugins.context.jar
Class JarEntryHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
      extended by org.jboss.virtual.plugins.context.AbstractURLHandler
          extended by org.jboss.virtual.plugins.context.jar.JarEntryHandler
All Implemented Interfaces:
java.io.Serializable, StructuredVirtualFileHandler, VirtualFileHandler

public class JarEntryHandler
extends AbstractURLHandler
implements StructuredVirtualFileHandler

JarEntryHandler.

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log, vfsUrl
 
Constructor Summary
JarEntryHandler(VFSContext context, VirtualFileHandler parent, java.util.jar.JarFile jar, java.util.jar.JarEntry entry, java.lang.String entryName, java.net.URL url)
          Create a new JarHandler.
 
Method Summary
 void addChild(VirtualFileHandler child)
          Add a child to an entry
 VirtualFileHandler createChildHandler(java.lang.String name)
          TODO: synchronization on lazy entryMap creation
 VirtualFileHandler findChild(java.lang.String path)
          Find a child
 java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
protected  java.util.jar.JarEntry getEntry()
          Get the entry
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
 boolean hasBeenModified()
          Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.
protected  void initCacheLastModified()
           
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 java.io.InputStream openStream()
          Access the file contents.
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
getURL, toURI, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, close, doClose, equals, getName, getParent, getPathName, getVFSContext, getVirtualFile, hashCode, simpleFindChild, structuredFindChild, toString, toVfsUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JarEntryHandler

public JarEntryHandler(VFSContext context,
                       VirtualFileHandler parent,
                       java.util.jar.JarFile jar,
                       java.util.jar.JarEntry entry,
                       java.lang.String entryName,
                       java.net.URL url)
                throws java.io.IOException
Create a new JarHandler.

Parameters:
context - the context
parent - the parent
jar - the jar file
entry - the entry
entryName - the entry name
url - the url
Throws:
java.io.IOException - for an error accessing the file system
java.lang.IllegalArgumentException - for a null context, url, jar or entry
Method Detail

initCacheLastModified

protected void initCacheLastModified()
Overrides:
initCacheLastModified in class AbstractURLHandler

hasBeenModified

public boolean hasBeenModified()
                        throws java.io.IOException
Description copied from interface: VirtualFileHandler
Returns true if the file has been modified since this method was last called Last modified time is initialized at handler instantiation.

Specified by:
hasBeenModified in interface VirtualFileHandler
Overrides:
hasBeenModified in class AbstractVirtualFileHandler
Returns:
Throws:
java.io.IOException

addChild

public void addChild(VirtualFileHandler child)
Add a child to an entry

Parameters:
child -

getEntry

protected java.util.jar.JarEntry getEntry()
Get the entry

Returns:
the file

getLastModified

public long getLastModified()
Description copied from interface: VirtualFileHandler
When the file was last modified

Specified by:
getLastModified in interface VirtualFileHandler
Overrides:
getLastModified in class AbstractURLHandler
Returns:
the last modified time

getSize

public long getSize()
Description copied from interface: VirtualFileHandler
Get the size

Specified by:
getSize in interface VirtualFileHandler
Overrides:
getSize in class AbstractURLHandler
Returns:
the size

isLeaf

public boolean isLeaf()
Description copied from interface: VirtualFileHandler
Whether it is a simple leaf of the VFS, i.e. whether it can contain other files

Specified by:
isLeaf in interface VirtualFileHandler
Returns:
true if a simple file.

isHidden

public boolean isHidden()
Description copied from interface: VirtualFileHandler
Whether it is hidden

Specified by:
isHidden in interface VirtualFileHandler
Overrides:
isHidden in class AbstractURLHandler
Returns:
true if hidden.

getChildren

public java.util.List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                               throws java.io.IOException
Description copied from interface: VirtualFileHandler
Get the children

Specified by:
getChildren in interface VirtualFileHandler
Parameters:
ignoreErrors - whether to ignore errors
Returns:
the children
Throws:
java.io.IOException - for an error accessing the file system

findChild

public VirtualFileHandler findChild(java.lang.String path)
                             throws java.io.IOException
Description copied from interface: VirtualFileHandler
Find a child

Specified by:
findChild in interface VirtualFileHandler
Parameters:
path - the path
Returns:
the child
Throws:
java.io.IOException - for an error accessing the file system (or the child doesn't exist)

openStream

public java.io.InputStream openStream()
                               throws java.io.IOException
Description copied from interface: VirtualFileHandler
Access the file contents.

Specified by:
openStream in interface VirtualFileHandler
Overrides:
openStream in class AbstractURLHandler
Returns:
An InputStream for the file contents.
Throws:
java.io.IOException - for any problem accessing the virtual file system

createChildHandler

public VirtualFileHandler createChildHandler(java.lang.String name)
                                      throws java.io.IOException
TODO: synchronization on lazy entryMap creation

Specified by:
createChildHandler in interface StructuredVirtualFileHandler
Parameters:
name - the name
Returns:
the handler
Throws:
java.io.IOException - for any error accessing the virtual file system