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 maintain Manifest entry names and their associated Attributes. There are main Manifest Attributes as well as per-entry Attributes. For information on the Manifest format, please see the Manifest format specification.

Unless otherwise noted, passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.

Since:
1.2
External Specifications
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new, empty Manifest.
    Constructs a new Manifest from the specified input stream.
    Constructs a new Manifest that is a copy of the specified Manifest.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the main Attributes as well as the entries in this Manifest.
    Returns a shallow copy of this Manifest.
    boolean
    Returns true if the specified Object is also a Manifest and has the same main Attributes and entries.
    Returns the Attributes for the specified entry name.
    Returns a Map of the entries contained in this Manifest.
    Returns the main Attributes for the Manifest.
    int
    Returns the hash code for this Manifest.
    void
    Reads the Manifest from the specified InputStream.
    void
    Writes the Manifest to the specified OutputStream.

    Methods declared in class Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    Modifier and Type
    Method
    Description
    protected void
    Deprecated, for removal: This API element is subject to removal in a future version.
    May cause performance issues, deadlocks and hangs.
    final Class<? extends Object>
    Answers the unique instance of java.lang.Class which represents the class of the receiver.
    final void
    Causes one thread which is waiting on the receiver to be made ready to run.
    final void
    Causes all threads which are waiting on the receiver to be made ready to run.
    Answers a string containing a concise, human-readable description of the receiver.
    final void
    Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated by notify or notifyAll).
    final void
    wait(long time)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
    final void
    wait(long time, int frac)
    Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated by notify or notifyAll) or the expiration of the timeout.
  • Constructor Details

    • Manifest

      public Manifest()
      Constructs a new, empty Manifest.
    • Manifest

      public Manifest(InputStream is) throws IOException
      Constructs a new Manifest from the specified input stream.
      Parameters:
      is - the input stream containing manifest data
      Throws:
      IOException - if an I/O error has occurred
    • Manifest

      public Manifest(Manifest man)
      Constructs a new Manifest that is a copy of the specified Manifest.
      Parameters:
      man - the Manifest to copy
  • Method Details

    • getMainAttributes

      public Attributes getMainAttributes()
      Returns the main Attributes for the Manifest.
      Returns:
      the main Attributes for the Manifest
    • getEntries

      public Map<String, Attributes> getEntries()
      Returns a Map of the entries contained in this Manifest. Each entry is represented by a String name (key) and associated Attributes (value). The Map permits the null key, but no entry with a null key is created by read(InputStream), nor is such an entry written by using write(OutputStream).
      Returns:
      a Map of the entries contained in this Manifest
    • getAttributes

      public Attributes getAttributes(String name)
      Returns the Attributes for the specified entry name. This method is defined as:
           return (Attributes)getEntries().get(name)
      
      Though null is a valid name, when getAttributes(null) is invoked on a Manifest obtained from a jar file, null will be returned. While jar files themselves do not allow null-named attributes, it is possible to invoke getEntries() on a Manifest, and on that result, invoke put with a null key and an arbitrary value. Subsequent invocations of getAttributes(null) will return the just-put value.

      Note that this method does not return the manifest's main attributes; see getMainAttributes().

      Parameters:
      name - entry name
      Returns:
      the Attributes for the specified entry name
    • clear

      public void clear()
      Clears the main Attributes as well as the entries in this Manifest.
    • write

      public void write(OutputStream out) throws IOException
      Writes the Manifest to the specified OutputStream. Attributes.Name.MANIFEST_VERSION must be set in MainAttributes prior to invoking this method.
      Parameters:
      out - the output stream
      Throws:
      IOException - if an I/O error has occurred
      See Also:
    • read

      public void read(InputStream is) throws IOException
      Reads the Manifest from the specified InputStream. The entry names and attributes read will be merged in with the current manifest entries.
      Parameters:
      is - the input stream
      Throws:
      IOException - if an I/O error has occurred
    • equals

      public boolean equals(Object o)
      Returns true if the specified Object is also a Manifest and has the same main Attributes and entries.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to be compared
      Returns:
      true if the specified Object is also a Manifest and has the same main Attributes and entries
      See Also:
    • hashCode

      public int hashCode()
      Returns the hash code for this Manifest.
      Overrides:
      hashCode in class Object
      Returns:
      the receiver's hash.
      See Also:
    • clone

      public Object clone()
      Returns a shallow copy of this Manifest. The shallow copy is implemented as follows:
          public Object clone() { return new Manifest(this); }
      
      Overrides:
      clone in class Object
      Returns:
      a shallow copy of this Manifest