APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.util.jar

public Class Manifest

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.io.DataOutputStream, .FilterInputStream, .IOException, .InputStream, .OutputStream, java.util.HashMap, .Map, sun.nio.cs.UTF_8, sun.security.util.SecurityProperties

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.

Author
David Connelly
Since
1.2
External Specification
JAR File Specification
See Also
Attributes

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final Attributes
private final Map<String, Attributes>
private final JarVerifier

Constructor Summary

AccessConstructor and Description
public
Manifest()

Constructs a new, empty Manifest.

public
Manifest(InputStream
the input stream containing manifest data
is
)

Constructs a new Manifest from the specified input stream.

pack-priv
Manifest(InputStream
the input stream containing manifest data
is
,
String
the name of the corresponding jar archive if available, else null
jarFilename
)

Constructs a new Manifest from the specified input stream.

pack-priv
Manifest(JarVerifier
the JarVerifier to use if any, else null
jv
,
InputStream
the input stream containing manifest data
is
,
String
the name of the corresponding jar archive if available
jarFilename
)

Constructs a new Manifest from the specified input stream and associates it with a JarVerifier.

public
Manifest(Manifest
the Manifest to copy
man
)

Constructs a new Manifest that is a copy of the specified Manifest.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Clears the main Attributes as well as the entries in this Manifest.

public Object

Returns:

a shallow copy of this Manifest
clone
()

Overrides java.lang.Object.clone.

Returns a shallow copy of this Manifest.

public boolean

Returns:

true if the specified Object is also a Manifest and has the same main Attributes and entries
equals
(Object
the object to be compared
o
)

Overrides java.lang.Object.equals.

Returns true if the specified Object is also a Manifest and has the same main Attributes and entries.

public Attributes

Returns:

the Attributes for the specified entry name
getAttributes
(String
entry name
name
)

Returns the Attributes for the specified entry name.

public Map<String, Attributes>

Returns:

a Map of the entries contained in this Manifest
getEntries
()

Returns a Map of the entries contained in this Manifest.

pack-priv static String
getErrorPosition(String filename, final int lineNumber)

public Attributes

Returns:

the main Attributes for the Manifest
getMainAttributes
()

Returns the main Attributes for the Manifest.

pack-priv Attributes

Returns:

returns the same result as getAttributes(String)
getTrustedAttributes
(String
entry name
name
)

Returns the Attributes for the specified entry name, if trusted.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code for this Manifest.

private String
parseName(byte[] lbuf, int len)

pack-priv static void
println(OutputStream out)

Writes a line break to out.

pack-priv static void
println72(OutputStream out, String line)

Writes line to out with line breaks and continuation spaces within the limits of 72 bytes of contents per line followed by a line break.

public void
read(InputStream
the input stream
is
)

Reads the Manifest from the specified InputStream.

private void
read(InputStream is, String jarFilename)

private int
toLower(int c)

public void
write(OutputStream
the output stream
out
)

Writes the Manifest to the specified OutputStream.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

attrback to summary
private final Attributes attr
entriesback to summary
private final Map<String, Attributes> entries
jvback to summary
private final JarVerifier jv

Constructor Detail

Manifestback to summary
public Manifest()

Constructs a new, empty Manifest.

Manifestback to summary
public Manifest(InputStream is) throws IOException

Constructs a new Manifest from the specified input stream.

Parameters
is:InputStream

the input stream containing manifest data

Annotations
@SuppressWarnings:this-escape
Exceptions
IOException:
if an I/O error has occurred
Manifestback to summary
pack-priv Manifest(InputStream is, String jarFilename) throws IOException

Constructs a new Manifest from the specified input stream.

Parameters
is:InputStream

the input stream containing manifest data

jarFilename:String

the name of the corresponding jar archive if available, else null

Exceptions
IOException:
if an I/O error has occurred
Manifestback to summary
pack-priv Manifest(JarVerifier jv, InputStream is, String jarFilename) throws IOException

