org.opensourcephysics.tools.minijar
Class MiniJar

java.lang.Object
  extended by org.opensourcephysics.tools.minijar.MiniJar

public class MiniJar
extends java.lang.Object


Constructor Summary
MiniJar()
          Empty constructor.
MiniJar(java.lang.String[] args)
          Constructor which processes a list of commands.
 
Method Summary
 void addClasspath(java.lang.String path)
          Adds a directory or compressed file for searching additional references made in the selected Java classes.
 void addDesired(java.lang.String pattern)
          Add files matching the pattern to the output.
 void addDesiredFrom(java.lang.String pattern, java.lang.String path)
          Add files matching the pattern to the output but only from the given source
 void addExclude(java.io.File compressedFile)
          Excludes from the output all files in a given ZIP or JAR file.
 void addExclude(java.lang.String pattern)
          Excludes from the output all files which match the pattern in any of the search (either -s or -c) directories.
 void addForced(java.lang.String pattern)
          Forces the output to include files that match the given pattern, even if a exclude pattern suggests to exclude them.
 void addSourcePath(java.lang.String path)
          Adds a source path, i.e.
 java.util.Set<java.lang.String> compress()
          Starts the process and creates the output file.
 java.util.Set<java.lang.String> compress(java.util.Set<PathAndFile> matches)
          Compresses a given list of matches.
static boolean compress(java.util.Set<PathAndFile> list, java.io.File target, java.util.jar.Manifest manifest)
          Compresses the list of files into a JAR or ZIP file.
static java.util.jar.Manifest createManifest(java.lang.String classpath, java.lang.String mainclass)
          Creates a Manifest for a JAR file with the given parameters
static java.util.jar.Manifest createManifest(java.lang.String classpath, java.lang.String mainclass, java.util.Set<java.lang.String> extraInfo)
          Creates a Manifest for a JAR file with the given parameters
static void freeMemory()
          Frees memory used to store the contents of directories and compressed files.
 java.util.Set<PathAndFile> getMatches()
          Creates the list of files that match the instruction set.
 java.util.Set<java.lang.String> getMissingFilesList()
          Returns the list of missing files after a match search.
static void main(java.lang.String[] args)
          Standard main program.
 void processArguments(java.lang.String[] args)
          Processes a series of arguments.
 void reset()
          Resets the object to its initial state (except for the PrintStream and the verbose condition).
 void setManifestFile(java.util.jar.Manifest manifest)
          Sets the manifest file to use for JAR files.
 void setOutputFile(java.io.File target)
          Sets the output file
 void setOutputFile(java.lang.String path)
          Sets the output file to the given path.
 void setPrintStream(java.io.PrintStream output)
          Sets the output stream for messages.
 void setVerbose(boolean verbose)
          Makes the processes to print debug information if the argument is true.
static java.lang.Object sourceFind(java.io.File source, java.lang.String filename)
          Whether the given directory or compressed (ZIP or JAR) file contains a file with that name under it (at any level)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MiniJar

public MiniJar()
Empty constructor.


MiniJar

public MiniJar(java.lang.String[] args)
Constructor which processes a list of commands.

Method Detail

main

public static void main(java.lang.String[] args)
Standard main program. Passes the arguments to an instance of MiniJar and then creates the output. It also prints the list of missing files.

Parameters:
args -

freeMemory

public static void freeMemory()
Frees memory used to store the contents of directories and compressed files.


reset

public void reset()
Resets the object to its initial state (except for the PrintStream and the verbose condition).


processArguments

