1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001, 2002,2004 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.dom;
  22 
  23 import org.w3c.dom.ls.LSOutput;
  24 
  25 import java.io.Writer;
  26 import java.io.OutputStream;
  27 
  28 /**
  29  * This class represents an output destination for data.
  30  * This interface allows an application to encapsulate information about an
  31  * output destination in a single object, which may include a URI, a byte stream
  32  * (possibly with a specifiedencoding), a base URI, and/or a character stream.
  33  * The exact definitions of a byte stream and a character stream are binding
  34  * dependent.
  35  * The application is expected to provide objects that implement this interface
  36  * whenever such objects are needed. The application can either provide its
  37  * own objects that implement this interface, or it can use the generic factory
  38  * method DOMImplementationLS.createLSOutput() to create objects that
  39  * implement this interface.
  40  * The DOMSerializer will use the LSOutput object to determine where to
  41  * serialize the output to. The DOMSerializer will look at the different
  42  * outputs specified in the LSOutput in the following order to know which one
  43  * to output to, the first one that data can be output to will be used:
  44  * 1.LSOutput.characterStream
  45  * 2.LSOutput.byteStream
  46  * 3.LSOutput.systemId
  47  * LSOutput objects belong to the application. The DOM implementation will
  48  * never modify them (though it may make copies and modify the copies,
  49  * if necessary).
  50  *
  51  * @xerces.internal
  52  *
  53  * @author Arun Yadav, Sun Microsytems
  54  * @author Gopal Sharma, Sun Microsystems
  55  **/
  56 
  57 public class DOMOutputImpl implements LSOutput {
  58 
  59         protected Writer fCharStream = null;
  60         protected OutputStream fByteStream = null;
  61         protected String fSystemId = null;
  62         protected String fEncoding = null;
  63 
  64    /**
  65     * Default Constructor
  66     */
  67     public DOMOutputImpl() {}
  68 
  69    /**
  70     * An attribute of a language and binding dependent type that represents a
  71     * writable stream of bytes. If the application knows the character encoding
  72     * of the byte stream, it should set the encoding attribute. Setting the
  73     * encoding in this way will override any encoding specified in an XML
  74     * declaration in the data.
  75     */
  76 
  77     public Writer getCharacterStream(){
  78         return fCharStream;
  79      };
  80 
  81    /**
  82     * An attribute of a language and binding dependent type that represents a
  83     * writable stream of bytes. If the application knows the character encoding
  84     * of the byte stream, it should set the encoding attribute. Setting the
  85     * encoding in this way will override any encoding specified in an XML
  86     * declaration in the data.
  87     */
  88 
  89     public void setCharacterStream(Writer characterStream){
  90         fCharStream = characterStream;
  91     };
  92 
  93    /**
  94     * Depending on the language binding in use, this attribute may not be
  95     * available. An attribute of a language and binding dependent type that
  96     * represents a writable stream to which 16-bit units can be output. The
  97     * application must encode the stream using UTF-16 (defined in [Unicode] and
  98     *  Amendment 1 of [ISO/IEC 10646]).
  99     */
 100 
 101     public OutputStream getByteStream(){
 102         return fByteStream;
 103     };
 104 
 105    /**
 106     * Depending on the language binding in use, this attribute may not be
 107     * available. An attribute of a language and binding dependent type that
 108     * represents a writable stream to which 16-bit units can be output. The
 109     * application must encode the stream using UTF-16 (defined in [Unicode] and
 110     *  Amendment 1 of [ISO/IEC 10646]).
 111     */
 112 
 113     public void setByteStream(OutputStream byteStream){
 114         fByteStream = byteStream;
 115     };
 116 
 117    /**
 118     * The system identifier, a URI reference [IETF RFC 2396], for this output
 119     *  destination. If the application knows the character encoding of the
 120     *  object pointed to by the system identifier, it can set the encoding
 121     *  using the encoding attribute. If the system ID is a relative URI
 122     *  reference (see section 5 in [IETF RFC 2396]), the behavior is
 123     *  implementation dependent.
 124     */
 125 
 126     public String getSystemId(){
 127         return fSystemId;
 128     };
 129 
 130    /**
 131     * The system identifier, a URI reference [IETF RFC 2396], for this output
 132     *  destination. If the application knows the character encoding of the
 133     *  object pointed to by the system identifier, it can set the encoding
 134     *  using the encoding attribute. If the system ID is a relative URI
 135     *  reference (see section 5 in [IETF RFC 2396]), the behavior is
 136     *  implementation dependent.
 137     */
 138 
 139     public void setSystemId(String systemId){
 140         fSystemId = systemId;
 141     };
 142 
 143    /**
 144     * The character encoding, if known. The encoding must be a string
 145     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
 146     * "Character Encoding in Entities"). This attribute has no effect when the
 147     * application provides a character stream or string data. For other sources
 148     * of input, an encoding specified by means of this attribute will override
 149     * any encoding specified in the XML declaration or the Text declaration, or
 150     * an encoding obtained from a higher level protocol, such as HTTP
 151     * [IETF RFC 2616].
 152     */
 153 
 154     public String getEncoding(){
 155         return fEncoding;
 156     };
 157 
 158    /**
 159     * The character encoding, if known. The encoding must be a string
 160     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
 161     * "Character Encoding in Entities"). This attribute has no effect when the
 162     * application provides a character stream or string data. For other sources
 163     * of input, an encoding specified by means of this attribute will override
 164     * any encoding specified in the XML declaration or the Text declaration, or
 165     * an encoding obtained from a higher level protocol, such as HTTP
 166     * [IETF RFC 2616].
 167     */
 168 
 169     public void setEncoding(String encoding){
 170         fEncoding = encoding;
 171     };
 172 
 173 }//DOMOutputImpl