public abstract class AttachmentPart extends Object
SOAPMessage对象。一个
SOAPMessage对象可能包含零个或多
AttachmentPart对象,。每个
AttachmentPart对象主要分为两个部分,具体内容和MIME标头中的应用。MIME标头包含名称/值对,可以用来识别和描述的内容。
一个AttachmentPart对象必须符合一定的标准。
Content-TypeAttachmentPart对象内容的数据类型必须与[ rfc2045 ]。下面是一个例子:一个内容类型标头内容类型:应用程序/ XML下面这行代码,这是一个
AttachmentPart ap对象,设置在前面的例子中所示的标题。AP。setmimeheader(“内容类型”、“application/xml”);
有一个 AttachmentPart对象的内容部分没有限制。内容可能是任何从一个简单的纯文本对象到一个复杂的XML文档或图像文件。
一个AttachmentPart对象与方法SOAPMessage.createAttachmentPart创建。后设置MIME标头,该AttachmentPart对象添加到创建它的方法SOAPMessage.addAttachmentPart消息。
下面的代码片段,其中m是SOAPMessage对象和contentStringl是String,创造AttachmentPart实例,一些内容和标题信息的AttachmentPart对象集,并增加了AttachmentPart对象的SOAPMessage对象。
attachmentpart AP1 = M createattachmentpart();AP1。setContent(contentstring1,“text/plain”);m.addattachmentpart(AP1);
下面的代码片段创建和加入了第二AttachmentPart实例相同的消息。jpegData是二进制字节缓冲区代表的JPEG文件。
attachmentpart AP2 = M createattachmentpart();字节[] jpegdata =…;AP2。setContent(新从字节数组读取的输入流(jpegdata)、“image/jpeg”);m.addattachmentpart(AP2);
的getContent方法从AttachmentPart对象检索和标头的内容。根据DataContentHandler对象,返回的Object可以是一个类型的java对象对应的MIME类型或InputStream包含内容为字节。
字符串内容= getcontent() AP1;java.io.inputstream内容= getcontent() AP2;方法
clearContent删除所有的内容从
AttachmentPart对象,但并不影响它的头信息。
clearcontent() AP1;
| Constructor and Description |
|---|
AttachmentPart() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
addMimeHeader(String name, String value)
增加了
AttachmentPart对象具有指定名称和值的MIME标头。
|
abstract void |
clearContent()
明确了这
AttachmentPart对象的内容。
|
abstract Iterator |
getAllMimeHeaders()
检索所有这
AttachmentPart对象的标题在
MimeHeader对象迭代器。
|
abstract InputStream |
getBase64Content()
返回一个
InputStream可获得
AttachmentPart含量为Base64编码的字符数据,该方法将base64编码和返回连接的原始字节。
|
abstract Object |
getContent()
作为一个java对象得到这个
AttachmentPart对象的内容。
|
String |
getContentId()
获取该MIME头名叫“内容身份的价值”。
|
String |
getContentLocation()
获取价值的MIME标头的名称是“内容的位置”。
|
String |
getContentType()
获取该MIME头名叫“内容类型”的价值。
|
abstract DataHandler |
getDataHandler()
获取此
AttachmentPart对象的
DataHandler对象。
|
abstract Iterator |
getMatchingMimeHeaders(String[] names)
检索匹配的名字在给定的数组对象的所有
MimeHeader。
|
abstract String[] |
getMimeHeader(String name)
获取标头了
String确定所有的值。
|
abstract Iterator |
getNonMatchingMimeHeaders(String[] names)
检索所有
MimeHeader对象的名字不在给定的数组名字匹配。
|
abstract InputStream |
getRawContent()
得到这
AttachmentPart对象的内容作为InputStream好像打了
getContent没有
DataContentHandler已经注册为本
AttachmentPart的
content-type。
|
abstract byte[] |
getRawContentBytes()
获取内容这
AttachmentPart对象作为字节数组[ ]如果一个电话就
getContent没有
DataContentHandler已注册为
content-type这
AttachmentPart。
|
abstract int |
getSize()
在这
AttachmentPart对象返回的字节数。
|
abstract void |
removeAllMimeHeaders()
删除所有的MIME标头项。
|
abstract void |
removeMimeHeader(String header)
移除给定的名称匹配所有MIME标头。
|
abstract void |
setBase64Content(InputStream content, String contentType)
设置此附件部分内容从base64源
InputStream和集包含在
contentType价值的
Content-Type标头的值,该方法先解码base64输入写产生的原始字节的依恋。
|
abstract void |
setContent(Object object, String contentType)
设置此附件部分的内容,给出
Object和设置为给定类型的
Content-Type标头的值。
|
void |
setContentId(String contentId)
设置MIME标头的名称是“具有给定值的内容ID”。
|
void |
setContentLocation(String contentLocation)
设置MIME标头的名称是“具有给定值的内容定位”。
|
void |
setContentType(String contentType)
设置MIME标头的名称是“具有给定值的内容类型”。
|
abstract void |
setDataHandler(DataHandler dataHandler)
设置给定的
DataHandler对象作为这
AttachmentPart对象的数据处理程序。
|
abstract void |
setMimeHeader(String name, String value)
更改与给定名称匹配给定值的第一头文件项,如果没有现有的标题匹配,将添加一个新的头文件。
|
abstract void |
setRawContent(InputStream content, String contentType)
集的内容本附件部分包含由
InputStream
content和集包含在
contentType价值的
Content-Type标头的值。
|
abstract void |
setRawContentBytes(byte[] content, int offset, int len, String contentType)
集的内容本附件部分包含由
byte[]阵列
content和集包含在
contentType价值的
Content-Type标头的值。
|
public abstract int getSize()
throws SOAPException
AttachmentPart对象返回的字节数。
AttachmentPart对象大小的字节或1如果大小无法确定
SOAPException如果本附件的内容被损坏,如果有例外,而试图确定尺寸。
public abstract void clearContent()
AttachmentPart对象的内容。MIME标头部分原封不动。
public abstract Object getContent() throws SOAPException
AttachmentPart对象的内容。java的返回对象的类型取决于(1)的
DataContentHandler对象,用于解释字节,(2)在给定的头
Content-Type。
对于MIME内容类型“text/plain”、“text/html”和“text/xml”的DataContentHandler对象进行转换和对应的MIME类型的java类型。其他的MIME类型,该DataContentHandler对象可以返回一个对象,InputStream包含原始字节内容数据。
一种用于兼容的实现必须为最小值,返回对应的任何内容流有text/plain Content-Type价值java.lang.String对象,对应于一个text/xml Content-Type价值内容流javax.xml.transform.stream.StreamSource对象,对应于一个image/gif或image/jpeg Content-Type价值内容流java.awt.Image对象。这些内容类型,安装DataContentHandler对象不理解的DataContentHandler对象必须返回一个与原始字节java.io.InputStream对象。
AttachmentPart对象内容的java对象
SOAPException -如果没有内容设置成这
AttachmentPart对象或者数据转换时出现错误
public abstract InputStream getRawContent() throws SOAPException
AttachmentPart对象的内容作为InputStream好像打了
getContent没有
DataContentHandler已经注册为本
AttachmentPart的
content-type。
注意,从返回的InputStream读取会导致消费数据流。它是调用者的责任,称随后的API复位前适当的输入流。如果一份原始附件的内容要求那么getRawContentBytes() API应该用来代替。
InputStream由
AttachmentPart包含原始数据可以被访问。
SOAPException -如果没有内容设置成这
AttachmentPart对象或者数据转换时出现错误。
getRawContentBytes()
public abstract byte[] getRawContentBytes()
throws SOAPException
AttachmentPart对象作为字节数组[ ]如果一个电话就
getContent没有
DataContentHandler已注册为
content-type这
AttachmentPart。
AttachmentPart
byte[]阵列。
SOAPException -如果没有内容设置成这
AttachmentPart对象或者数据转换时出现错误。
public abstract InputStream getBase64Content() throws SOAPException
InputStream可获得
AttachmentPart含量为Base64编码的字符数据,该方法将base64编码和返回连接的原始字节。
InputStream从base64编码
AttachmentPart可以读。
SOAPException -如果没有内容设置成这
AttachmentPart对象或者数据转换时出现错误。
public abstract void setContent(Object object, String contentType)
Object和设置为给定类型的
Content-Type标头的值。
Object的类型应符合给定的
Content-Type价值。这取决于
DataContentHandler对象的特定使用。
object的java对象,弥补了此附件部分的内容
contentType - MIME字符串,指定内容类型
IllegalArgumentException可能如果contentType不的内容对象的类型匹配抛出,或如果有此内容的对象没有
DataContentHandler对象
getContent()
public abstract void setRawContent(InputStream content, String contentType) throws SOAPException
InputStream
content和集包含在
contentType价值的
Content-Type标头的值。
随后调用getsize()不得内容大小的准确度量。
content -原数据添加到附件部分
contentType -设置为
Content-Type标头的值
SOAPException -如果有内容设置错误
NullPointerException -如果
content是空的
public abstract void setRawContentBytes(byte[] content,
int offset,
int len,
String contentType)
throws SOAPException
byte[]阵列
content和集包含在
contentType价值的
Content-Type标头的值。
content -原数据添加到附件部分
contentType -设置为
Content-Type标头的值
offset -
len -字节形式的内容的数量
SOAPException -如果有设定的内容或内容的一个错误是空的
public abstract void setBase64Content(InputStream content, String contentType) throws SOAPException
InputStream和集包含在
contentType价值的
Content-Type标头的值,该方法先解码base64输入写产生的原始字节的依恋。
随后调用getsize()不得内容大小的准确度量。
content的Base64编码的数据添加到附件部分
contentType -设置为
Content-Type标头的值
SOAPException -如果有内容设置错误
NullPointerException -如果
content是空的
public abstract DataHandler getDataHandler() throws SOAPException
AttachmentPart对象的
DataHandler对象。
AttachmentPart对象相关的
DataHandler对象
SOAPException -如果有这
AttachmentPart对象没有数据
public abstract void setDataHandler(DataHandler dataHandler)
DataHandler对象作为这
AttachmentPart对象的数据处理程序。通常情况下,在传入消息中,数据处理程序将自动设置。当一个消息被创建和填充的内容,在
setDataHandler方法可以用来把数据从不同的数据源的信息。
dataHandler -
DataHandler对象被设置
IllegalArgumentException -如果有指定的
DataHandler对象问题
public String getContentId()
String给出“内容身份”头或
null价值如果没有
setContentId(java.lang.String)
public String getContentLocation()
String给出“内容定位”头或
null价值如果没有
public String getContentType()
String给出“内容类型”头或
null如果没有价值
public void setContentId(String contentId)
contentId -
String赋予价值的“内容身份”头
IllegalArgumentException -如果有指定的
contentId价值问题
getContentId()
public void setContentLocation(String contentLocation)
contentLocation -
String赋予价值的“内容定位”头
IllegalArgumentException -如果有指定的内容定位问题
public void setContentType(String contentType)
contentType -
String赋予价值的“内容类型”头
IllegalArgumentException -如果有指定内容类型的问题
public abstract void removeMimeHeader(String header)
header的MIME头/要删除的字符串名称
public abstract void removeAllMimeHeaders()
public abstract String[] getMimeHeader(String name)
String确定所有的值。
name -标头的名称;例如:“内容类型”
String阵列给指定的标头的值
setMimeHeader(java.lang.String, java.lang.String)
public abstract void setMimeHeader(String name, String value)
注意RFC822头只能包含US-ASCII字符。
name -
String给出的标题名称搜索
value -
String给设置的名称相匹配的名字的标头的值
IllegalArgumentException -如果有指定的MIME标头名称或值的问题
public abstract void addMimeHeader(String name, String value)
AttachmentPart对象具有指定名称和值的MIME标头。
注意RFC822头只能包含US-ASCII字符。
name -
String给标头的名称应加
value -
String给要添加标题的价值
IllegalArgumentException -如果有指定的MIME标头名称或值的问题
public abstract Iterator getAllMimeHeaders()
AttachmentPart对象的标题在
MimeHeader对象迭代器。
Iterator对象所有的MIME标头这
AttachmentPart对象
public abstract Iterator getMatchingMimeHeaders(String[] names)
MimeHeader。
names -一个叫
String阵列(S)的MIME标头被退回
Iterator对象的名称
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.