2 * village information loader
4 * License : The MIT License
5 * Copyright(c) 2008 olyutorskii
8 package jp.sfjp.jindolf.data.html;
10 import java.io.IOException;
11 import java.util.logging.Level;
12 import java.util.logging.Logger;
13 import jp.osdn.jindolf.parser.HtmlParseException;
14 import jp.osdn.jindolf.parser.HtmlParser;
15 import jp.osdn.jindolf.parser.content.DecodedContent;
16 import jp.sfjp.jindolf.data.Land;
17 import jp.sfjp.jindolf.data.Village;
18 import jp.sfjp.jindolf.net.HtmlSequence;
19 import jp.sfjp.jindolf.net.ServerAccess;
20 import jp.sourceforge.jindolf.corelib.LandDef;
21 import jp.sourceforge.jindolf.corelib.LandState;
24 * 人狼各国のHTTPサーバから個別の村の村情報をHTMLで取得する。
26 * <p>村情報には村毎の更新時刻、日程、進行状況などが含まれる。
28 * <p>各Periodの会話はまだロードされない。
30 public final class VillageInfoLoader {
32 private static final Logger LOGGER = Logger.getAnonymousLogger();
38 private VillageInfoLoader() {
45 * HTMLで記述された各村の村情報ページをダウンロードする。
47 * <p>村情報ページのURLは各国の状態及び村の進行状況により異なる。
49 * <p>※ G国HISTORICAL運用移行に伴い、
50 * 2020-02の時点で進行中の村はもはや存在しないため、
53 * <p>例: G1000村(エピローグ終了状態)の村情報ページは
54 * <a href="http://www.wolfg.x0.com/index.rb?vid=1000">
55 * http://www.wolfg.x0.com/index.rb?vid=1000</a>
59 * @throws IOException 入出力エラー
61 private static DecodedContent loadVillageInfo(Village village)
63 Land land = village.getParentLand();
64 ServerAccess server = land.getServerAccess();
65 LandDef landDef = land.getLandDef();
66 LandState landState = landDef.getLandState();
69 if(landState == LandState.ACTIVE){
70 html = server.getHTMLBoneHead(village);
72 html = server.getHTMLVillage(village);
75 DecodedContent content = html.getContent();
81 * 人狼BBSサーバから各村のPeriod一覧情報が含まれたHTML(村情報)を取得し、
82 * 更新時刻や日程、空PeriodのリストをVillageインスタンスに設定する。
85 * @throws java.io.IOException ネットワーク入出力の異常
87 public static void updateVillageInfo(Village village)
89 DecodedContent content = loadVillageInfo(village);
91 HtmlParser parser = new HtmlParser();
92 VillageInfoHandler handler = new VillageInfoHandler();
93 parser.setBasicHandler (handler);
94 parser.setSysEventHandler(handler);
95 parser.setTalkHandler (handler);
97 handler.setVillage(village);
99 parser.parseAutomatic(content);
100 }catch(HtmlParseException e){
101 LOGGER.log(Level.WARNING, "村の状態が不明", e);