KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > dom > DOMOutputImpl


1 /*
2  * Copyright 2001, 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.dom;
18
19 import org.w3c.dom.ls.LSOutput JavaDoc;
20
21 import java.io.Writer JavaDoc;
22 import java.io.OutputStream JavaDoc;
23
24 /**
25  * This class represents an output destination for data.
26  * This interface allows an application to encapsulate information about an
27  * output destination in a single object, which may include a URI, a byte stream
28  * (possibly with a specifiedencoding), a base URI, and/or a character stream.
29  * The exact definitions of a byte stream and a character stream are binding
30  * dependent.
31  * The application is expected to provide objects that implement this interface
32  * whenever such objects are needed. The application can either provide its
33  * own objects that implement this interface, or it can use the generic factory
34  * method DOMImplementationLS.createLSOutput() to create objects that
35  * implement this interface.
36  * The DOMSerializer will use the LSOutput object to determine where to
37  * serialize the output to. The DOMSerializer will look at the different
38  * outputs specified in the LSOutput in the following order to know which one
39  * to output to, the first one that data can be output to will be used:
40  * 1.LSOutput.characterStream
41  * 2.LSOutput.byteStream
42  * 3.LSOutput.systemId
43  * LSOutput objects belong to the application. The DOM implementation will
44  * never modify them (though it may make copies and modify the copies,
45  * if necessary).
46  *
47  * @xerces.internal
48  *
49  * @author Arun Yadav, Sun Microsytems
50  * @author Gopal Sharma, Sun Microsystems
51  **/

52
53 public class DOMOutputImpl implements LSOutput JavaDoc {
54
55         protected Writer JavaDoc fCharStream = null;
56         protected OutputStream JavaDoc fByteStream = null;
57         protected String JavaDoc fSystemId = null;
58         protected String JavaDoc fEncoding = null;
59
60    /**
61     * Default Constructor
62     */

63     public DOMOutputImpl() {}
64
65    /**
66     * An attribute of a language and binding dependent type that represents a
67     * writable stream of bytes. If the application knows the character encoding
68     * of the byte stream, it should set the encoding attribute. Setting the
69     * encoding in this way will override any encoding specified in an XML
70     * declaration in the data.
71     */

72
73     public Writer JavaDoc getCharacterStream(){
74         return fCharStream;
75      };
76
77    /**
78     * An attribute of a language and binding dependent type that represents a
79     * writable stream of bytes. If the application knows the character encoding
80     * of the byte stream, it should set the encoding attribute. Setting the
81     * encoding in this way will override any encoding specified in an XML
82     * declaration in the data.
83     */

84
85     public void setCharacterStream(Writer JavaDoc characterStream){
86         fCharStream = characterStream;
87     };
88
89    /**
90     * Depending on the language binding in use, this attribute may not be
91     * available. An attribute of a language and binding dependent type that
92     * represents a writable stream to which 16-bit units can be output. The
93     * application must encode the stream using UTF-16 (defined in [Unicode] and
94     * Amendment 1 of [ISO/IEC 10646]).
95     */

96
97     public OutputStream JavaDoc getByteStream(){
98         return fByteStream;
99     };
100
101    /**
102     * Depending on the language binding in use, this attribute may not be
103     * available. An attribute of a language and binding dependent type that
104     * represents a writable stream to which 16-bit units can be output. The
105     * application must encode the stream using UTF-16 (defined in [Unicode] and
106     * Amendment 1 of [ISO/IEC 10646]).
107     */

108
109     public void setByteStream(OutputStream JavaDoc byteStream){
110         fByteStream = byteStream;
111     };
112
113    /**
114     * The system identifier, a URI reference [IETF RFC 2396], for this output
115     * destination. If the application knows the character encoding of the
116     * object pointed to by the system identifier, it can set the encoding
117     * using the encoding attribute. If the system ID is a relative URI
118     * reference (see section 5 in [IETF RFC 2396]), the behavior is
119     * implementation dependent.
120     */

121
122     public String JavaDoc getSystemId(){
123         return fSystemId;
124     };
125
126    /**
127     * The system identifier, a URI reference [IETF RFC 2396], for this output
128     * destination. If the application knows the character encoding of the
129     * object pointed to by the system identifier, it can set the encoding
130     * using the encoding attribute. If the system ID is a relative URI
131     * reference (see section 5 in [IETF RFC 2396]), the behavior is
132     * implementation dependent.
133     */

134
135     public void setSystemId(String JavaDoc systemId){
136         fSystemId = systemId;
137     };
138
139    /**
140     * The character encoding, if known. The encoding must be a string
141     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
142     * "Character Encoding in Entities"). This attribute has no effect when the
143     * application provides a character stream or string data. For other sources
144     * of input, an encoding specified by means of this attribute will override
145     * any encoding specified in the XML declaration or the Text declaration, or
146     * an encoding obtained from a higher level protocol, such as HTTP
147     * [IETF RFC 2616].
148     */

149
150     public String JavaDoc getEncoding(){
151         return fEncoding;
152     };
153
154    /**
155     * The character encoding, if known. The encoding must be a string
156     * acceptable for an XML encoding declaration ([XML 1.0] section 4.3.3
157     * "Character Encoding in Entities"). This attribute has no effect when the
158     * application provides a character stream or string data. For other sources
159     * of input, an encoding specified by means of this attribute will override
160     * any encoding specified in the XML declaration or the Text declaration, or
161     * an encoding obtained from a higher level protocol, such as HTTP
162     * [IETF RFC 2616].
163     */

164
165     public void setEncoding(String JavaDoc encoding){
166         fEncoding = encoding;
167     };
168
169 }//DOMOutputImpl
170
Popular Tags