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

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.AbstractJarHandler
              extended by org.jboss.virtual.plugins.context.jar.JarEntryContents
All Implemented Interfaces:
Serializable, HierarchyVirtualFileHandler, StructuredVirtualFileHandler, VirtualFileHandler

public class JarEntryContents
extends AbstractJarHandler
implements StructuredVirtualFileHandler, HierarchyVirtualFileHandler

A nested jar contents implementation used to represent a jar within a jar.

Author:
Ales.Justin@jboss.org, Scott.Stark@jboss.org
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log
 
Method Summary
 void addChild(VirtualFileHandler child)
          Add a child to an entry
 void close()
          Close the resources
 VirtualFileHandler createChildHandler(String name)
          Create a virtual file context
 boolean delete(int gracePeriod)
          Delete the file represented by this handler.
 boolean exists()
          TODO: removing the entry/jar that resulted in this needs to be detected.
protected  VirtualFileHandler findChildHandler(String name)
          Find the handler.
 VirtualFileHandler getChild(String path)
          Get a child
 List<VirtualFileHandler> getChildren(boolean ignoreErrors)
          Get the children
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
protected  void initCacheLastModified()
           
protected  void initNestedJar()
           
protected  void internalReplaceChild(VirtualFileHandler original, VirtualFileHandler replacement)
          Replace original child with unpacked replacement.
 boolean isHidden()
          Whether it is hidden
 boolean isLeaf()
          Whether it is a simple leaf of the VFS, i.e.
 boolean isNested()
          Are we nested in some archive.
 InputStream openStream()
          Access the file contents.
 boolean removeChild(String path)
          Remove a child
 String toString()
           
 URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 
Methods inherited from class org.jboss.virtual.plugins.context.jar.AbstractJarHandler
fromURL, getEntry, getJar, getURL, handleJarFile
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractURLHandler
getURL, openConnection, openConnection, toURL
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, checkParentExists, cleanup, decrement, doClose, equals, getChildPathName, getChildVfsUrl, getLocalPathName, getLocalVFSContext, getName, getParent, getPathName, getRealURL, getReferences, getVFSContext, getVfsUrl, getVirtualFile, hasBeenModified, hashCode, increment, isArchive, isTemporary, replaceChild, setPathName, setVfsUrl, simpleFindChild, structuredFindChild, toInternalVfsUrl, toStringLocal, toVfsUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

initCacheLastModified

protected void initCacheLastModified()
Overrides:
initCacheLastModified in class AbstractURLHandler

addChild

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

Specified by:
addChild in interface HierarchyVirtualFileHandler
Parameters:
child - the child

exists

public boolean exists()
               throws IOException
TODO: removing the entry/jar that resulted in this needs to be detected.

Specified by:
exists in interface VirtualFileHandler
Overrides:
exists in class AbstractURLHandler
Returns:
true if the file exists, false otherwise.
Throws:
IOException - - thrown on failure to detect existence.
See Also:
URLConnection.getLastModified(), org.jboss.test.virtual.test.URLExistsUnitTestCase

isHidden

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

Specified by:
isHidden in interface VirtualFileHandler
Overrides:
isHidden in class AbstractURLHandler
Returns:
true if hidden.
Throws:
IOException - for any problem accessing the virtual file system

isNested

public boolean isNested()
                 throws IOException
Description copied from interface: VirtualFileHandler
Are we nested in some archive.

Specified by:
isNested in interface VirtualFileHandler
Returns:
true if this is archive entry
Throws:
IOException - for any error

getChildren

public List<VirtualFileHandler> getChildren(boolean ignoreErrors)
                                     throws 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:
IOException - for an error accessing the file system

createChildHandler

public VirtualFileHandler createChildHandler(String name)
                                      throws IOException
Description copied from interface: StructuredVirtualFileHandler
Create a virtual file context

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

getChild

public VirtualFileHandler getChild(String path)
                            throws IOException
Description copied from interface: VirtualFileHandler
Get a child

Specified by:
getChild in interface VirtualFileHandler
Parameters:
path - the path
Returns:
the child or null if not found
Throws:
IOException - for an error accessing the file system

removeChild

public boolean removeChild(String path)
Description copied from interface: VirtualFileHandler
Remove a child

Specified by:
removeChild in interface VirtualFileHandler
Parameters:
path - child name
Returns:
true if child was removed, false otherwise

findChildHandler

protected VirtualFileHandler findChildHandler(String name)
                                       throws IOException
Find the handler. TODO: synchronization on lazy entryMap creation

Parameters:
name - the path name
Returns:
handler or null is it doesn't exist
Throws:
IOException - for any error

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
Overrides:
isLeaf in class AbstractJarHandler
Returns:
true if a simple file.

delete

public boolean delete(int gracePeriod)
Description copied from class: AbstractVirtualFileHandler
Delete the file represented by this handler. File deletion is comprised of two parts:
  1. physical file deletion - performed by this method or its override
  2. removal of any child references from the parent - performed by VirtualFileHandler.removeChild(String) of the parent
This method doesn't do any physical file removal because it has no concept of underlying physical file. An implementation that does physical file removal should override this method and call super.delete() at the end.

Specified by:
delete in interface VirtualFileHandler
Overrides:
delete in class AbstractVirtualFileHandler
Parameters:
gracePeriod - max time to wait for any locks
Returns:
true if file was deleted, false otherwise

openStream

public InputStream openStream()
                       throws 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:
IOException - for any problem accessing the virtual file system

close

public void close()
Description copied from interface: VirtualFileHandler
Close the resources

Specified by:
close in interface VirtualFileHandler
Overrides:
close in class AbstractVirtualFileHandler

toURI

public URI toURI()
          throws URISyntaxException
Description copied from interface: VirtualFileHandler
Get the VF URI (file://root/org/jboss/X.java)

Specified by:
toURI in interface VirtualFileHandler
Overrides:
toURI in class AbstractURLHandler
Returns:
the full URI to the VF in the VFS.
Throws:
URISyntaxException - for an error parsing the URI

internalReplaceChild

protected void internalReplaceChild(VirtualFileHandler original,
                                    VirtualFileHandler replacement)
Description copied from class: AbstractVirtualFileHandler
Replace original child with unpacked replacement.

Overrides:
internalReplaceChild in class AbstractVirtualFileHandler
Parameters:
original - the original
replacement - the replacement

toString

public String toString()
Overrides:
toString in class AbstractVirtualFileHandler

initNestedJar

protected void initNestedJar()
                      throws IOException
Throws:
IOException


Copyright © 2009 JBoss, A division of Red Hat, Inc. All Rights Reserved.