4 * License : The MIT License
5 * Copyright(c) 2013 MikuToga Partners
8 package jp.sfjp.mikutoga.xml;
10 import java.io.Closeable;
11 import java.io.Flushable;
12 import java.io.IOException;
17 public interface XmlExporter extends Appendable, Flushable, Closeable{
23 * @throws IOException 出力エラー
25 XmlExporter putRawCh(char ch) throws IOException;
31 * @throws IOException 出力エラー
33 XmlExporter putRawText(CharSequence seq) throws IOException;
38 * @throws IOException 出力エラー
40 XmlExporter sp() throws IOException;
44 * @param count 空白回数。0以下の場合は何も出力しない。
46 * @throws IOException 出力エラー
48 XmlExporter sp(int count) throws IOException;
58 * @param newLine 改行文字列
59 * @throws NullPointerException 引数がnull
61 void setNewLine(String newLine) throws NullPointerException;
66 * @throws IOException 出力エラー
68 XmlExporter ln() throws IOException;
72 * @param count 改行回数。0以下の場合は何も出力しない。
74 * @throws IOException 出力エラー
76 XmlExporter ln(int count) throws IOException;
82 String getIndentUnit();
87 * @param indUnit インデント単位文字列。
88 * @throws NullPointerException 引数がnull
90 void setIndentUnit(String indUnit) throws NullPointerException;
99 * インデントレベル0の状態をさらに上げようとした場合、何も起こらない。
108 int getIndentLevel();
112 * インデント単位文字列をネストレベル回数分出力する。
114 * @throws IOException 出力エラー
116 XmlExporter ind() throws IOException;
119 * BasicLatin文字だけを出力する状態か判定する。
121 * @return BasicLatin文字だけで出力するならtrue
123 boolean isBasicLatinOnlyOut();
126 * BasicLatin文字だけで出力するか設定する。
127 * <p>BasicLatin以外の文字(≒日本語)を、そのまま出力するか、
130 * @param bool BasicLatin文字だけで出力するならtrue
132 void setBasicLatinOnlyOut(boolean bool);
135 * 指定された文字を16進2桁の文字参照形式で出力する。
136 * <p>「A」は「&#x41;」になる。
137 * <p>2桁で出力できない場合(>0x00ff)は4桁で出力する。
140 * @throws IOException 出力エラー
141 * @see <a href="http://www.w3.org/TR/xml11/#NT-CharRef">
142 * W3C XML1.1 Character Reference
145 XmlExporter putCharRef2Hex(char ch) throws IOException;
148 * 指定された文字を16進4桁の文字参照形式で出力する。
149 * <p>「亜」は「&#x4E9C;」になる。
150 * <p>UCS4に伴うサロゲートペアは未サポート
153 * @throws IOException 出力エラー
154 * @see <a href="http://www.w3.org/TR/xml11/#NT-CharRef">
155 * W3C XML1.1 Character Reference
158 XmlExporter putCharRef4Hex(char ch) throws IOException;
161 * 要素の中身および属性値中身を出力する。
162 * <p>XMLの構文規則を守る上で必要な各種エスケープ処理が行われる。
165 * @throws IOException 出力エラー
167 XmlExporter putCh(char ch) throws IOException;
170 * 要素の中身および属性値中身を出力する。
171 * <p>必要に応じてXML定義済み実体文字が割り振られた文字、
172 * コントロールコード、および非BasicLatin文字がエスケープされる。
173 * <p>半角円通貨記号U+00A5はバックスラッシュU+005Cに置換される。
174 * <p>連続するスペースU+0020の2文字目以降は文字参照化される。
175 * <p>全角スペースその他空白文字は無条件に文字参照化される。
178 * @throws IOException 出力エラー
180 XmlExporter putContent(CharSequence content) throws IOException;
184 * <p>コメント中の'\n'記号出現に伴い、
185 * あらかじめ指定された改行文字が出力される。
186 * <p>コメント中の'\n'以外のコントロールコードは
187 * Control Pictures(U+2400〜)で代替される。
188 * <p>それ以外の非BasicLatin文字はそのまま出力される。
189 * <p>連続するハイフン(-)記号間には強制的にスペースが挿入される。
190 * @param comment コメント内容
192 * @throws IOException 出力エラー
193 * <a href="http://www.unicode.org/charts/PDF/U2400.pdf">
194 * Unicode 6.2 Controll Pictures
197 XmlExporter putCommentContent(CharSequence comment) throws IOException;
201 * コメント内部の頭及び末尾に空白が1つ挿入される。
202 * @param comment コメント内容
204 * @throws IOException 出力エラー
206 XmlExporter putLineComment(CharSequence comment) throws IOException;
210 * <p>コメント内部の頭の前に改行が出力される。
211 * <p>コメント内部の末尾が改行でない場合、改行が挿入される。
212 * <p>ブロックコメント末尾は改行で終わる。
214 * @param comment コメント内容
216 * @throws IOException 出力エラー
218 XmlExporter putBlockComment(CharSequence comment) throws IOException;
224 * @throws IOException 出力エラー
226 XmlExporter putOpenSTag(CharSequence tagName) throws IOException;
231 * @throws IOException 出力エラー
233 XmlExporter putCloseSTag() throws IOException;
236 * 属性の無いシンプルな開始タグ表記を出力する。
239 * @throws IOException 出力エラー
241 XmlExporter putSimpleSTag(CharSequence tagName) throws IOException;
247 * @throws IOException 出力エラー
249 XmlExporter putETag(CharSequence tagName) throws IOException;
255 * @throws IOException 出力エラー
257 XmlExporter putSimpleEmpty(CharSequence tagName) throws IOException;
262 * @throws IOException 出力エラー
264 XmlExporter putCloseEmpty() throws IOException;
267 * xsd:int値をXMLスキーマ準拠の形式で出力する。
270 * @throws IOException 出力エラー
271 * @see <a href="http://www.w3.org/TR/xmlschema11-2/#int">
272 * XML Schema 1.1 Datatypes int
275 XmlExporter putXsdInt(int iVal) throws IOException;
278 * xsd:float値をXMLスキーマ準拠の形式で出力する。
281 * @throws IOException 出力エラー
282 * @see <a href="http://www.w3.org/TR/xmlschema11-2/#sec-lex-float">
283 * XML Schema 1.1 Datatypes float Lexical Mapping
286 XmlExporter putXsdFloat(float fVal) throws IOException;
290 * @param attrName 属性名
293 * @throws IOException 出力エラー
295 XmlExporter putIntAttr(CharSequence attrName, int iVal)
300 * @param attrName 属性名
303 * @throws IOException 出力エラー
305 XmlExporter putFloatAttr(CharSequence attrName, float fVal)
310 * @param attrName 属性名
311 * @param content 属性内容
313 * @throws IOException 出力エラー
315 XmlExporter putAttr(CharSequence attrName, CharSequence content)