KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xerces > internal > dom > DOMOutputImpl


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001, 2002 The Apache Software Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.dom;
59
60 import org.w3c.dom.ls.LSOutput JavaDoc;
61
62 import java.io.Writer JavaDoc;
63 import java.io.OutputStream JavaDoc;
64
65 /**
66  * This class represents an output destination for data.
67  * This interface allows an application to encapsulate information about an
68  * output destination in a single object, which may include a URI, a byte stream
69  * (possibly with a specifiedencoding), a base URI, and/or a character stream.
70  * The exact definitions of a byte stream and a character stream are binding
71  * dependent.
72  * The application is expected to provide objects that implement this interface
73  * whenever such objects are needed. The application can either provide its
74  * own objects that implement this interface, or it can use the generic factory
75  * method DOMImplementationLS.createLSOutput() to create objects that
76  * implement this interface.
77  * The DOMSerializer will use the LSOutput object to determine where to
78  * serialize the output to. The DOMSerializer will look at the different
79  * outputs specified in the LSOutput in the following order to know which one
80  * to output to, the first one that data can be output to will be used:
81  * 1.LSOutput.characterStream
82  * 2.LSOutput.byteStream
83  * 3.LSOutput.systemId
84  * LSOutput objects belong to the application. The DOM implementation will
85  * never modify them (though it may make copies and modify the copies,
86  * if necessary).
87  *
88  *
89  * @author Arun Yadav, Sun Microsytems
90  * @author Gopal Sharma, Sun Microsystems
91  **/

92
93 public class DOMOutputImpl implements LSOutput JavaDoc {
94
95         protected Writer JavaDoc fCharStream = null;
96         protected OutputStream JavaDoc fByteStream = null;
97         protected String JavaDoc fSystemId = null;
98         protected String JavaDoc fEncoding = null;
99
100    /**
101     * Default Constructor
102     */

103     public DOMOutputImpl() {}
104
105    /**
106     * An attribute of a language and binding dependent type that represents a
107     * writable stream of bytes. If the application knows the character encoding
108     * of the byte stream, it should set the encoding attribute. Setting the
109     * encoding in this way will override any encoding specified in an XML
110     * declaration in the data.
111     */

112
113     public Writer JavaDoc getCharacterStream(){
114         return fCharStream;
115      };
116
117    /**
118     * An attribute of a language and binding dependent type that represents a
119     * writable stream of bytes. If the application knows the character encoding
120     * of the byte stream, it should set the encoding attribute. Setting the
121     * encoding in this way will override any encoding specified in an XML
122     * declaration in the data.
123     */

124
125     public void setCharacterStream(Writer JavaDoc characterStream){
126         fCharStream = characterStream;
127     };
128
129    /**
130     * Depending on the language binding in use, this attribute may not be
131     * available. An attribute of a language and binding dependent type that
132     * represents a writable stream to which 16-bit units can be output. The
133     * application must encode the stream using UTF-16 (defined in [Unicode] and
134     * Amendment 1 of [ISO/IEC 10646]).
135     */

136
137     public OutputStream JavaDoc getByteStream(){
138         return fByteStream;
139     };
140
141    /**
142     * Depending on the language binding in use, this attribute may not be
143     * available. An attribute of a language and binding dependent type that
144     * represents a writable stream to which 16-bit units can be output. The
145     * application must encode the stream using UTF-16 (defined in [Unicode] and
146     * Amendment 1 of [ISO/IEC 10646]).
147     */

148
149     public void setByteStream(OutputStream JavaDoc byteStream){
150         fByteStream = byteStream;
151     };
152
153    /**
154     * The system identifier, a URI reference [IETF RFC 2396], for this output
155     * destination. If the application knows the character encoding of the
156     * object pointed to by the system identifier, it can set the encoding
157     * using the encoding attribute. If the system ID is a relative URI
158     * reference (see section 5 in [IETF RFC 2396]), the behavior is
159     * implementation dependent.
160     */

161
162     public String JavaDoc getSystemId(){
163         return fSystemId;
164     };
165
166    /**
167     * The system identifier, a URI reference [IETF RFC 2396], for this output
168     * destination. If the application knows the character encoding of the
169     * object pointed to by the system identifier, it can set the encoding
170     * using the encoding attribute. If the system ID is a relative URI
171     * reference (see section 5 in [IETF RFC 2396]), the behavior is
172     * implementation dependent.
173     */

174
175     public void setSystemId(String JavaDoc systemId){
176         fSystemId = systemId;
177     };
178
179    /**
180     * The character encoding, if known. The encoding must be a string
181     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
182     * "Character Encoding in Entities"). This attribute has no effect when the
183     * application provides a character stream or string data. For other sources
184     * of input, an encoding specified by means of this attribute will override
185     * any encoding specified in the XML declaration or the Text declaration, or
186     * an encoding obtained from a higher level protocol, such as HTTP
187     * [IETF RFC 2616].
188     */

189
190     public String JavaDoc getEncoding(){
191         return fEncoding;
192     };
193
194    /**
195     * The character encoding, if known. The encoding must be a string
196     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
197     * "Character Encoding in Entities"). This attribute has no effect when the
198     * application provides a character stream or string data. For other sources
199     * of input, an encoding specified by means of this attribute will override
200     * any encoding specified in the XML declaration or the Text declaration, or
201     * an encoding obtained from a higher level protocol, such as HTTP
202     * [IETF RFC 2616].
203     */

204
205     public void setEncoding(String JavaDoc encoding){
206         fEncoding = encoding;
207     };
208
209 }//DOMOutputImpl
210
Popular Tags