DataSource (Java EE 5)

Java EE API


javax.activation Interface DataSource

All Known Subinterfaces:
MultipartDataSource
All Known Implementing Classes:
ByteArrayDataSource, FileDataSource, MimePartDataSource, URLDataSource

public interface DataSource


DataSource 接口为 JavaBeans Activation Framework 提供任意数据集合的抽象。它提供该数据的类型,并在适当的时候以 InputStreamOutputStream 的形式提供对该数据的访问。
英文文档:

The DataSource interface provides the JavaBeans Activation Framework with an abstraction of an arbitrary collection of data. It provides a type for that data as well as access to it in the form of InputStreams and OutputStreams where appropriate.


Method Summary
 String
 InputStream
 String
 OutputStream
 

Method Detail

public java.io.InputStream getInputStream() throws java.io.IOException
此方法返回一个表示数据的 InputStream;如果无法提供,则抛出适当的异常。注意,每次调用此方法时都必须返回一个新的 InputStream 对象,并且流必须位于数据的开始位置。
return InputStream
英文文档:

getInputStream

InputStream getInputStream()
                           throws IOException
This method returns an InputStream representing the data and throws the appropriate exception if it can not do so. Note that a new InputStream object must be returned each time this method is called, and the stream must be positioned at the beginning of the data.

Returns:
an InputStream
Throws:
IOException

public java.io.OutputStream getOutputStream() throws java.io.IOException
此方法返回一个可以写入数据的 OutputStream,如果无法返回,则抛出适当的异常。注意,每次调用此方法时都必须返回一个新的 OutputStream 对象,并且流必须位于要写入数据的位置。
return OutputStream
英文文档:

getOutputStream

OutputStream getOutputStream()
                             throws IOException
This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so. Note that a new OutputStream object must be returned each time this method is called, and the stream must be positioned at the location the data is to be written.

Returns:
an OutputStream
Throws:
IOException

public String getContentType()
此方法以字符串形式返回数据的 MIME 类型。应该始终返回有效类型。如果 DataSource 实现不能确定数据类型,则建议 getContentType 返回 "application/octet-stream"。
return MIME 类型
英文文档:

getContentType

String getContentType()
This method returns the MIME type of the data in the form of a string. It should always return a valid type. It is suggested that getContentType return "application/octet-stream" if the DataSource implementation can not determine the data type.

Returns:
the MIME Type

public String getName()
返回此对象的名称,其中对象的名称依赖于底层对象的特性。封装文件的 DataSources 可以选择返回对象的文件名。(通常,这是文件名的最后部分,并不是完整路径名。)
return 对象的名称。
英文文档:

getName

String getName()
Return the name of this object where the name of the object is dependant on the nature of the underlying objects. DataSources encapsulating files may choose to return the filename of the object. (Typically this would be the last component of the filename, not an entire pathname.)

Returns:
the name of the object.


Submit a bug or feature

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

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

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