1 22 23 27 28 package org.xquark.serialize; 29 30 import java.io.OutputStream ; 31 import java.io.UnsupportedEncodingException ; 32 import java.io.Writer ; 33 34 import org.xquark.util.NSPrefixDecorator; 35 36 46 public class XMLSerializer extends NSPrefixDecorator { 47 private static final String RCSRevision = "$Revision: 1.5 $"; 48 49 private static final String RCSName = "$Name: $"; 50 51 private BasicXMLSerializer serializer = new BasicXMLSerializer(); 52 53 private XMLSerializer() { 54 setContentHandler(serializer); 55 setLexicalHandler(serializer); 56 setEnabled(true); 57 } 58 59 69 public XMLSerializer(OutputStream out) throws UnsupportedEncodingException { 70 this(); 71 serializer.setOutputStream(out); 72 } 73 74 88 public XMLSerializer(OutputStream out, String encoding) 89 throws UnsupportedEncodingException { 90 this(); 91 serializer.setDefaultEncoding(encoding); 92 serializer.setOutputStream(out); 93 } 94 95 102 public XMLSerializer(Writer out) { 103 this(); 104 serializer.setWriter(out); 105 } 106 107 120 public XMLSerializer(Writer out, String encoding) { 121 this(); 122 serializer.setDefaultEncoding(encoding); 123 serializer.setWriter(out); 124 } 125 126 136 public XMLSerializer(String encoding, boolean indent) { 137 this(); 138 serializer.setDefaultEncoding(encoding); 139 serializer.setIndent(indent); 140 } 141 142 156 public void setOutputStream(OutputStream out) 157 throws UnsupportedEncodingException { 158 serializer.setOutputStream(out); 159 } 160 161 167 public void setWriter(Writer out) { 168 serializer.setWriter(out); 169 } 170 171 180 public void setIndent(boolean indent) { 181 serializer.setIndent(indent); 182 } 183 184 194 public void setCanonicalOutput(boolean mode) { 195 serializer.setCanonicalOutput(mode); 196 } 197 198 206 public void setUseIgnorableWhitespaces(boolean use) { 207 serializer.setUseIgnorableWhitespaces(use); 208 } 209 210 217 public void setEncoding(String encoding) { 218 serializer.setDefaultEncoding(encoding); 219 } 220 221 227 public void setGenerateXMLDeclaration(boolean enable) { 228 serializer.setGenerateXMLDeclaration(enable); 229 } 230 231 238 public void setGenerateEncodingDeclaration(boolean enable) { 239 serializer.setGenerateEncodingDeclaration(enable); 240 } 241 242 248 public void setAutoStreamClose(boolean close) { 249 serializer.setAutoStreamClose(close); 250 } 251 252 257 public boolean getIndent() { 258 return serializer.getIndent(); 259 } 260 261 266 public boolean getCanonicalOutput() { 267 return serializer.getCanonicalOutput(); 268 } 269 270 276 public boolean getUseIgnorableWhitespaces() { 277 return serializer.getUseIgnorableWhitespaces(); 278 } 279 280 285 public String getEncoding() { 286 return serializer.getDefaultEncoding(); 287 } 288 289 294 public boolean getGenerateXMLDeclaration() { 295 return serializer.getGenerateXMLDeclaration(); 296 } 297 298 303 public boolean getAutoStreamClose() { 304 return serializer.getAutoStreamClose(); 305 } 306 307 313 public void completeStartTag() { 314 serializer.completeStartTag(); 315 } 316 317 320 public void flush() { 321 serializer.flush(); 322 } 323 324 327 public void reset() { 328 serializer.reset(); 329 } 330 331 334 public void close() { 335 serializer.close(); 336 } 337 } | Popular Tags |