Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

oracle.ide.net
Class JarUtil

java.lang.Object
  extended by oracle.ide.net.JarUtil

public final class JarUtil
extends java.lang.Object


Method Summary
static java.lang.String getClassPath(java.io.File jarFile)
          Returns the value of the Class-Path attribute in the manifest file of the specified JAR file.
static java.lang.String getClassPath(java.net.URL jarURL)
          Returns the value of the Class-Path attribute in the manifest file of the specified JAR URL.
static java.lang.String getJarEntry(java.net.URL jarURL)
          Returns the jar entry name within the specified jar URL.
static java.net.URL getJarFileURL(java.net.URL jarURL)
          Returns the jar file part of the specified jar URL.
static JarIndex getJarIndex(java.net.URL jarURL)
          Returns the JarIndex object that represents an index of the contents of the specified jar file.
static JarIndex getJarIndex(java.net.URL jarURL, boolean full)
          Deprecated. use #getJarIndex(URL)
static ReadWriteLock getLock(java.net.URL url)
          Get the lock used to synchronize access to a JAR file across multiple threads in the calling process.
static java.lang.String getMainClass(java.io.File jarFile)
          Returns the value of the Main-Class attribute in the manifest file of the specified JAR file.
static java.lang.String getMainClass(java.net.URL jarURL)
          Returns the value of the Main-Class attribute in the manifest file of the specified JAR URL.
static java.util.jar.Manifest getManifest(java.io.File jarFile)
          Returns the manifest of the specified JAR file.
static java.util.jar.Manifest getManifest(java.net.URL jarURL)
          Returns the manifest of the specified JAR URL.
static boolean isArchive(java.lang.String pathname)
          Determine if a given URL represents an jar or zip file.
static boolean isJarURL(java.net.URL jarURL)
          Returns true if the specified URL has the "jar" protocol.
static void releaseJarIndex(java.net.URL jarURL)
          Releases the in-memory jar index corresponding to the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getJarEntry

public static java.lang.String getJarEntry(java.net.URL jarURL)
Returns the jar entry name within the specified jar URL. If the jar URL specifies no entry, then the empty string is returned. If the URL is not a jar URL, then null is returned.


getJarFileURL

public static java.net.URL getJarFileURL(java.net.URL jarURL)
Returns the jar file part of the specified jar URL. The specified URL is returned if it is not a jar URL.


getManifest

public static java.util.jar.Manifest getManifest(java.net.URL jarURL)
                                          throws java.io.IOException
Returns the manifest of the specified JAR URL.

Throws:
java.io.IOException

getManifest

public static java.util.jar.Manifest getManifest(java.io.File jarFile)
                                          throws java.io.IOException
Returns the manifest of the specified JAR file.

Throws:
java.io.IOException

getMainClass

public static java.lang.String getMainClass(java.io.File jarFile)
                                     throws java.io.IOException
Returns the value of the Main-Class attribute in the manifest file of the specified JAR file.

Throws:
java.io.IOException

getMainClass

public static java.lang.String getMainClass(java.net.URL jarURL)
                                     throws java.io.IOException
Returns the value of the Main-Class attribute in the manifest file of the specified JAR URL.

Throws:
java.io.IOException

getClassPath

public static java.lang.String getClassPath(java.io.File jarFile)
                                     throws java.io.IOException
Returns the value of the Class-Path attribute in the manifest file of the specified JAR file.

Throws:
java.io.IOException

getClassPath

public static java.lang.String getClassPath(java.net.URL jarURL)
                                     throws java.io.IOException
Returns the value of the Class-Path attribute in the manifest file of the specified JAR URL.

Throws:
java.io.IOException

isJarURL

public static boolean isJarURL(java.net.URL jarURL)
Returns true if the specified URL has the "jar" protocol. Returns false if the specified URL is null or has a protocol other than "jar". Alas, Websphere uses "wsjar" as an alias for "jar" protocol.


getJarIndex

public static JarIndex getJarIndex(java.net.URL jarURL)
                            throws java.io.IOException
Returns the JarIndex object that represents an index of the contents of the specified jar file. If the jar file does not exist or if the URL points to content that is not a a jar file, then null is returned.

This method caches its results, so that if an index is requested for the same URL more than once, the previously calculated JarIndex is returned. However, as an implementation detail, this method may use an algorithm for removing cached indexes that have not been accessed recently in order to conserve memory. The details of that algorithm, if one is implemented, are not publically documented. If a previously cached index is removed and is subsequently requested later, it is simply rebuilt.

Parameters:
jarURL - This is the URL of the jar file. If this URL has the "jar" protocol, then the jar file part of the jar URL is extracted and indexed. Otherwise, the URL is assumed to point to a jar/zip file, and that file is indexed.
Throws:
java.io.IOException

getJarIndex

@Deprecated
public static JarIndex getJarIndex(java.net.URL jarURL,
                                              boolean full)
                            throws java.io.IOException
Deprecated. use #getJarIndex(URL)

Gets the JAR index for the given URL. The full parameter indicates whether a full index is built initially. A full index takes much longer to create. If the caller just needs to check for the existance of entries in the JAR, or open input streams for entries, then a full index is not necessary. A full index is necessary for other operations, such as listing all entries in the JAR or within a directory in the JAR.

Parameters:
jarURL - the URL of the JAR file
full - whether to build a full index
Returns:
the JAR index
Throws:
java.io.IOException - if the JAR file could not be read

releaseJarIndex

public static void releaseJarIndex(java.net.URL jarURL)
Releases the in-memory jar index corresponding to the specified URL. The URL may point to the jar file itself or it may be a jar URL pointing to an entry within a jar. If the URL is null, this method has no effect.


isArchive

public static boolean isArchive(java.lang.String pathname)
Determine if a given URL represents an jar or zip file. The method does a simple check to determine if the pathname ends with .jar or .zip.


getLock

public static ReadWriteLock getLock(java.net.URL url)
Get the lock used to synchronize access to a JAR file across multiple threads in the calling process. The lock is used internally by JarIndex and URLFileSystem, but it may be necessary to acquire this lock manually in cases where the JAR file is read or written without going through those APIs. For example, using the JarFile class to read or write a JAR file would require manually acquiring this lock.

The caller must hold a strong reference to the lock while it is locked. This is necessary because locks are weakly cached.

Note that the locking mechanism provided by this method is different than native file system locking (such as that provided by FileLock), which synchronizes access to a file across different processes, but does not synchronize access to the file across threads in the same process.

Parameters:
url - the URL of the JAR file or an entry in the JAR file
Returns:
the lock for the JAR file

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.7.0)

E13403-08

Copyright © 1997, 2013, Oracle. All rights reserved.