com.springsource.util.io
Class JarTransformer

java.lang.Object
  extended by com.springsource.util.io.JarTransformer

public final class JarTransformer
extends java.lang.Object

Utility class for transforming the entries in a JAR file.

Entries cannot be added or removed only changed. Actual transformation of entries is performed by an implementation of the JarTransformer.JarTransformerCallback interface.


Nested Class Summary
static interface JarTransformer.JarTransformerCallback
          Callback interface used to transform entries in a JAR file.
 
Field Summary
private  JarTransformer.JarTransformerCallback callback
           
private static java.lang.String MANIFEST_VERSION_HEADER
           
 
Constructor Summary
JarTransformer(JarTransformer.JarTransformerCallback callback)
          Creates a new JarTransformer that uses the supplied JarTransformer.JarTransformerCallback for transformation.
 
Method Summary
private  void copy(java.io.InputStream inputStream, java.io.OutputStream outputStream)
           
private  java.io.InputStream getDefaultManifestStream()
           
 void transform(java.io.InputStream is, java.io.OutputStream stream)
          Transforms the JAR content in is and writes the results to os.
 void transform(java.io.InputStream is, java.io.OutputStream stream, boolean ensureManifestIsPresent)
          Transforms the JAR content in is and writes the results to os.
private  void transformEntry(java.io.InputStream inputStream, java.util.zip.ZipEntry entry, java.io.OutputStream os)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MANIFEST_VERSION_HEADER

private static final java.lang.String MANIFEST_VERSION_HEADER
See Also:
Constant Field Values

callback

private final JarTransformer.JarTransformerCallback callback
Constructor Detail

JarTransformer

public JarTransformer(JarTransformer.JarTransformerCallback callback)
Creates a new JarTransformer that uses the supplied JarTransformer.JarTransformerCallback for transformation.

Parameters:
callback - the JarTransformerCallback to use for entry transformation.
Method Detail

transform

public void transform(java.io.InputStream is,
                      java.io.OutputStream stream)
               throws java.io.IOException
Transforms the JAR content in is and writes the results to os.

Parameters:
is - the JAR to transform.
stream - the OutputStream to write the transformed JAR to.
Throws:
java.io.IOException - if the JAR cannot be transformed.

transform

public void transform(java.io.InputStream is,
                      java.io.OutputStream stream,
                      boolean ensureManifestIsPresent)
               throws java.io.IOException
Transforms the JAR content in is and writes the results to os.

Parameters:
is - the JAR to transform.
stream - the OutputStream to write the transformed JAR to.
ensureManifestIsPresent - if true ensures that the transformed JAR contains a manifest.
Throws:
java.io.IOException - if the JAR cannot be transformed.

getDefaultManifestStream

private java.io.InputStream getDefaultManifestStream()

transformEntry

private void transformEntry(java.io.InputStream inputStream,
                            java.util.zip.ZipEntry entry,
                            java.io.OutputStream os)
                     throws java.io.IOException
Throws:
java.io.IOException

copy

private void copy(java.io.InputStream inputStream,
                  java.io.OutputStream outputStream)
           throws java.io.IOException
Throws:
java.io.IOException