APIdia Launch Partner
Top Fields Constructors Methods
sun.net.www.protocol.jar

pack-priv Class JarFileFactory

extends Object
implements URLJarFileCloseController
Class Inheritance
All Implemented Interfaces
sun.net.www.protocol.jar.URLJarFile.URLJarFileCloseController
Imports
java.io.IOException, .FileNotFoundException, java.net.URL, .URLConnection, java.util.HashMap, java.util.jar.JarFile, jdk.internal.util.OperatingSystem, sun.net.util.URLUtil, sun.net.www.ParseUtil

Field Summary

Modifier and TypeField and Description
private static final HashMap<String, JarFile>
private static final JarFileFactory
private static final HashMap<JarFile, URL>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
cacheIfAbsent(URL url, JarFile jarFile)

public void
close(JarFile jarFile)

Implements sun.net.www.protocol.jar.URLJarFile.URLJarFileCloseController.close.

Callback method of the URLJarFileCloseController to indicate that the JarFile is closed.

pack-priv boolean

Returns:

true if the jar file has been closed, false otherwise.
closeIfNotCached
(URL
the jar file URL
url
,
JarFile
the jar file to close
jarFile
)

Close the given jar file if it isn't present in the cache.

public JarFile
get(URL url)

pack-priv JarFile
get(URL url, boolean useCaches)

private JarFile
pack-priv URLConnection
public static JarFileFactory
pack-priv JarFile

Returns:

a new or cached jar file.
getOrCreate
(URL
the jar file url
url
,
boolean
whether the cache should be used
useCaches
)

Get or create a JarFile for the given url.

private URL
urlFor(URL url)

private String
urlKey(URL url)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileCacheback to summary
private static final HashMap<String, JarFile> fileCache
instanceback to summary
private static final JarFileFactory instance
urlCacheback to summary
private static final HashMap<JarFile, URL> urlCache

Constructor Detail

JarFileFactoryback to summary
private JarFileFactory()

Method Detail

cacheIfAbsentback to summary
pack-priv boolean cacheIfAbsent(URL url, JarFile jarFile)
closeback to summary
public void close(JarFile jarFile)

Implements sun.net.www.protocol.jar.URLJarFile.URLJarFileCloseController.close.

Callback method of the URLJarFileCloseController to indicate that the JarFile is closed. This way we can remove the JarFile from the cache

closeIfNotCachedback to summary
pack-priv boolean closeIfNotCached(URL url, JarFile jarFile) throws IOException

Close the given jar file if it isn't present in the cache. Otherwise, does nothing.

Parameters
url:URL

the jar file URL

jarFile:JarFile

the jar file to close

Returns:boolean

true if the jar file has been closed, false otherwise.

Exceptions
IOException:
if an error occurs while closing the jar file.
getback to summary
public JarFile get(URL url) throws IOException
getback to summary
pack-priv JarFile get(URL url, boolean useCaches) throws IOException
getCachedJarFileback to summary
private JarFile getCachedJarFile(URL url)
getConnectionback to summary
pack-priv URLConnection getConnection(JarFile jarFile) throws IOException
getInstanceback to summary
public static JarFileFactory getInstance()
getOrCreateback to summary
pack-priv JarFile getOrCreate(URL url, boolean useCaches) throws IOException

Get or create a JarFile for the given url. If useCaches is true, this method attempts to find a jar file in the cache, and if so, returns it. If no jar file is found in the cache, or useCaches is false, the method creates a new jar file. If the URL points to a local file, the returned jar file will not be put in the cache yet. The caller should then call cacheIfAbsent(URL, JarFile) with the returned jar file, if updating the cache is desired.

Parameters
url:URL

the jar file url

useCaches:boolean

whether the cache should be used

Returns:JarFile

a new or cached jar file.

Exceptions
IOException:
if the jar file couldn't be created
urlForback to summary
private URL urlFor(URL url) throws IOException
urlKeyback to summary
private String urlKey(URL url)