Java Code Examples for javax.xml.transform.stream.StreamResult#getSystemId()

The following examples show how to use javax.xml.transform.stream.StreamResult#getSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 2
Source File: SAXWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void setOutput(StreamResult streamResult, String encoding) throws IOException {
	if (streamResult.getOutputStream() != null)
		setOutput(streamResult.getOutputStream(), encoding);
	else if (streamResult.getWriter() != null)
		setOutput(streamResult.getWriter());
	else if (streamResult.getSystemId() != null)
		setOutput(new FileOutputStream(streamResult.getSystemId()), encoding);
}
 
Example 3
Source File: XMLStreamWriterImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 4
Source File: StreamSerializer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 5
Source File: XMLStreamWriterImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 6
Source File: StreamSerializer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 7
Source File: XMLStreamWriterImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 8
Source File: StreamSerializer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 9
Source File: XMLStreamWriterImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 10
Source File: StreamSerializer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 11
Source File: XMLStreamWriterImpl.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 12
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 13
Source File: StreamSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 14
Source File: XMLStreamWriterImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 15
Source File: StreamSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 16
Source File: XMLStreamWriterImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}
 
Example 17
Source File: StreamSerializer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example 18
Source File: XMLStreamWriterImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Use a StreamResult to initialize the output for this XMLStreamWriter. Check
 * for OutputStream, Writer and then systemId, in that order.
 *
 * @param sr        StreamResult encapsulating output information
 * @param encoding  Encoding to be used except when a Writer is available
 */
public void setOutput(StreamResult sr, String encoding)
    throws IOException {

    if (sr.getOutputStream() != null) {
        setOutputUsingStream(sr.getOutputStream(), encoding);
    }
    else if (sr.getWriter() != null) {
        setOutputUsingWriter(sr.getWriter());
    }
    else if (sr.getSystemId() != null) {
        setOutputUsingStream(new FileOutputStream(sr.getSystemId()),
            encoding);
    }
}