001: /*
002: * $Id: StreamResult.java,v 1.5 2001/11/02 22:07:45 db Exp $
003: * Copyright (C) 2001 Andrew Selkirk
004: * Copyright (C) 2001 David Brownell
005: *
006: * This file is part of GNU JAXP, a library.
007: *
008: * GNU JAXP is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License as published by
010: * the Free Software Foundation; either version 2 of the License, or
011: * (at your option) any later version.
012: *
013: * GNU JAXP is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: *
022: * As a special exception, if you link this library with other files to
023: * produce an executable, this library does not by itself cause the
024: * resulting executable to be covered by the GNU General Public License.
025: * This exception does not however invalidate any other reasons why the
026: * executable file might be covered by the GNU General Public License.
027: */
028: package javax.xml.transform.stream;
029:
030: import java.io.OutputStream;
031: import java.io.Writer;
032: import java.io.File;
033: import java.io.IOException;
034: import javax.xml.transform.Result;
035:
036: /**
037: * Stream Result
038: * @author Andrew Selkirk, David Brownell
039: * @version 1.0
040: */
041: public class StreamResult implements Result {
042:
043: //-------------------------------------------------------------
044: // Variables --------------------------------------------------
045: //-------------------------------------------------------------
046:
047: public static final String FEATURE = "http://javax.xml.transform.stream.StreamResult/feature";
048:
049: private String systemId = null;
050: private OutputStream outputStream = null;
051: private Writer writer = null;
052:
053: //-------------------------------------------------------------
054: // Initialization ---------------------------------------------
055: //-------------------------------------------------------------
056:
057: public StreamResult() {
058: }
059:
060: public StreamResult(OutputStream stream) {
061: this .outputStream = stream;
062: }
063:
064: public StreamResult(Writer writer) {
065: this .writer = writer;
066: }
067:
068: public StreamResult(String systemID) {
069: this .systemId = systemID;
070: }
071:
072: public StreamResult(File file) {
073: setSystemId(file);
074: }
075:
076: //-------------------------------------------------------------
077: // Methods ----------------------------------------------------
078: //-------------------------------------------------------------
079:
080: public OutputStream getOutputStream() {
081: return outputStream;
082: }
083:
084: public String getSystemId() {
085: return systemId;
086: }
087:
088: public Writer getWriter() {
089: return writer;
090: }
091:
092: public void setOutputStream(OutputStream stream) {
093: this .outputStream = stream;
094: }
095:
096: public void setWriter(Writer writer) {
097: this .writer = writer;
098: }
099:
100: public void setSystemId(File file) {
101: try {
102: this .systemId = StreamSource.fileToURL(file).toString();
103: } catch (IOException e) {
104: // can't happen
105: throw new RuntimeException(e.getMessage());
106: }
107: }
108:
109: public void setSystemId(String systemID) {
110: this.systemId = systemID;
111: }
112: }
|