org.apache.maven.jar
Class JarUtils

java.lang.Object
  extended by org.apache.maven.jar.JarUtils

public class JarUtils
extends Object

Utility class for maven-jar-plugin. Currently only used for testing the manifest created by Maven's jar:jar goal.

Version:
$Id: JarUtils.java 531612 2007-04-23 21:28:38Z ltheussl $
Author:
Lukas Theussl

Constructor Summary
JarUtils()
           
 
Method Summary
 boolean containsMainAttribute(String key)
          Checks if the current manifest contains a main attribute with the given key.
 boolean containsSection(String key)
          Checks if the current manifest contains a section with the given key.
 boolean containsSectionAttribute(String key)
          Checks if the current manifest contains a section attribute with the given key.
 void extractManifestFromFile(File manifestFile)
          Extracts the manifest from a given file.
 void extractManifestFromJar(File theJarFile)
          Extracts the manifest from the given jar file.
 String getMainAttribute(String key)
          Returns the value of the main attribute key.
 Attributes getMainAttributes()
          Returns the main attributes of the manifest as Attributes.
 Manifest getManifest()
          Gets the manifest.
 Map getManifestEntries()
          Returns a Map of manifest entries.
 String getSectionAttribute(String key)
          Returns the value of the section attribute key.
 void setManifest(Manifest mf)
          Sets the manifest.
 
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

extractManifestFromJar

public void extractManifestFromJar(File theJarFile)
                            throws IOException
Extracts the manifest from the given jar file. The manifest entries can then be retrieved via getManifestEntries() and getMainAttributes().

Parameters:
theJarFile - The jar file to extract the manifest from.
Throws:
IOException - If there is an error opening the jar file.

extractManifestFromFile

public void extractManifestFromFile(File manifestFile)
                             throws IOException
Extracts the manifest from a given file. The manifest entries can then be retrieved via getManifestEntries() and getMainAttributes().

Parameters:
manifestFile - The manifest file.
Throws:
IOException - If there is an error opening the file.

setManifest

public void setManifest(Manifest mf)
Sets the manifest.

Parameters:
mf - The new manifest.

getManifest

public Manifest getManifest()
Gets the manifest.

Returns:
The manifest.

getManifestEntries

public Map getManifestEntries()
Returns a Map of manifest entries.

Returns:
Map of manifest entries.

getMainAttributes

public Attributes getMainAttributes()
Returns the main attributes of the manifest as Attributes.

Returns:
The main attributes.

containsSection

public boolean containsSection(String key)
Checks if the current manifest contains a section with the given key.

Parameters:
key - The section name.
Returns:
true if the manifest contains a section with the given key.

getMainAttribute

public String getMainAttribute(String key)
Returns the value of the main attribute key.

Parameters:
key - The attribute name.
Returns:
The attribute value, null if the attribute is not found.

containsMainAttribute

public boolean containsMainAttribute(String key)
Checks if the current manifest contains a main attribute with the given key.

Parameters:
key - The main attribute name.
Returns:
true if the manifest contains a main attribute with the given key.

getSectionAttribute

public String getSectionAttribute(String key)
Returns the value of the section attribute key.

Parameters:
key - The attribute name.
Returns:
The attribute value, null if the attribute is not found.

containsSectionAttribute

public boolean containsSectionAttribute(String key)
Checks if the current manifest contains a section attribute with the given key.

Parameters:
key - The section attribute name.
Returns:
true if the manifest contains a section attribute with the given key.


Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.