org.jboss.virtual.plugins.context
Class AbstractURLHandler

java.lang.Object
  extended by org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
      extended by org.jboss.virtual.plugins.context.AbstractURLHandler
All Implemented Interfaces:
Serializable, VirtualFileHandler
Direct Known Subclasses:
AbstractJarHandler, FileHandler, LinkHandler, MemoryContextHandler, SynthenticDirEntryHandler

public abstract class AbstractURLHandler
extends AbstractVirtualFileHandler

URLHandler.

Version:
$Revision: 1.1 $
Author:
Adrian Brock
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
cachedLastModified, log
 
Constructor Summary
AbstractURLHandler(VFSContext context, VirtualFileHandler parent, URL url, String name)
          Create a newURLHandler.
 
Method Summary
 boolean exists()
          Basis existence on URLConnection.getLastModified() != 0.
 long getLastModified()
          When the file was last modified
 long getSize()
          Get the size
 URL getURL()
          Get the url
protected  void initCacheLastModified()
           
 boolean isHidden()
          Whether it is hidden
protected  URLConnection openConnection()
          Open connection.
protected static URLConnection openConnection(URL url)
          Open connection.
 InputStream openStream()
          Access the file contents.
 URI toURI()
          Get the VF URI (file://root/org/jboss/X.java)
 URL toURL()
          Get the VF URL (file://root/org/jboss/X.java)
 
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVirtualFileHandler
checkClosed, checkParentExists, cleanup, close, decrement, delete, doClose, equals, getChildPathName, getChildVfsUrl, getLocalPathName, getLocalVFSContext, getName, getParent, getPathName, getRealURL, getReferences, getVFSContext, getVfsUrl, getVirtualFile, hasBeenModified, hashCode, increment, internalReplaceChild, isArchive, isTemporary, replaceChild, setPathName, setVfsUrl, simpleFindChild, structuredFindChild, toInternalVfsUrl, toString, toStringLocal, toVfsUrl
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.virtual.spi.VirtualFileHandler
getChild, getChildren, isLeaf, isNested, removeChild
 

Constructor Detail

AbstractURLHandler

public AbstractURLHandler(VFSContext context,
                          VirtualFileHandler parent,
                          URL url,
                          String name)
Create a newURLHandler.

Parameters:
context - the context
parent - the parent
url - the url
name - the name
Throws:
IllegalArgumentException - for a null context, vfsPath or url
Method Detail

openConnection

protected URLConnection openConnection()
                                throws IOException
Open connection.

Returns:
url's connection
Throws:
IOException - for any error

openConnection

protected static URLConnection openConnection(URL url)
                                       throws IOException
Open connection. Set use cacheable to false, due to locking on Windows.

Parameters:
url - the url to open
Returns:
url's connection
Throws:
IOException - for any error

initCacheLastModified

protected void initCacheLastModified()

getURL

public URL getURL()
Get the url

Returns:
the url

toURL

public URL toURL()
          throws MalformedURLException,
                 URISyntaxException
Description copied from interface: VirtualFileHandler
Get the VF URL (file://root/org/jboss/X.java)

Specified by:
toURL in interface VirtualFileHandler
Overrides:
toURL in class AbstractVirtualFileHandler
Returns:
the full URL to the VF in the VFS.
Throws:
MalformedURLException - for any error
URISyntaxException - for an error parsing the URI

getLastModified

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

Returns:
the last modified time
Throws:
IOException - for any problem accessing the virtual file system

getSize

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

Returns:
the size
Throws:
IOException - for any problem accessing the virtual file system

exists

public boolean exists()
               throws IOException
Basis existence on URLConnection.getLastModified() != 0. This may not be true for all url connections.

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

Returns:
true if hidden.
Throws:
IOException - for any problem accessing the virtual file system

openStream

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

Returns:
An InputStream for the file contents.
Throws:
IOException - for any problem accessing the virtual file system

toURI

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

Returns:
the full URI to the VF in the VFS.
Throws:
URISyntaxException - for an error parsing the URI


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