APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.transform.stream

public Class StreamResult

extends Object
implements Result
Class Inheritance
All Implemented Interfaces
javax.xml.transform.Result
Imports
javax.xml.transform.Result, java.io.File, .OutputStream, .Writer

Acts as an holder for a transformation result, which may be XML, plain Text, HTML, or some other form of markup.

Author
Jeff Suttor
Since
1.4

Field Summary

Modifier and TypeField and Description
public static final String
FEATURE

If javax.xml.transform.TransformerFactory#getFeature returns true when passed this value as an argument, the Transformer supports Result output of this type.

private OutputStream
outputStream

The byte stream that is to be written to.

private String
systemId

The systemID that may be used in association with the byte or character stream, or, if neither is set, use this value as a writeable URI (probably a file name).

private Writer
writer

The character stream that is to be written to.

Constructor Summary

AccessConstructor and Description
public
StreamResult()

Zero-argument default constructor.

public
StreamResult(OutputStream
A valid OutputStream reference.
outputStream
)

Construct a StreamResult from a byte stream.

public
StreamResult(Writer
A valid Writer reference.
writer
)

Construct a StreamResult from a character stream.

public
StreamResult(String
Must be a String that conforms to the URI syntax.
systemId
)

Construct a StreamResult from a URL.

public
StreamResult(File
Must a non-null File reference.
f
)

Construct a StreamResult from a File.

Method Summary

Modifier and TypeMethod and Description
public OutputStream

Returns:

The byte stream that was set with setOutputStream, or null if setOutputStream or the ByteStream constructor was not called.
getOutputStream
()

Get the byte stream that was set with setOutputStream.

public String

Returns:

The system identifier that was set with setSystemId, or null if setSystemId was not called.
getSystemId
()

Implements javax.xml.transform.Result.getSystemId.

Get the system identifier that was set with setSystemId.

public Writer

Returns:

The character stream that was set with setWriter, or null if setWriter or the Writer constructor was not called.
getWriter
()

Get the character stream that was set with setWriter.

public void
setOutputStream(OutputStream
A valid OutputStream reference.
outputStream
)

Set the ByteStream that is to be written to.

public void
setSystemId(String
The system identifier as a URI string.
systemId
)

Implements javax.xml.transform.Result.setSystemId.

Set the systemID that may be used in association with the byte or character stream, or, if neither is set, use this value as a writeable URI (probably a file name).

public void
setSystemId(File
Must a non-null File reference.
f
)

Set the system ID from a File reference.

public void
setWriter(Writer
A valid Writer reference.
writer
)

Set the writer that is to receive the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FEATUREback to summary
public static final String FEATURE

If javax.xml.transform.TransformerFactory#getFeature returns true when passed this value as an argument, the Transformer supports Result output of this type.

outputStreamback to summary
private OutputStream outputStream

The byte stream that is to be written to.

systemIdback to summary
private String systemId

The systemID that may be used in association with the byte or character stream, or, if neither is set, use this value as a writeable URI (probably a file name).

writerback to summary
private Writer writer

The character stream that is to be written to.

Constructor Detail

StreamResultback to summary
public StreamResult()

Zero-argument default constructor.

StreamResultback to summary
public StreamResult(OutputStream outputStream)

Construct a StreamResult from a byte stream. Normally, a stream should be used rather than a reader, so that the transformer may use instructions contained in the transformation instructions to control the encoding.

Parameters
outputStream:OutputStream

A valid OutputStream reference.

StreamResultback to summary
public StreamResult(Writer writer)

Construct a StreamResult from a character stream. Normally, a stream should be used rather than a reader, so that the transformer may use instructions contained in the transformation instructions to control the encoding. However, there are times when it is useful to write to a character stream, such as when using a StringWriter.

Parameters
writer:Writer

A valid Writer reference.

StreamResultback to summary
public StreamResult(String systemId)

Construct a StreamResult from a URL.

Parameters
systemId:String

Must be a String that conforms to the URI syntax.

StreamResultback to summary
public StreamResult(File f)

Construct a StreamResult from a File.

Parameters
f:File

Must a non-null File reference.

Method Detail

getOutputStreamback to summary
public OutputStream getOutputStream()

Get the byte stream that was set with setOutputStream.

Returns:OutputStream

The byte stream that was set with setOutputStream, or null if setOutputStream or the ByteStream constructor was not called.

getSystemIdback to summary
public String getSystemId()

Implements javax.xml.transform.Result.getSystemId.

Get the system identifier that was set with setSystemId.

Returns:String

The system identifier that was set with setSystemId, or null if setSystemId was not called.

getWriterback to summary
public Writer getWriter()

Get the character stream that was set with setWriter.

Returns:Writer

The character stream that was set with setWriter, or null if setWriter or the Writer constructor was not called.

setOutputStreamback to summary
public void setOutputStream(OutputStream outputStream)

Set the ByteStream that is to be written to. Normally, a stream should be used rather than a reader, so that the transformer may use instructions contained in the transformation instructions to control the encoding.

Parameters
outputStream:OutputStream

A valid OutputStream reference.

setSystemIdback to summary
public void setSystemId(String systemId)

Implements javax.xml.transform.Result.setSystemId.

Set the systemID that may be used in association with the byte or character stream, or, if neither is set, use this value as a writeable URI (probably a file name).

Parameters
systemId:String

The system identifier as a URI string.

setSystemIdback to summary
public void setSystemId(File f)

Set the system ID from a File reference.

Parameters
f:File

Must a non-null File reference.

setWriterback to summary
public void setWriter(Writer writer)

Set the writer that is to receive the result. Normally, a stream should be used rather than a writer, so that the transformer may use instructions contained in the transformation instructions to control the encoding. However, there are times when it is useful to write to a writer, such as when using a StringWriter.

Parameters
writer:Writer

A valid Writer reference.