Package org.apache.axiom.attachments
Class ByteArrayDataSource
- java.lang.Object
-
- org.apache.axiom.attachments.ByteArrayDataSource
-
- All Implemented Interfaces:
DataSource
,SizeAwareDataSource
public class ByteArrayDataSource extends Object implements SizeAwareDataSource
-
-
Constructor Summary
Constructors Constructor Description ByteArrayDataSource(byte[] data)
ByteArrayDataSource(byte[] data, String type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getContentType()
InputStream
getInputStream()
String
getName()
OutputStream
getOutputStream()
long
getSize()
Get the size of the data source.void
setType(String type)
-
-
-
Constructor Detail
-
ByteArrayDataSource
public ByteArrayDataSource(byte[] data, String type)
-
ByteArrayDataSource
public ByteArrayDataSource(byte[] data)
-
-
Method Detail
-
setType
public void setType(String type)
-
getContentType
public String getContentType()
- Specified by:
getContentType
in interfaceDataSource
-
getInputStream
public InputStream getInputStream() throws IOException
- Specified by:
getInputStream
in interfaceDataSource
- Throws:
IOException
-
getName
public String getName()
- Specified by:
getName
in interfaceDataSource
-
getOutputStream
public OutputStream getOutputStream() throws IOException
- Specified by:
getOutputStream
in interfaceDataSource
- Throws:
IOException
-
getSize
public long getSize()
Description copied from interface:SizeAwareDataSource
Get the size of the data source. Implementations must return the number of bytes that can be read from the input stream returned byDataSource.getInputStream()
before reaching the end of the stream. If the implementation is unable to determine the size, it must return -1.- Specified by:
getSize
in interfaceSizeAwareDataSource
- Returns:
- the size of the data source or -1 if the size is not known
-
-