com.infoengine.util
Class JarUtils

java.lang.Object
  extended bycom.infoengine.util.JarUtils

public class JarUtils
extends Object


Field Summary
private  Vector jarListeners
           
 
Constructor Summary
JarUtils()
          Create an instance of JarUtils
 
Method Summary
 void addJarListener(JarListener listener)
          Add an jarListener to be notified of jar events.
private  void fireJarEvent(String path)
           
private  void fireUnjarEvent(File f, boolean ow)
           
 void jar(File jar, File[] files)
           
 void jar(File jar, File[] files, File relativeTo)
           
 void jar(File jar, Map files)
           
private  void jar(JarOutputStream jos, File f, File relativeTo, Vector paths)
           
private  void list(File jf)
          doesn't actually unjar simply generates one unjarred event per entry in the jar
static void main(String[] args)
           
private  String normalizePath(File f, File relativeTo)
          force paths to look unix like and force / on the end of directory paths
 void removeJarListener(JarListener listener)
          Unregister a jarListener so it's no longer notified of jar events.
 File tempUnjar(File jf)
          unjars a jar to a temporary location (deleteOnExit) and returns the directory
 void unjar(File jf)
          unjar a file to the current directory
 void unjar(File jf, File dest)
          Unjars a jar to a specified location.
 void unjar(File jf, File dest, boolean deleteOnExit)
          Unjars a jar to a specified location.
 void unjar(File jf, File dest, boolean deleteOnExit, boolean overwrite)
          Unjars a jar to a specified location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jarListeners

private Vector jarListeners
Constructor Detail

JarUtils

public JarUtils()
Create an instance of JarUtils

Method Detail

addJarListener

public void addJarListener(JarListener listener)
Add an jarListener to be notified of jar events.

Parameters:
listener -

removeJarListener

public void removeJarListener(JarListener listener)
Unregister a jarListener so it's no longer notified of jar events.

Parameters:
listener -

unjar

public void unjar(File jf)
           throws IOException
unjar a file to the current directory

Parameters:
jf - the file to unjar
Throws:
IOException

tempUnjar

public File tempUnjar(File jf)
               throws IOException
unjars a jar to a temporary location (deleteOnExit) and returns the directory

Parameters:
jf - the file to unjar
Returns:
the directory the files were unjarred to
Throws:
IOException

unjar

public void unjar(File jf,
                  File dest)
           throws IOException
Unjars a jar to a specified location. Existing files will be overwritten. Unjarred files will persist after the VM has exited.

Parameters:
jf - the file to unjar
dest - the destination directory. if null the current directory.
Throws:
IOException

unjar

public void unjar(File jf,
                  File dest,
                  boolean deleteOnExit)
           throws IOException
Unjars a jar to a specified location. Existing files will be overwritten.

Parameters:
jf - the file to unjar
dest - the destination directory. if null the current directory.
deleteOnExit - should the files persist when the VM exists?
Throws:
IOException

unjar

public void unjar(File jf,
                  File dest,
                  boolean deleteOnExit,
                  boolean overwrite)
           throws IOException
Unjars a jar to a specified location.

Parameters:
jf - the file to unjar
dest - the destination directory. if null the current directory.
deleteOnExit - should the files persist when the VM exists?
overwrite - should existing files be overwritten?
Throws:
IOException

list

private void list(File jf)
           throws IOException
doesn't actually unjar simply generates one unjarred event per entry in the jar

Parameters:
jf - the jar file
Throws:
IOException

fireUnjarEvent

private void fireUnjarEvent(File f,
                            boolean ow)

jar

public void jar(File jar,
                File[] files,
                File relativeTo)
         throws IOException
Throws:
IOException

jar

public void jar(File jar,
                Map files)
         throws IOException
Parameters:
jar - - the jar file
files - - map of files, keys must be relative directories, values must be File []
Throws:
IOException

jar

public void jar(File jar,
                File[] files)
         throws IOException
Throws:
IOException

jar

private void jar(JarOutputStream jos,
                 File f,
                 File relativeTo,
                 Vector paths)
          throws IOException
Throws:
IOException

fireJarEvent

private void fireJarEvent(String path)

normalizePath

private String normalizePath(File f,
                             File relativeTo)
force paths to look unix like and force / on the end of directory paths


main

public static void main(String[] args)
                 throws Exception
Throws:
Exception