OSDN Git Service

1.105.3-SNAPSHOT版開発開始
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / parser / pmd / PmdParserExt2.java
1 /*
2  * pmd parser extensin 2
3  *
4  * License : The MIT License
5  * Copyright(c) 2010 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.parser.pmd;
9
10 import java.io.IOException;
11 import jp.sourceforge.mikutoga.parser.MmdFormatException;
12 import jp.sourceforge.mikutoga.parser.MmdSource;
13
14 /**
15  * PMDモデルファイルのパーサ拡張その2。
16  * ※独自トゥーンテクスチャファイル名対応
17  */
18 public class PmdParserExt2 extends PmdParserExt1 {
19
20     private PmdToonHandler toonHandler = null;
21
22     /**
23      * コンストラクタ。
24      * @param source 入力ソース
25      */
26     public PmdParserExt2(MmdSource source){
27         super(source);
28         return;
29     }
30
31     /**
32      * トゥーンテクスチャファイルハンドラを登録する。
33      * @param handler ハンドラ
34      */
35     public void setToonHandler(PmdToonHandler handler){
36         this.toonHandler = handler;
37         return;
38     }
39
40     /**
41      * {@inheritDoc}
42      * @throws IOException {@inheritDoc}
43      * @throws MmdFormatException {@inheritDoc}
44      */
45     @Override
46     protected void parseBody()
47             throws IOException, MmdFormatException{
48         super.parseBody();
49
50         if(hasMore()){
51             parseToonName();
52         }
53
54         return;
55     }
56
57     /**
58      * 独自トゥーンテクスチャファイル名のパースと通知。
59      * @throws IOException IOエラー
60      * @throws MmdFormatException フォーマットエラー
61      */
62     private void parseToonName() throws IOException, MmdFormatException{
63         if(this.toonHandler == null){
64             skip(PmdLimits.MAXBYTES_TOONFILENAME * PmdLimits.TOON_FIXEDNUM);
65             return;
66         }
67
68         this.toonHandler.loopStart(PmdToonHandler.TOON_LIST,
69                                    PmdLimits.TOON_FIXEDNUM );
70
71         for(int ct = 0; ct < PmdLimits.TOON_FIXEDNUM; ct++){
72             String toonName =
73                     parseZeroTermString(PmdLimits.MAXBYTES_TOONFILENAME);
74             this.toonHandler.pmdToonFileInfo(toonName);
75
76             this.toonHandler.loopNext(PmdToonHandler.TOON_LIST);
77         }
78
79         this.toonHandler.loopEnd(PmdToonHandler.TOON_LIST);
80
81         return;
82     }
83
84 }