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