Top Description Fields Constructors Methods
com.sun.istack

public final Class ByteArrayDataSource

extends Object
implements DataSource
Class Inheritance
All Implemented Interfaces
jakarta.activation.DataSource
Imports
jakarta.activation.DataSource, java.io.InputStream, .ByteArrayInputStream, .OutputStream

DataSource backed by a byte buffer.
Author
Kohsuke Kawaguchi

Field Summary

Modifier and TypeField and Description
private final byte[]
private final String
private final int

Constructor Summary

AccessConstructor and Description
public
ByteArrayDataSource(byte[]
input buffer - the byte array isn't being copied; used directly
buf
,
String
content type
contentType
)

public
ByteArrayDataSource(byte[]
input buffer - the byte array isn't being copied; used directly
buf
,
int
length
length
,
String
content type
contentType
)

Method Summary

Modifier and TypeMethod and Description
public String
getContentType()

Implements jakarta.activation.DataSource.getContentType.

This method returns the MIME type of the data in the form of a string.

public InputStream
getInputStream()

Implements jakarta.activation.DataSource.getInputStream.

This method returns an InputStream representing the data and throws the appropriate exception if it can not do so.

public String
getName()

Implements jakarta.activation.DataSource.getName.

Return the name of this object where the name of the object is dependant on the nature of the underlying objects.

public OutputStream
getOutputStream()

Implements jakarta.activation.DataSource.getOutputStream.

This method returns an OutputStream where the data can be written and throws the appropriate exception if it can not do so.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufback to summary
private final byte[] buf
contentTypeback to summary
private final String contentType
lenback to summary
private final int len

Constructor Detail

ByteArrayDataSourceback to summary
public ByteArrayDataSource(byte[] buf, String contentType)
Parameters
buf:byte[]

input buffer - the byte array isn't being copied; used directly

contentType:String

content type

ByteArrayDataSourceback to summary
public ByteArrayDataSource(byte[] buf, int length, String contentType)
Parameters
buf:byte[]

input buffer - the byte array isn't being copied; used directly

length:int

length

contentType:String

content type

Method Detail

getContentTypeback to summary
public String getContentType()

Implements jakarta.activation.DataSource.getContentType.

Doc from jakarta.activation.DataSource.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.

Annotations
@Override
getInputStreamback to summary
public InputStream getInputStream()

Implements jakarta.activation.DataSource.getInputStream.

Doc from jakarta.activation.DataSource.getInputStream.

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.

Annotations
@Override
getNameback to summary
public String getName()

Implements jakarta.activation.DataSource.getName.

Doc from jakarta.activation.DataSource.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.)

Annotations
@Override
getOutputStreamback to summary
public OutputStream getOutputStream()

Implements jakarta.activation.DataSource.getOutputStream.

Doc from jakarta.activation.DataSource.getOutputStream.

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.

Annotations
@Override