public void processArguments(java.lang.String[] args)
Processes a series of arguments. Each argument (or sequence s of arguments) must be of the form: Switches are case-insensitive, arguments are not. Examples of patterns are: (Note: We don't use the standard wild char '*' because the operating system converts it before passing it to the java program.)

Parameters:
args -

setPrintStream

public void setPrintStream(java.io.PrintStream output)
Sets the output stream for messages. Default is outputStream.

Parameters:
output -

setVerbose

public void setVerbose(boolean verbose)
Makes the processes to print debug information if the argument is true. By default, the processes only prints error messages, if any.

Parameters:
verbose -

setOutputFile

public void setOutputFile(java.lang.String path)
Sets the output file to the given path.

Parameters:
path - The path for the desired compressed file, which must end with either ".zip" or ".jar".

setOutputFile

public void setOutputFile(java.io.File target)
Sets the output file

Parameters:
file - The desired output file, its name should end with either ".zip" or ".jar".

setManifestFile

public void setManifestFile(java.util.jar.Manifest manifest)
Sets the manifest file to use for JAR files.

Parameters:
manifest -
See Also:
createManifest(String, String)

addSourcePath

public void addSourcePath(java.lang.String path)
Adds a source path, i.e. a directory or compressed file where to search for files which match the given patterns. It implies addClasspath() for that directory.

Parameters:
path -

addClasspath

public void addClasspath(java.lang.String path)
Adds a directory or compressed file for searching additional references made in the selected Java classes.

Parameters:
path -

addExclude

public void addExclude(java.lang.String pattern)
Excludes from the output all files which match the pattern in any of the search (either -s or -c) directories. If the pattern is the path for a ZIP or JAR file, all files in the compressed file will be excluded.


addExclude

public void addExclude(java.io.File compressedFile)
Excludes from the output all files in a given ZIP or JAR file.


addForced

public void addForced(java.lang.String pattern)
Forces the output to include files that match the given pattern, even if a exclude pattern suggests to exclude them.

Parameters:
pattern -

addDesired

public void addDesired(java.lang.String pattern)
Add files matching the pattern to the output.

Parameters:
pattern -

addDesiredFrom

public void addDesiredFrom(java.lang.String pattern,
                           java.lang.String path)
Add files matching the pattern to the output but only from the given source

Parameters:
pattern -

compress

public java.util.Set<java.lang.String> compress()
Starts the process and creates the output file.

Returns:
a list of missing files, i.e. classes that are referenced by the classes included. Standard Java classes are not listed.

compress

public java.util.Set<java.lang.String> compress(java.util.Set<PathAndFile> matches)
Compresses a given list of matches. This allows the user to customize the list of matches.

Returns:
a list of missing files, i.e. classes that are referenced by the classes included. Standard Java classes are not listed.

getMatches

public java.util.Set<PathAndFile> getMatches()
Creates the list of files that match the instruction set.

Returns:

getMissingFilesList

public java.util.Set<java.lang.String> getMissingFilesList()
Returns the list of missing files after a match search.

Returns:

compress

public static boolean compress(java.util.Set<PathAndFile> list,
                               java.io.File target,
                               java.util.jar.Manifest manifest)
Compresses the list of files into a JAR or ZIP file. If the target file exists it will be overwritten.

Parameters:
list - List The list of s to compress
target - File The output file
manifest - Manifest The manifest (in case of a JAR file)
Returns:
boolean

sourceFind

public static java.lang.Object sourceFind(java.io.File source,
                                          java.lang.String filename)
Whether the given directory or compressed (ZIP or JAR) file contains a file with that name under it (at any level)

Parameters:
source - File The directory or compressed file
filename - String The path of the file to extract
Returns:
boolean true if there is no error and the file is there, false otherwise

createManifest

public static java.util.jar.Manifest createManifest(java.lang.String classpath,
                                                    java.lang.String mainclass)
Creates a Manifest for a JAR file with the given parameters

Parameters:
classpath - String
mainclass - String
Returns:
Manifest

createManifest

public static java.util.jar.Manifest createManifest(java.lang.String classpath,
                                                    java.lang.String mainclass,
                                                    java.util.Set<java.lang.String> extraInfo)
Creates a Manifest for a JAR file with the given parameters

Parameters:
classpath - String
mainclass - String
Returns:
Manifest