OSDN Git Service

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