OSDN Git Service

3814cbabec5e81d815defa5bafd0b242e084004c
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / parser / ParseStage.java
1 /*
2  * parse-processing stage
3  *
4  * License : The MIT License
5  * Copyright(c) 2010 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.parser;
9
10 /**
11  * パース処理の進行ステージ種別を表す。
12  * ループ構造の識別に用いられる。
13  */
14 public abstract class ParseStage {
15
16     private final String name;
17
18     /**
19      * コンストラクタ。
20      * 進行ステージ名は実行時クラス名(パッケージ名抜き)が指定される。
21      */
22     protected ParseStage(){
23         super();
24
25         Class<?> klass = getClass();
26         String fullName = klass.getName();
27         int idx = fullName.lastIndexOf('.');
28
29         String stripName;
30         if(idx >= 0){
31             stripName = fullName.substring(idx + 1);
32         }else{
33             stripName = fullName;
34         }
35
36         this.name = stripName;
37
38         return;
39     }
40
41     /**
42      * コンストラクタ。
43      * @param name 進行ステージ名
44      * @throws NullPointerException 引数がnull
45      */
46     protected ParseStage(String name) throws NullPointerException{
47         super();
48         if(name == null) throw new NullPointerException();
49         this.name = name;
50         return;
51     }
52
53     /**
54      * {@inheritDoc}
55      * 進行ステージ名を返す。
56      * @return {@inheritDoc} 進行ステージ名
57      */
58     @Override
59     public String toString(){
60         return this.name;
61     }
62
63 }