DataContentHandler (Java EE 5)

Java EE API


javax.activation Interface DataContentHandler


public interface DataContentHandler


DataContentHandler 接口由可用于扩展 Transferable 接口的 DataHandler 实现性能的对象来实现。通过 DataContentHandlers 可扩展该框架,使它能够将流转入对象,并能将对象写入流。

应用程序通常不直接调用 DataContentHandler 中的方法。相反,应用程序调用 DataHandler 中的等效方法。DataHandler 将使用当前 DataContentHandlerFactory 尝试找到与其 MIME 类型对应的恰当 DataContentHandler。然后,DataHandler 调用到该 DataContentHandlerthen 中的方法。

英文文档:

The DataContentHandler interface is implemented by objects that can be used to extend the capabilities of the DataHandler's implementation of the Transferable interface. Through DataContentHandlers the framework can be extended to convert streams in to objects, and to write objects to streams.

Applications don't generally call the methods in DataContentHandlers directly. Instead, an application calls the equivalent methods in DataHandler. The DataHandler will attempt to find an appropriate DataContentHandler that corresponds to its MIME type using the current DataContentHandlerFactory. The DataHandler then calls through to the methods in the DataContentHandler.


Method Summary
 Object
 Object
 DataFlavor[]
 void
 

Method Detail

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
返回一个 DataFlavor 对象数组,这些对象指示可用于提供数据的 flavor。该数组应该根据提供数据的首选项来排序(从描述最多的到描述最少的)。
return DataFlavor。
英文文档:

getTransferDataFlavors

DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).

Returns:
The DataFlavors.

public Object getTransferData(java.awt.datatransfer.DataFlavor df, DataSource ds) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
返回一个对象,该对象表示将要传输的数据。返回的对象的类是由该 flavor 的表示形式类定义的。
df 表示所请求类型的 DataFlavor。
ds 表示要转换的数据的 DataSource。
return 构造的对象
Throwsjava.awt.datatransfer.UnsupportedFlavorException: 如果处理程序不支持所请求的 flavor
Throwsjava.io.IOException: 如果数据不能被访问
英文文档:

getTransferData

Object getTransferData(DataFlavor df,
                       DataSource ds)
                       throws UnsupportedFlavorException,
                              IOException
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.

Parameters:
df - The DataFlavor representing the requested type.
ds - The DataSource representing the data to be converted.
Returns:
The constructed Object.
Throws:
UnsupportedFlavorException - if the handler doesn't support the requested flavor
IOException - if the data can't be accessed

public Object getContent(DataSource ds) throws java.io.IOException
返回一个对象,该对象表示其首选形式的数据。通常,这将是 getTransferDataFlavors 方法返回的第一个 DataFlavor 所描述的形式。
ds 表示要转换的数据的 DataSource。
return 构造的对象
Throwsjava.io.IOException: 如果数据不能被访问
英文文档:

getContent

Object getContent(DataSource ds)
                  throws IOException
Return an object representing the data in its most preferred form. Generally this will be the form described by the first DataFlavor returned by the getTransferDataFlavors method.

Parameters:
ds - The DataSource representing the data to be converted.
Returns:
The constructed Object.
Throws:
IOException - if the data can't be accessed

public void writeTo(Object obj, String mimeType, java.io.OutputStream os) throws java.io.IOException
将对象转换为指定 MIME 类型的字节流,并将其写入输出流。
obj 要转换的对象。
mimeType 所请求的结果字节流的 MIME 类型。
os 要写入转换的字节流的输出流。
Throwsjava.io.IOException: 写入流时出现错误
英文文档:

writeTo

void writeTo(Object obj,
             String mimeType,
             OutputStream os)
             throws IOException
Convert the object to a byte stream of the specified MIME type and write it to the output stream.

Parameters:
obj - The object to be converted.
mimeType - The requested MIME type of the resulting byte stream.
os - The output stream into which to write the converted byte stream.
Throws:
IOException - errors writing to the stream


Submit a bug or feature

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

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

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