FileDocCategorySizeDatePackage
StreamResult.javaAPI DocJava SE 6 API6461Tue Jun 10 00:27:14 BST 2008javax.xml.transform.stream

StreamResult

public class StreamResult extends Object implements Result

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

author
Jeff Suttor

Fields Summary
public static final String
FEATURE
If {@link javax.xml.transform.TransformerFactory#getFeature} returns true when passed this value as an argument, the Transformer supports Result output of this type.
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 OutputStream
outputStream
The byte stream that is to be written to.
private Writer
writer
The character stream that is to be written to.
Constructors Summary
public StreamResult()
Zero-argument default constructor.


            
      
    
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.

param
outputStream A valid OutputStream reference.

        setOutputStream(outputStream);
    
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.

param
writer A valid Writer reference.

        setWriter(writer);
    
public StreamResult(String systemId)
Construct a StreamResult from a URL.

param
systemId Must be a String that conforms to the URI syntax.

        this.systemId = systemId;
    
public StreamResult(File f)
Construct a StreamResult from a File.

param
f Must a non-null File reference.

        //convert file to appropriate URI, f.toURI().toASCIIString() 
        //converts the URI to string as per rule specified in
        //RFC 2396,
        setSystemId(f.toURI().toASCIIString());
    
Methods Summary
public java.io.OutputStreamgetOutputStream()
Get the byte stream that was set with setOutputStream.

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

        return outputStream;
    
public java.lang.StringgetSystemId()
Get the system identifier that was set with setSystemId.

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

        return systemId;
    
public java.io.WritergetWriter()
Get the character stream that was set with setWriter.

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

        return writer;
    
public voidsetOutputStream(java.io.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.

param
outputStream A valid OutputStream reference.

        this.outputStream = outputStream;
    
public voidsetSystemId(java.lang.String systemId)
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).

param
systemId The system identifier as a URI string.

        this.systemId = systemId;
    
public voidsetSystemId(java.io.File f)

Set the system ID from a File reference.

param
f Must a non-null File reference.

    	//convert file to appropriate URI, f.toURI().toASCIIString() 
        //converts the URI to string as per rule specified in
        //RFC 2396,
        this.systemId = f.toURI().toASCIIString();
    
public voidsetWriter(java.io.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.

param
writer A valid Writer reference.

        this.writer = writer;