Example usage for javax.xml.transform.stream StreamResult getSystemId

List of usage examples for javax.xml.transform.stream StreamResult getSystemId

Introduction

In this page you can find the example usage for javax.xml.transform.stream StreamResult getSystemId.

Prototype

public String getSystemId() 

Source Link

Document

Get the system identifier that was set with setSystemId.

Usage

From source file:org.apache.fop.render.intermediate.AbstractBinaryWritingIFDocumentHandler.java

/** {@inheritDoc} */
public void setResult(Result result) throws IFException {
    if (result instanceof StreamResult) {
        StreamResult streamResult = (StreamResult) result;
        OutputStream out = streamResult.getOutputStream();
        if (out == null) {
            if (streamResult.getWriter() != null) {
                throw new IllegalArgumentException("FOP cannot use a Writer. Please supply an OutputStream!");
            }//from w  w w. java 2s  .c o m
            try {
                URL url = new URL(streamResult.getSystemId());
                File f = FileUtils.toFile(url);
                if (f != null) {
                    out = new java.io.FileOutputStream(f);
                } else {
                    out = url.openConnection().getOutputStream();
                }
            } catch (IOException ioe) {
                throw new IFException("I/O error while opening output stream", ioe);
            }
            out = new java.io.BufferedOutputStream(out);
            this.ownOutputStream = true;
        }
        if (out == null) {
            throw new IllegalArgumentException("Need a StreamResult with an OutputStream");
        }
        this.outputStream = out;
    } else {
        throw new UnsupportedOperationException("Unsupported Result subclass: " + result.getClass().getName());
    }
}