4 * Copyright(c) 2008 olyutorskii
\r
7 package jp.sourceforge.jindolf.archiver;
\r
9 import java.io.IOException;
\r
10 import java.io.Writer;
\r
11 import java.util.LinkedList;
\r
12 import java.util.List;
\r
13 import jp.sourceforge.jindolf.parser.DecodedContent;
\r
18 public abstract class TopicData{
\r
20 private static final DecodedContent BREAK = new DecodedContent("\n");
\r
22 private final List<DecodedContent> lineList =
\r
23 new LinkedList<DecodedContent>();
\r
28 protected TopicData(){
\r
35 * @param content 行を構成する文字列
\r
37 public void addLine(DecodedContent content){
\r
38 this.lineList.add(content);
\r
45 public void addBreak(){
\r
46 this.lineList.add(BREAK);
\r
54 public int getLineNum(){
\r
55 return this.lineList.size();
\r
62 public DecodedContent get1stLine(){
\r
63 return this.lineList.get(0);
\r
69 * @throws IOException 出力エラー
\r
71 public void dumpLines(Writer writer) throws IOException{
\r
72 DecodedContent lastLine = null;
\r
73 DecodedContent lastContent = null;
\r
75 for(DecodedContent content : this.lineList){
\r
76 lastContent = content;
\r
77 if(content == BREAK){
\r
78 if(lastLine != null){
\r
79 writer.append("</li>\n");
\r
82 writer.append("<li/>\n");
\r
85 if(lastLine == null){
\r
86 writer.append("<li>");
\r
88 XmlUtils.dumpDecodedContent(writer, content);
\r
93 if(lastLine != null){
\r
94 writer.append("</li>\n");
\r
95 }else if(lastContent == BREAK){
\r
96 writer.append("<li/>\n");
\r
104 * @param writer 出力先
\r
105 * @throws IOException 出力エラー
\r
107 public abstract void dumpXml(Writer writer) throws IOException;
\r