StreamResultpublic class StreamResult extends Object implements ResultActs as an holder for a transformation result,
which may be XML, plain Text, HTML, or some other form of markup. |
Fields Summary |
---|
public static final String | FEATUREIf {@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 | systemIdThe 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 | outputStreamThe byte stream that is to be written to. | private Writer | writerThe 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.
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.
setWriter(writer);
| public StreamResult(String systemId)Construct a StreamResult from a URL.
this.systemId = systemId;
| public StreamResult(File f)Construct a StreamResult from a File.
setSystemId(f);
|
Methods Summary |
---|
public java.io.OutputStream | getOutputStream()Get the byte stream that was set with setOutputStream.
return outputStream;
| public java.lang.String | getSystemId()Get the system identifier that was set with setSystemId.
return systemId;
| public java.io.Writer | getWriter()Get the character stream that was set with setWriter.
return writer;
| public void | setOutputStream(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.
this.outputStream = outputStream;
| public void | setSystemId(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).
this.systemId = systemId;
| public void | setSystemId(java.io.File f)Set the system ID from a File reference.
Note the use of {@link File#toURI()} and {@link File#toURL()}.
toURI() is prefered and used if possible.
To allow JAXP 1.3 to run on J2SE 1.3, toURL()
is used if a {@link NoSuchMethodException} is thrown by the attempt
to use toURI() .
try {
// assume >= 1.4
this.systemId = f.toURI().toString();
} catch (java.lang.NoSuchMethodError nme) {
// running on J2SE 1.3?
try {
this.systemId = f.toURL().toString();
} catch (MalformedURLException malformedURLException) {
this.systemId = null;
throw new RuntimeException(
"javax.xml.transform.stream.StreamResult#setSystemId(File f) with MalformedURLException: "
+ malformedURLException.toString()
);
}
} catch (Exception exception) {
throw new RuntimeException(
"javax.xml.transform.stream.StreamResult#setSystemId(File f):"
+ " unexpected Exception: " + exception.toString()
);
}
| public void | setWriter(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.
this.writer = writer;
|
|