public class JARUtils
extends java.lang.Object
Title: Framework Support Library
Description: This is a utility class that assists in all JAR related activities such as loading, reading and obtaining JAR content.
Copyright: Copyright (c) 2008
Company: StreamScape Technologies
Constructor and Description |
---|
JARUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
appendJarFileEntries(java.lang.String jarFileName,
java.util.LinkedHashMap entries) |
static void |
createNewJarFromEntriesMap(java.io.File jarFile,
java.util.LinkedHashMap entries)
Creates a JAR file from a
java.util.LinkedHashMap of artifacts. |
static void |
extractJarToDirectory(java.lang.String jarURL,
java.lang.String jarEntry,
java.lang.String outDir,
boolean keepParentDirectory)
Extract resources contained i thef jar (has to be in classpath).
|
static java.util.Vector |
getClassNamesBySuperFromJarFile(java.lang.String jarFileName,
java.lang.String superClassName)
Obtain a vector of class names that are validated as specific type.
|
static java.util.Vector |
getClassNamesFromJarFile(java.lang.String jarFileName)
This method takes a full pathed JAR File as a parameter and returns an array of
objects that are a list of Classes in the JAR file.
|
static java.lang.String[] |
getClassPath()
This method returns a list of Jar Files in the CLASSPATH of the current
Java application as full pathed file names.
|
static java.util.Vector |
getEntriesFromJarFile(java.lang.String jarFileName)
Returns a list of entry names from a JAR file.
|
static java.util.LinkedHashMap |
getEntriesMapFromJarFile(java.lang.String jarFileName)
Returns a Collection of all entries in a JAR file as
java.util.LinkedHashMap . |
public static java.util.Vector getClassNamesBySuperFromJarFile(java.lang.String jarFileName, java.lang.String superClassName) throws UtilitiesException
There are several limitations to this type on introspection. Inner classes are explicitly omitted. Furthermore, any classes that are not self contained, or those that do not provide all subordinate classes (and may thus fail to auto-instantiate) will be skipped. In this way, the method also validates at config time the 'run time' environment for a given class which must match.
jarFileName
- The name of the jar file to introspect.superClassName
- The name of the super class (parent class) without the .class extension.java.io.IOException
- If a JAR file is not found.UtilitiesException
public static java.util.Vector getClassNamesFromJarFile(java.lang.String jarFileName) throws UtilitiesException
jarFileName
- The name of the JAR file as a full path.java.io.IOException
UtilitiesException
public static java.util.Vector getEntriesFromJarFile(java.lang.String jarFileName) throws UtilitiesException
jarFileName
- String Name of the JAR fileUtilitiesException
public static java.util.LinkedHashMap getEntriesMapFromJarFile(java.lang.String jarFileName) throws UtilitiesException
java.util.LinkedHashMap
.
This is the actual contents of the JAR file, not simple refences to the entiry names. The
key represents the name of a file and it's full path. The file instance is presented as
a byte array.jarFileName
- Filejava.lang.Exception
UtilitiesException
public static void appendJarFileEntries(java.lang.String jarFileName, java.util.LinkedHashMap entries) throws java.lang.Exception
java.lang.Exception
public static void extractJarToDirectory(java.lang.String jarURL, java.lang.String jarEntry, java.lang.String outDir, boolean keepParentDirectory) throws UtilitiesException
jarURL
- Jar URL to jar libraryoutDir
- Directory to unpack JAR into.keepParentDirectory
- true - full structure of directories is kept; false - file - removed all directories, directory - started from resource pointjava.io.IOException
- if any errorUtilitiesException
public static void createNewJarFromEntriesMap(java.io.File jarFile, java.util.LinkedHashMap entries) throws UtilitiesException
java.util.LinkedHashMap
of artifacts. Artifacts may be
java.io.File
instances, byte[]
arrays or java.lang.String
.jarFile
- File The file object tha will be the taret Jar File.entries
- LinkedHashMap A Map that contains the Jar entities to be put in the file.UtilitiesException
public static java.lang.String[] getClassPath()
Copyright © 2015-2024 StreamScape Technologies. All rights reserved.