4 * License : The MIT License
5 * Copyright(c) 2008 olyutorskii
8 package jp.sourceforge.jindolf.archiver;
10 import java.io.IOException;
11 import java.io.Writer;
13 import java.util.LinkedList;
14 import java.util.List;
15 import jp.sourceforge.jindolf.corelib.DisclosureType;
16 import jp.sourceforge.jindolf.corelib.SysEventType;
17 import jp.sourceforge.jindolf.parser.DecodedContent;
22 public class PeriodData{
24 private final VillageData parent;
25 private final PeriodResource resource;
26 private DecodedContent loginName = new DecodedContent("");
27 private int commitMonth;
28 private int commitDay;
29 private int commitHour;
30 private int commitMinute;
31 private DisclosureType disclosureType = DisclosureType.HOT;
32 private boolean hasMurderResult = false;
34 private final List<TopicData> topicList = new LinkedList<TopicData>();
39 * @param resource ロード元情報
41 public PeriodData(VillageData parent, PeriodResource resource){
44 this.resource = resource;
52 public DecodedContent getLoginName(){
53 return this.loginName;
58 * @param loginName ログイン名
60 public void setLoginName(DecodedContent loginName){
61 this.loginName = loginName;
69 public int getCommitMonth(){
70 return this.commitMonth;
75 * @param commitMonth コミット月
77 public void setCommitMonth(int commitMonth){
78 this.commitMonth = commitMonth;
86 public int getCommitDay(){
87 return this.commitDay;
92 * @param commitDay コミット日
94 public void setCommitDay(int commitDay){
95 this.commitDay = commitDay;
103 public int getCommitHour(){
104 return this.commitHour;
109 * @param commitHour コミット時
111 public void setCommitHour(int commitHour){
112 this.commitHour = commitHour;
120 public int getCommitMinute(){
121 return this.commitMinute;
126 * @param commitMinute コミット分
128 public void setCommitMinute(int commitMinute){
129 this.commitMinute = commitMinute;
137 public DisclosureType getDisclosureType(){
138 return this.disclosureType;
145 public void setDisclosureType(DisclosureType type){
146 this.disclosureType = type;
151 * 襲撃結果イベントが既に格納されているか確認する。
152 * @return 襲撃結果があればtrue
154 public boolean hasMurderResult(){
155 return this.hasMurderResult;
161 * @param topicData TopiData
163 public void addTopicData(TopicData topicData){
164 this.topicList.add(topicData);
166 if(topicData instanceof EventData){
167 EventData event = (EventData) topicData;
168 SysEventType type = event.getEventType();
169 if( type == SysEventType.MURDERED
170 || type == SysEventType.NOMURDER){
171 this.hasMurderResult = true;
181 * @throws IOException 出力エラー
183 public void dumpXml(Writer writer) throws IOException{
184 writer.append("<period\n");
187 switch(this.resource.getPeriodType()){
198 throw new IllegalArgumentException();
201 XmlUtils.indent(writer, 1);
202 XmlUtils.attrOut(writer, "type", ptype);
205 XmlUtils.attrOut(writer,
206 "day", Integer.toString(this.resource.getDay()));
209 if(this.disclosureType != DisclosureType.COMPLETE){
210 XmlUtils.indent(writer, 1);
211 XmlUtils.attrOut(writer,
212 "disclosure", this.disclosureType.getXmlName());
216 XmlUtils.indent(writer, 1);
217 XmlUtils.dateAttrOut(writer, "nextCommitDay",
218 this.commitMonth, this.commitDay);
221 XmlUtils.timeAttrOut(writer,
223 this.commitHour, this.commitMinute);
226 URI baseUri = URI.create(this.parent.getBaseUri());
227 URI periodUri = URI.create(this.resource.getOrigUrlText());
228 URI relativeUri = baseUri.relativize(periodUri);
229 XmlUtils.indent(writer, 1);
230 XmlUtils.attrOut(writer, "sourceURI", relativeUri.toString());
233 long downTimeMs = this.resource.getDownTimeMs();
234 XmlUtils.indent(writer, 1);
235 XmlUtils.dateTimeAttr(writer, "loadedTime", downTimeMs);
238 if(this.loginName.length() > 0){
239 XmlUtils.indent(writer, 1);
240 XmlUtils.attrOut(writer, "loadedBy", this.loginName.toString());
244 writer.append(">\n\n");
246 for(TopicData topic : this.topicList){
247 topic.dumpXml(writer);
252 writer.append("</period>\n");