Package java.util.jar
Class Manifest
java.lang.Object
java.util.jar.Manifest
- All Implemented Interfaces:
Cloneable
public class Manifest extends Object implements Cloneable
The
Manifest class is used to obtain attribute information for a
JarFile and its entries.-
Constructor Summary
Constructors Constructor Description Manifest()Creates a newManifestinstance.Manifest(InputStream is)Creates a newManifestinstance using the attributes obtained from the input stream.Manifest(Manifest man)Creates a newManifestinstance. -
Method Summary
Modifier and Type Method Description voidclear()Resets the both the main attributes as well as the entry attributes associated with thisManifest.Objectclone()Creates a copy of thisManifest.booleanequals(Object o)Determines if the receiver is equal to the parameter object.AttributesgetAttributes(String name)Returns theAttributesassociated with the parameter entryname.Map<String,Attributes>getEntries()Returns a map containing theAttributesfor each entry in theManifest.AttributesgetMainAttributes()Returns the mainAttributesof theJarFile.inthashCode()Returns the hash code for this instance.voidread(InputStream is)Merges name/attribute pairs read from the input streamisinto this manifest.voidwrite(OutputStream os)Writes thisManifest's name/attributes pairs to the givenOutputStream.
-
Constructor Details
-
Manifest
public Manifest()Creates a newManifestinstance. -
Manifest
Creates a newManifestinstance using the attributes obtained from the input stream.- Parameters:
is-InputStreamto parse for attributes.- Throws:
IOException- if an IO error occurs while creating thisManifest
-
Manifest
Creates a newManifestinstance. The new instance will have the same attributes as those found in the parameterManifest.- Parameters:
man-Manifestinstance to obtain attributes from.
-
-
Method Details
-
clear
public void clear()Resets the both the main attributes as well as the entry attributes associated with thisManifest. -
getAttributes
Returns theAttributesassociated with the parameter entryname.- Parameters:
name- the name of the entry to obtainAttributesfrom.- Returns:
- the Attributes for the entry or
nullif the entry does not exist.
-
getEntries
Returns a map containing theAttributesfor each entry in theManifest.- Returns:
- the map of entry attributes.
-
getMainAttributes
Returns the mainAttributesof theJarFile.- Returns:
- main
Attributesassociated with the sourceJarFile.
-
clone
Creates a copy of thisManifest. The returnedManifestwill equal theManifestfrom which it was cloned. -
write
Writes thisManifest's name/attributes pairs to the givenOutputStream. TheMANIFEST_VERSIONorSIGNATURE_VERSIONattribute must be set before calling this method, or no attributes will be written.- Throws:
IOException- If an error occurs writing theManifest.
-
read
Merges name/attribute pairs read from the input streamisinto this manifest.- Parameters:
is- TheInputStreamto read from.- Throws:
IOException- If an error occurs reading the manifest.
-
hashCode
public int hashCode()Returns the hash code for this instance.- Overrides:
hashCodein classObject- Returns:
- this
Manifest's hashCode. - See Also:
Object.equals(java.lang.Object)
-
equals
Determines if the receiver is equal to the parameter object. TwoManifests are equal if they have identical main attributes as well as identical entry attributes.- Overrides:
equalsin classObject- Parameters:
o- the object to compare against.- Returns:
trueif the manifests are equal,falseotherwise- See Also:
Object.hashCode()
-