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