org.eclipse.gemini.blueprint.test.internal.util.jar
Class JarUtils

java.lang.Object
  extended by org.eclipse.gemini.blueprint.test.internal.util.jar.JarUtils

public abstract class JarUtils
extends Object

Utility class for Jar files. As opposed to JarCreator, this class is stateless and contains only static methods (hence the abstract qualifier).

Author:
Costin Leau

Constructor Summary
JarUtils()
           
 
Method Summary
static int createJar(Manifest manifest, Map entries, OutputStream outputStream)
          Creates a jar based on the given entries and manifest.
static String dumpJarContent(JarInputStream jis)
          Dumps the entries of a jar and return them as a String.
static String dumpJarContent(org.springframework.core.io.Resource resource)
          Dump the entries of a jar and return them as a String.
static Manifest getManifest(InputStream stream)
          Read the manifest for a given stream.
static Manifest getManifest(org.springframework.core.io.Resource resource)
          Convenience method for reading a manifest from a given resource.
static int writeToJar(org.springframework.core.io.Resource res, String entryName, JarOutputStream jarStream)
          Writes a resource content to a jar.
static int writeToJar(org.springframework.core.io.Resource res, String entryName, JarOutputStream jarStream, int bufferSize)
          Writes a resource content to a jar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarUtils

public JarUtils()
Method Detail

dumpJarContent

public static String dumpJarContent(JarInputStream jis)
Dumps the entries of a jar and return them as a String. This method can be memory expensive depending on the jar size.

Parameters:
jis -
Returns:
Throws:
Exception

dumpJarContent

public static String dumpJarContent(org.springframework.core.io.Resource resource)
Dump the entries of a jar and return them as a String. This method can be memory expensive depending on the jar size.

Parameters:
resource -
Returns:

writeToJar

public static int writeToJar(org.springframework.core.io.Resource res,
                             String entryName,
                             JarOutputStream jarStream)
                      throws IOException
Writes a resource content to a jar.

Parameters:
res -
entryName -
jarStream -
Returns:
the number of bytes written to the jar file
Throws:
Exception
IOException

writeToJar

public static int writeToJar(org.springframework.core.io.Resource res,
                             String entryName,
                             JarOutputStream jarStream,
                             int bufferSize)
                      throws IOException
Writes a resource content to a jar.

Parameters:
res -
entryName -
jarStream -
bufferSize -
Returns:
the number of bytes written to the jar file
Throws:
Exception
IOException

getManifest

public static Manifest getManifest(InputStream stream)
Read the manifest for a given stream. The stream will be wrapped in a JarInputStream and closed after the manifest was read.

Parameters:
stream -
Returns:

getManifest

public static Manifest getManifest(org.springframework.core.io.Resource resource)
Convenience method for reading a manifest from a given resource. Will assume the resource points to a jar.

Parameters:
resource -
Returns:

createJar

public static int createJar(Manifest manifest,
                            Map entries,
                            OutputStream outputStream)
                     throws IOException
Creates a jar based on the given entries and manifest. This method will always close the given output stream.

Parameters:
manifest - jar manifest
entries - map of resources keyed by the jar entry named
outputStream - output stream for writing the jar
Returns:
number of byte written to the jar
Throws:
IOException


Copyright © 2006-2012. All Rights Reserved.