public class StreamSource extends Object implements SingleUseSource
writeTo() method will result in all data being consumed immediately, assuming no error occurs. The pull-based getInputStream() actually gives the underlying InputStream directly to the caller.DEFAULT_CHARACTER_SET_ENCODING| Constructor and Description |
|---|
StreamSource(InputStream inputStream) |
StreamSource(InputStream inputStream, String contentType) |
| Modifier and Type | Method and Description |
|---|---|
String |
getContentType() |
InputStream |
getInputStream(TransformOptions options)
Returns streaming byte-baseed representation of the Source's content.
|
boolean |
isConsumed()
Indicates if the Source has already been consumed
|
int |
peek(byte[] b, int off, int len)
Peek bytes from the input stream without consuming the input stream.
|
void |
writeTo(OutputStream out, TransformOptions options)
Serializes the Source's content to a byte-based stream.
|
public StreamSource(InputStream inputStream)
inputStream - A valid InputStream reference to an XML stream.public StreamSource(InputStream inputStream, String contentType)
inputStream - A valid InputStream reference to an XML stream.public String getContentType()
public InputStream getInputStream(TransformOptions options)
SourcegetInputStream in interface Sourceoptions - Options used to affect the serializationpublic void writeTo(OutputStream out, TransformOptions options) throws IOException
SourceNote that this method may involve an internal transformation, although it should not in any way change the underlying content.
writeTo in interface Sourceout - the OutputStream to which serialized content will be writtenoptions - TransformOptions used to affect the serializationIOExceptionpublic boolean isConsumed()
SingleUseSourceisConsumed in interface SingleUseSource
public int peek(byte[] b,
int off,
int len)
throws IOException
readb - bytes array to copy bytes tooff - start offset for bytes to copylen - length of bytes to copyIOException - an I/O Exception occurred