Package org.eclipse.jetty.util.resource
Class JarFileResource
- java.lang.Object
-
- org.eclipse.jetty.util.resource.Resource
-
- org.eclipse.jetty.util.resource.URLResource
-
- org.eclipse.jetty.util.resource.JarResource
-
- org.eclipse.jetty.util.resource.JarFileResource
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,ResourceFactory
public class JarFileResource extends JarResource
-
-
Field Summary
Fields Modifier and Type Field Description private boolean_directoryprivate java.util.jar.JarEntry_entryprivate boolean_existsprivate java.io.File_fileprivate java.util.jar.JarFile_jarFileprivate java.lang.String_jarUrlprivate java.lang.String[]_listprivate java.lang.String_pathprivate static LoggerLOG-
Fields inherited from class org.eclipse.jetty.util.resource.JarResource
_jarConnection
-
Fields inherited from class org.eclipse.jetty.util.resource.URLResource
_connection, _in, _url, _urlString, _useCaches
-
Fields inherited from class org.eclipse.jetty.util.resource.Resource
__defaultUseCaches, _associate
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJarFileResource(java.net.URL url)protectedJarFileResource(java.net.URL url, boolean useCaches)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckConnection()voidclose()Release any resources held by the resource.booleanexists()Returns true if the represented resource exists.java.io.FilegetJarFile()static ResourcegetNonCachingResource(Resource resource)Take a Resource that possibly might use URLConnection caching and turn it into one that doesn't.booleanisContainedIn(Resource resource)Check if this jar:file: resource is contained in the named resource.booleanisDirectory()Returns true if the represented resource is a container/directory.longlastModified()Returns the last modified timelonglength()Return the length of the resourcejava.lang.String[]list()Returns a list of resource names contained in the given resourceprivate java.util.List<java.lang.String>listEntries()protected voidnewConnection()-
Methods inherited from class org.eclipse.jetty.util.resource.JarResource
copyTo, getFile, getInputStream, newJarResource
-
Methods inherited from class org.eclipse.jetty.util.resource.URLResource
addPath, delete, equals, getInputStream, getName, getReadableByteChannel, getURL, getUseCaches, hashCode, renameTo, toString
-
Methods inherited from class org.eclipse.jetty.util.resource.Resource
encode, finalize, getAlias, getAllResources, getAssociate, getDefaultUseCaches, getListHTML, getListHTML, getResource, getURI, getWeakETag, getWeakETag, isAlias, isContainedIn, isSame, newClassPathResource, newClassPathResource, newResource, newResource, newResource, newResource, newResource, newResource, newResource, newSystemResource, release, setAssociate, setDefaultUseCaches, toURL, writeTo
-
-
-
-
Field Detail
-
LOG
private static final Logger LOG
-
_jarFile
private java.util.jar.JarFile _jarFile
-
_file
private java.io.File _file
-
_list
private java.lang.String[] _list
-
_entry
private java.util.jar.JarEntry _entry
-
_directory
private boolean _directory
-
_jarUrl
private java.lang.String _jarUrl
-
_path
private java.lang.String _path
-
_exists
private boolean _exists
-
-
Method Detail
-
close
public void close()
Description copied from class:URLResourceRelease any resources held by the resource.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classJarResource
-
checkConnection
protected boolean checkConnection()
- Overrides:
checkConnectionin classJarResource
-
newConnection
protected void newConnection() throws java.io.IOException- Overrides:
newConnectionin classJarResource- Throws:
java.io.IOException- Sub-classes ofJarResourcemay throw an IOException (or subclass)
-
exists
public boolean exists()
Returns true if the represented resource exists.- Overrides:
existsin classJarResource- Returns:
- true if the represented resource exists.
-
isDirectory
public boolean isDirectory()
Returns true if the represented resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.- Overrides:
isDirectoryin classURLResource- Returns:
- true if the represented resource is a container/directory. if the resource is not a file, resources ending with "/" are considered directories.
-
lastModified
public long lastModified()
Returns the last modified time- Overrides:
lastModifiedin classURLResource- Returns:
- the last modified time as milliseconds since unix epoch
-
list
public java.lang.String[] list()
Description copied from class:URLResourceReturns a list of resource names contained in the given resource- Overrides:
listin classURLResource- Returns:
- a list of resource names contained in the given resource, or null. Note: The resource names are not URL encoded.
-
listEntries
private java.util.List<java.lang.String> listEntries()
-
length
public long length()
Return the length of the resource- Overrides:
lengthin classURLResource- Returns:
- the length of the resource
-
getNonCachingResource
public static Resource getNonCachingResource(Resource resource)
Take a Resource that possibly might use URLConnection caching and turn it into one that doesn't.- Parameters:
resource- the JarFileResource to obtain without URLConnection caching.- Returns:
- the non-caching resource
-
isContainedIn
public boolean isContainedIn(Resource resource) throws java.net.MalformedURLException
Check if this jar:file: resource is contained in the named resource. Egjar:file:///a/b/c/foo.jar!/x.htmlisContainedInfile:///a/b/c/foo.jar- Overrides:
isContainedInin classURLResource- Parameters:
resource- the resource to test for- Returns:
- true if resource is contained in the named resource
- Throws:
java.net.MalformedURLException- if unable to process is contained due to invalid URL format
-
getJarFile
public java.io.File getJarFile()
-
-