AttachmentUnmarshaller (Java EE 5)

Java EE API


javax.xml.bind.attachment Class AttachmentUnmarshaller

java.lang.Object
  extended by javax.xml.bind.attachment.AttachmentUnmarshaller

public abstract class AttachmentUnmarshaller
extends Object


启用包含优化的二进制数据格式的根文档的 JAXB 解组。

此 API 支持 JAXB 2.0 实现与基于 MIME 的包处理器(MTOM/XOP 和 WS-I AP 1.0)之间的协作,有效地处理优化的二进制数据格式。JAXB 解组包的正文,把理解将使用的打包格式这项任务委托给实现此抽象类的基于 MIME 的包处理器。

此抽象类标识包是否需要 XOP 处理(#isXOPPackage()),并提供对使用内容 id 存储为附件的二进制内容的检索。

标识要传递给 getAttachment*(String cid) 的内容 id(即 cid)。

英文文档:

Enables JAXB unmarshalling of a root document containing optimized binary data formats.

This API enables an efficient cooperative processing of optimized binary data formats between a JAXB 2.0 implementation and MIME-based package processor (MTOM/XOP and WS-I AP 1.0). JAXB unmarshals the body of a package, delegating the understanding of the packaging format being used to a MIME-based package processor that implements this abstract class.

This abstract class identifies if a package requires XOP processing, isXOPPackage() and provides retrieval of binary content stored as attachments by content-id.

Identifying the content-id, cid, to pass to getAttachment*(String cid)

Since:
JAXB 2.0
Author:
Marc Hadley, Kohsuke Kawaguchi, Joseph Fialli
See Also:
Unmarshaller.setAttachmentUnmarshaller(AttachmentUnmarshaller), XML-binary Optimized Packaging, WS-I Attachments Profile Version 1.0., Describing Media Content of Binary Data in XML

Constructor Summary
 
Method Summary
abstract  byte[]
abstract  DataHandler
 boolean
 
Methods inherited from class java.lang.Object
 

Constructor Detail

public AttachmentUnmarshaller()
英文文档:

AttachmentUnmarshaller

public AttachmentUnmarshaller()
Method Detail

abstract public DataHandler getAttachmentAsDataHandler(String cid)

通过内容 id(即 cid)查找 MIME 内容,并作为 DataHandler 返回。

返回的 DataHandler 实例必须配置为满足以下必需的映射关系约束条件。

MIME 和 Java 类型之间的必需的映射关系
MIME 类型 Java 类型

DataHandler.getContentType() instanceof DataHandler.getContent() image/gif java.awt.Image image/jpeg java.awt.Image text/xml or application/xml javax.xml.transform.Source 注意,允许支持其他映射关系。

英文文档:

getAttachmentAsDataHandler

public abstract DataHandler getAttachmentAsDataHandler(String cid)

Lookup MIME content by content-id, cid, and return as a DataHandler.

The returned DataHandler instance must be configured to meet the following required mapping constaint.

Required Mappings between MIME and Java Types
MIME Type Java Type
DataHandler.getContentType() instanceof DataHandler.getContent()
Note that it is allowable to support additional mappings.

Parameters:
cid - It is expected to be a valid lexical form of the XML Schema xs:anyURI datatype. If isXOPPackage() ==true, it must be a valid URI per the cid: URI scheme (see RFC 2387)
Returns:
a DataHandler that represents the MIME attachment.
Throws:
IllegalArgumentException - if the attachment for the given cid is not found.

abstract public byte[] getAttachmentAsByteArray(String cid)

byte[] 形式检索由内容 id(即 cid)标识的附件。

.
cid 需要它是 XML 模式 xs:anyURI 数据类型的有效词法形式。如果 #isXOPPackage() ==true,则对于每个 cid: URI 模式,它都必须是有效的 URI(参见 RFC 2387)。
return 由 cid 所标识的附件的 byte[] 表示形式。
ThrowsIllegalArgumentException: 如果未找到给定 cid 的附件。
英文文档:

getAttachmentAsByteArray

public abstract byte[] getAttachmentAsByteArray(String cid)

Retrieve the attachment identified by content-id, cid, as a byte[]

.

Parameters:
cid - It is expected to be a valid lexical form of the XML Schema xs:anyURI datatype. If isXOPPackage() ==true, it must be a valid URI per the cid: URI scheme (see RFC 2387)
Returns:
byte[] representation of attachment identified by cid.
Throws:
IllegalArgumentException - if the attachment for the given cid is not found.

public boolean isXOPPackage()

只读属性,如果 JAXB 解组程序需要执行 XOP 处理,则返回 true。

当满足 Identifying XOP Documents 中指定的约束条件时,此方法返回 true。解组过程中此值不得更改。

return 当 MIME 上下文是一个 XOP 文档时,返回 true。
英文文档:

isXOPPackage

public boolean isXOPPackage()

Read-only property that returns true if JAXB unmarshaller needs to perform XOP processing.

This method returns true when the constraints specified in Identifying XOP Documents are met. This value must not change during the unmarshalling process.

Returns:
true when MIME context is a XOP Document.


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!