4 * License : The MIT License
5 * Copyright(c) 2010 MikuToga Partners
8 package jp.sourceforge.mikutoga.xml;
10 import java.io.BufferedWriter;
11 import java.io.Closeable;
12 import java.io.Flushable;
13 import java.io.IOException;
14 import java.io.OutputStream;
15 import java.io.OutputStreamWriter;
16 import java.nio.charset.Charset;
19 * Appendable用XMLエクスポータ実装。
21 public class BasicXmlExporter extends AbstractXmlExporter{
24 private static final Charset CS_UTF8 = Charset.forName("UTF-8");
27 private final Appendable appendable;
32 * 文字エンコーディングはUTF-8が用いられる。
33 * @param stream 出力ストリーム
35 public BasicXmlExporter(OutputStream stream){
36 this(stream, CS_UTF8);
42 * @param stream 出力ストリーム
43 * @param charSet 文字エンコーディング指定
45 public BasicXmlExporter(OutputStream stream, Charset charSet){
48 new OutputStreamWriter(stream, charSet)
56 * @param appendable 文字列出力
58 public BasicXmlExporter(Appendable appendable){
60 this.appendable = appendable;
67 * @param ch {@inheritDoc}
68 * @return {@inheritDoc}
69 * @throws IOException {@inheritDoc}
72 public BasicXmlExporter putRawCh(char ch) throws IOException{
73 this.appendable.append(ch);
79 * @param seq {@inheritDoc}
80 * @return {@inheritDoc}
81 * @throws IOException {@inheritDoc}
84 public BasicXmlExporter putRawText(CharSequence seq) throws IOException{
85 this.appendable.append(seq);
92 * @throws IOException {@inheritDoc}
95 public void flush() throws IOException{
96 if(this.appendable instanceof Flushable){
97 ((Flushable)this.appendable).flush();
105 * @throws IOException {@inheritDoc}
108 public void close() throws IOException{
109 if(this.appendable instanceof Closeable){
110 ((Closeable)this.appendable).close();