com.xmlmind.util
Class JarUtil

java.lang.Object
  extended by com.xmlmind.util.JarUtil

public final class JarUtil
extends java.lang.Object

A collection of utility functions (static methods) operating on JARs.


Method Summary
static java.net.URL[] getClassPath(java.net.URL jarURL)
          Returns the URLs of the JARs listed in the Class-Path attribute of the manifest of a JAR.
static java.lang.String getClassPathAttribute(java.net.URL jarURL)
          Returns the Class-Path attribute of the manifest of a JAR.
static java.util.Map<java.lang.String,java.lang.String[]> getServiceProviders(java.net.URL jarURL)
          Returns the service providers found in a JAR.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClassPath

public static java.net.URL[] getClassPath(java.net.URL jarURL)
                                   throws java.io.IOException
Returns the URLs of the JARs listed in the Class-Path attribute of the manifest of a JAR.

Parameters:
jarURL - the URL of the JAR
Returns:
the URLs of the JARs listed in the Class-Path attribute of the manifest or an empty array if the manifest or the Class-Path attribute were not found
Throws:
java.io.IOException - if an I/O error occurs while reading the JAR

getClassPathAttribute

public static java.lang.String getClassPathAttribute(java.net.URL jarURL)
                                              throws java.io.IOException
Returns the Class-Path attribute of the manifest of a JAR.

Parameters:
jarURL - the URL of the JAR
Returns:
the Class-Path attribute of the manifest if any; null otherwise
Throws:
java.io.IOException - if an I/O error occurs while reading the JAR

getServiceProviders

public static java.util.Map<java.lang.String,java.lang.String[]> getServiceProviders(java.net.URL jarURL)
                                                                              throws java.io.IOException
Returns the service providers found in a JAR.

Parameters:
jarURL - the URL of the JAR
Returns:
a possibly empty map where a key is the name of a service and the value is an array of names of classes implementing this service
Throws:
java.io.IOException - if an I/O error occurs while reading the JAR