Package com.bea.wli.sb.sources
Class ByteArraySource
java.lang.Object
com.bea.wli.sb.sources.ByteArraySource
- All Implemented Interfaces:
com.bea.wli.sb.sources.ContentTypeAwareSource
,Source
,Serializable
public class ByteArraySource
extends Object
implements Source, Serializable, com.bea.wli.sb.sources.ContentTypeAwareSource
A byte-stream Source whose content comes from a byte array. As
a byte-stream source, the serialization methods do not heed any
transformation options.
- See Also:
-
Field Summary
Fields inherited from interface com.bea.wli.sb.sources.Source
DEFAULT_CHARACTER_SET_ENCODING
-
Constructor Summary
ConstructorsConstructorDescriptionByteArraySource
(byte[] bytes) ByteArraySource
(byte[] bytes, int pos, int count) ByteArraySource
(byte[] bytes, int pos, int count, String contentType) ByteArraySource
(byte[] bytes, String contentType) -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getBytes()
Returns the underlying byte-array.getInputStream
(TransformOptions options) Returns streaming byte-baseed representation of the Source's content.int
size()
void
writeTo
(OutputStream out, TransformOptions options) Serializes the Source's content to a byte-based stream.
-
Constructor Details
-
ByteArraySource
public ByteArraySource(byte[] bytes) -
ByteArraySource
-
ByteArraySource
public ByteArraySource(byte[] bytes, int pos, int count) -
ByteArraySource
-
-
Method Details
-
getBytes
public byte[] getBytes()Returns the underlying byte-array. Note that this may or maynot be a copy! If the caller wishes to modify this byte-array, it should cease all further usage of thisByteArraySource
. -
size
public int size() -
getInputStream
Description copied from interface:Source
Returns streaming byte-baseed representation of the Source's content. The representation of that serialization is entirely up to the Source. Note that this method may involve an internal transformation, although it should not in any way change the underlying content.- Specified by:
getInputStream
in interfaceSource
- Parameters:
options
- Options used to affect the serialization- Returns:
- an InputStream for retrieving the serialized content
- Throws:
IOException
TransformException
-
writeTo
public void writeTo(OutputStream out, TransformOptions options) throws IOException, TransformException Description copied from interface:Source
Serializes the Source's content to a byte-based stream. The representation of that serialization is entirely up to the Source. The Source is forbidden from closing the provided OutputStream, although it is allowed to flush it. However, flushing the stream should be left to the caller, if possible.Note that this method may involve an internal transformation, although it should not in any way change the underlying content.
- Specified by:
writeTo
in interfaceSource
- Parameters:
out
- the OutputStream to which serialized content will be writtenoptions
- TransformOptions used to affect the serialization- Throws:
IOException
TransformException
-
getContentType
- Specified by:
getContentType
in interfacecom.bea.wli.sb.sources.ContentTypeAwareSource
-