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