JavaTM Platform
Standard Ed. 6

java.util.jar
类 Manifest

java.lang.Object
  继承者 java.util.jar.Manifest
所有已实现的接口:
Cloneable

public class Manifest
extends Object
implements Cloneable

Manifest 类用于维护 Manifest 条目名称及其相关的 Attributes。既有主 Manifest 的 Attributes,也有每个条目的 Attributes。有关 Manifest 格式的信息,请参阅 Manifest 格式规范

从以下版本开始:
1.2
另请参见:
Attributes

构造方法摘要
Manifest()
          构造新的空 Manifest。
Manifest(InputStream is)
          从指定的输入流构造新的 Manifest。
Manifest(Manifest man)
          构造新的 Manifest,它是指定 Manifest 的副本。
 
方法摘要
 void clear()
          清除此 Manifest 中的主 Attributes 和条目。
 Object clone()
          返回 Manifest 的浅表副本。
 boolean equals(Object o)
          如果指定的 Object 也是一个 Manifest,并且具有相同的主 Attributes 和条目,则返回 true。
 Attributes getAttributes(String name)
          返回指定条目名称的 Attributes。
 Map<String,Attributes> getEntries()
          返回此 Manifest 中所包含条目的 Map。
 Attributes getMainAttributes()
          返回 Manifest 的主 Attributes。
 int hashCode()
          返回 Manifest 的哈希码。
 void read(InputStream is)
          从指定的 InputStream 读取 Manifest。
 void write(OutputStream out)
          将 Manifest 写入指定的 OutputStream。
 
从类 java.lang.Object 继承的方法
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

Manifest

public Manifest()
构造新的空 Manifest。


Manifest

public Manifest(InputStream is)
         throws IOException
从指定的输入流构造新的 Manifest。

参数:
is - 包含清单数据的输入流
抛出:
IOException - 如果发生 I/O 错误

Manifest

public Manifest(Manifest man)
构造新的 Manifest,它是指定 Manifest 的副本。

参数:
man - 要复制的 Manifest
方法详细信息

getMainAttributes

public Attributes getMainAttributes()
返回 Manifest 的主 Attributes。

返回:
Manifest 的主 Attributes

getEntries

public Map<String,Attributes> getEntries()
返回此 Manifest 中所包含条目的 Map。每个条目由一个 String 名称(键)和相关的 Attributes(值)表示。Map 允许 null 键,但 read(java.io.InputStream) 并不创建带有 null 键的条目,也不创建使用 write(java.io.OutputStream) 编写的条目。

返回:
此 Manifest 中所包含条目的 Map

getAttributes

public Attributes getAttributes(String name)
返回指定条目名称的 Attributes。此方法定义为:
            return (Attributes)getEntries().get(name)
 
虽然 null 是有效的 name,当在 Manifest(从 jar 文件中获得)上调用 getAttributes(null) 时,将返回 null。尽管 jar 文件自身并不允许 null 命名的属性,则可以在 Manifest 上调用 getEntries(),然后在其结果之上调用带有 null 键和任意值的 putgetAttributes(null) 的后续调用将返回刚刚用 put 操作放入的值。

注意此方法不返回清单的主要属性;请参阅 getMainAttributes()

参数:
name - 条目名称。
返回:
指定条目名称的 Attributes

clear

public void clear()
清除此 Manifest 中的主 Attributes 和条目。


write

public void write(OutputStream out)
           throws IOException
将 Manifest 写入指定的 OutputStream。在调用此方法前,必须在 MainAttributes 中设置 Attributes.Name.MANIFEST_VERSION。

参数:
out - 输出流。
抛出:
IOException - 如果发生 I/O 错误。
另请参见:
getMainAttributes()

read

public void read(InputStream is)
          throws IOException
从指定的 InputStream 读取 Manifest。读取的条目名称和属性将与当前的清单条目进行合并。

参数:
is - 输入流。
抛出:
IOException - 如果发生 I/O 错误

equals

public boolean equals(Object o)
如果指定的 Object 也是一个 Manifest,并且具有相同的主 Attributes 和条目,则返回 true。

覆盖:
Object 中的 equals
参数:
o - 要进行比较的对象
返回:
如果指定的 Object 也是一个 Manifest,并且具有相同的主 Attributes 和条目,则返回 true
另请参见:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
返回 Manifest 的哈希码。

覆盖:
Object 中的 hashCode
返回:
此对象的一个哈希码值。
另请参见:
Object.equals(java.lang.Object), Hashtable

clone

public Object clone()
返回 Manifest 的浅表副本。浅表副本的实现方式如下:
     public Object clone() { return new Manifest(this); }
 

覆盖:
Object 中的 clone
返回:
Manifest 的浅表副本
另请参见:
Cloneable

JavaTM Platform
Standard Ed. 6

提交错误或意见
有关更多的 API 参考资料和开发人员文档,请参阅 Java SE 开发人员文档。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策