Constructs a new Manifest from the specified input stream and associates it with a JarVerifier.

Parameters
jv:JarVerifier

the JarVerifier to use if any, else null

is:InputStream

the input stream containing manifest data

jarFilename:String

the name of the corresponding jar archive if available

Exceptions
IOException:
if an I/O error has occurred
Manifestback to summary
public Manifest(Manifest man)

Constructs a new Manifest that is a copy of the specified Manifest.

Parameters
man:Manifest

the Manifest to copy

Method Detail

clearback to summary
public void clear()

Clears the main Attributes as well as the entries in this Manifest.

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Returns a shallow copy of this Manifest. The shallow copy is implemented as follows:

    public Object clone() { return new Manifest(this); }
Returns:Object

a shallow copy of this Manifest

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Returns true if the specified Object is also a Manifest and has the same main Attributes and entries.

Parameters
o:Object

the object to be compared

Returns:boolean

true if the specified Object is also a Manifest and has the same main Attributes and entries

getAttributesback to summary
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:String

entry name

Returns:Attributes

the Attributes for the specified entry name

getEntriesback to summary
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, nor is such an entry written by using write.

Returns:Map<String, Attributes>

a Map of the entries contained in this Manifest

getErrorPositionback to summary
pack-priv static String getErrorPosition(String filename, final int lineNumber)
getMainAttributesback to summary
public Attributes getMainAttributes()

Returns the main Attributes for the Manifest.

Returns:Attributes

the main Attributes for the Manifest

getTrustedAttributesback to summary
pack-priv Attributes getTrustedAttributes(String name)

Returns the Attributes for the specified entry name, if trusted.

Parameters
name:String

entry name

Returns:Attributes

returns the same result as getAttributes(String)

Exceptions
SecurityException:
if the associated jar is signed but this entry has been modified after signing (i.e. the section in the manifest does not exist in SF files of all signers).
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Returns the hash code for this Manifest.

parseNameback to summary
private String parseName(byte[] lbuf, int len)
printlnback to summary
pack-priv static void println(OutputStream out) throws IOException

Writes a line break to out.

println72back to summary
pack-priv static void println72(OutputStream out, String line) throws IOException

Writes line to out with line breaks and continuation spaces within the limits of 72 bytes of contents per line followed by a line break.

readback to summary
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:InputStream

the input stream

Exceptions
IOException:
if an I/O error has occurred
readback to summary
private void read(InputStream is, String jarFilename) throws IOException
toLowerback to summary
private int toLower(int c)
writeback to summary
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:OutputStream

the output stream

Exceptions
IOException:
if an I/O error has occurred
See Also
getMainAttributes
java.util.jar back to summary

pack-priv Class Manifest.FastInputStream

extends FilterInputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private byte[]
private int
private int
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream.

public void
close()

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

private void
fill()

public byte
peek()

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[] b, int off, int len)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.

public int
readLine(byte[] b, int off, int len)

public int
readLine(byte[] b)

public long
skip(long n)

Overrides java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream.

Inherited from java.io.FilterInputStream:
markmarkSupportedreadreset

Field Detail

bufback to summary
private byte[] buf
countback to summary
private int count
posback to summary
private int pos

Constructor Detail

FastInputStreamback to summary
pack-priv FastInputStream(InputStream in)
FastInputStreamback to summary
pack-priv FastInputStream(InputStream in, int size)

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.FilterInputStream.available.

Doc from java.io.FilterInputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next caller of a method for this input stream. The next caller might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.FilterInputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterInputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
fillback to summary
private void fill() throws IOException
peekback to summary
public byte peek() throws IOException
readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Exceptions
IOException:
if an I/O error occurs.
readLineback to summary
public int readLine(byte[] b, int off, int len) throws IOException
readLineback to summary
public int readLine(byte[] b) throws IOException
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.FilterInputStream.skip.

Doc from java.io.FilterInputStream.skip.

Skips over and discards n bytes of data from the input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.

Exceptions
IOException:
if in.skip(n) throws an IOException.