* パース処理の進行ステージ種別を表す。
* ループ構造の識別に用いられる。
*/
-public abstract class ParseStage {
-
- private final String name;
-
- /**
- * コンストラクタ。
- * 進行ステージ名は実行時クラス名(パッケージ名抜き)が指定される。
- */
- protected ParseStage(){
- super();
-
- Class<?> klass = getClass();
- String fullName = klass.getName();
- int idx = fullName.lastIndexOf('.');
-
- String stripName;
- if(idx >= 0){
- stripName = fullName.substring(idx + 1);
- }else{
- stripName = fullName;
- }
-
- this.name = stripName;
-
- return;
- }
+public class ParseStage {
/**
* コンストラクタ。
- * @param name 進行ステージ名
- * @throws NullPointerException 引数がnull
*/
- protected ParseStage(String name) throws NullPointerException{
+ public ParseStage(){
super();
- if(name == null) throw new NullPointerException();
- this.name = name;
return;
}
- /**
- * {@inheritDoc}
- * 進行ステージ名を返す。
- * @return {@inheritDoc} 進行ステージ名
- */
- @Override
- public String toString(){
- return this.name;
- }
-
}
*/
public interface PmdBoneHandler extends LoopHandler {
- /**
- * ボーン情報パースステージ。
- */
- class PmdBoneStage extends ParseStage{
- /** コンストラクタ。 */
- PmdBoneStage(){ super(); return; }
- }
-
/** ボーン定義抽出ループ。 */
- PmdBoneStage BONE_LIST = new PmdBoneStage();
+ ParseStage BONE_LIST = new ParseStage();
/** IKリスト抽出ループ。 */
- PmdBoneStage IK_LIST = new PmdBoneStage();
+ ParseStage IK_LIST = new ParseStage();
/** IKチェーンリスト抽出ループ。 */
- PmdBoneStage IKCHAIN_LIST = new PmdBoneStage();
+ ParseStage IKCHAIN_LIST = new ParseStage();
/** ボーングループ名抽出ループ。 */
- PmdBoneStage BONEGROUP_LIST = new PmdBoneStage();
+ ParseStage BONEGROUP_LIST = new ParseStage();
/** ボーングループ内訳抽出ループ。 */
- PmdBoneStage GROUPEDBONE_LIST = new PmdBoneStage();
+ ParseStage GROUPEDBONE_LIST = new ParseStage();
/**
* ボーン定義情報の通知を受け取る。
*/
public interface PmdEngHandler extends LoopHandler {
- /**
- * 英語情報パースステージ。
- */
- class PmdEngStage extends ParseStage{
- /** コンストラクタ。 */
- PmdEngStage(){ super(); return; }
- }
-
/** ボーン英語名抽出ループ。 */
- ParseStage ENGBONE_LIST = new PmdEngStage();
+ ParseStage ENGBONE_LIST = new ParseStage();
/** モーフ英語名抽出ループ。 */
- ParseStage ENGMORPH_LIST = new PmdEngStage();
+ ParseStage ENGMORPH_LIST = new ParseStage();
/** ボーングループ英語名抽出グループ。 */
- ParseStage ENGBONEGROUP_LIST = new PmdEngStage();
+ ParseStage ENGBONEGROUP_LIST = new ParseStage();
/**
* PMD英語情報の有無の通知を受け取る。
*/
public interface PmdJointHandler extends LoopHandler {
- /**
- * ジョイント情報パースステージ。
- */
- class PmdJointStage extends ParseStage{
- /** コンストラクタ。 */
- PmdJointStage(){ super(); return; }
- }
-
/** ジョイント情報抽出ループ。 */
- PmdJointStage JOINT_LIST = new PmdJointStage();
+ ParseStage JOINT_LIST = new ParseStage();
/**
* ジョイント名の通知を受け取る。
*/
public interface PmdMaterialHandler extends LoopHandler {
- /**
- * モデル材質パースステージ。
- */
- class PmdMaterialStage extends ParseStage{
- /** コンストラクタ。 */
- PmdMaterialStage(){ super(); return; }
- }
-
/** 材質抽出ループ。 */
- PmdMaterialStage MATERIAL_LIST = new PmdMaterialStage();
+ ParseStage MATERIAL_LIST = new ParseStage();
/**
* 材質の拡散光成分の通知を受け取る。
*/
public interface PmdMorphHandler extends LoopHandler {
- /**
- * モーフ情報パースステージ。
- */
- class PmdMorphStage extends ParseStage{
- /** コンストラクタ。 */
- PmdMorphStage(){ super(); return; }
- }
-
/** モーフ抽出ループ。 */
- PmdMorphStage MORPH_LIST = new PmdMorphStage();
+ ParseStage MORPH_LIST = new ParseStage();
/** モーフ頂点抽出ループ。 */
- PmdMorphStage MORPHVERTEX_LIST = new PmdMorphStage();
+ ParseStage MORPHVERTEX_LIST = new ParseStage();
/** モーフ出現順抽出ループ。 */
- PmdMorphStage MORPHORDER_LIST = new PmdMorphStage();
+ ParseStage MORPHORDER_LIST = new ParseStage();
/**
* モーフ情報の通知を受け取る。
*/
public interface PmdRigidHandler extends LoopHandler {
- /**
- * 剛体情報パースステージ。
- */
- class PmdRigidStage extends ParseStage{
- /** コンストラクタ。 */
- PmdRigidStage(){ super(); return; }
- }
-
/** 剛体情報抽出ループ。 */
- PmdRigidStage RIGID_LIST = new PmdRigidStage();
+ ParseStage RIGID_LIST = new ParseStage();
/**
* 剛体名の通知を受け取る。
*/
public interface PmdShapeHandler extends LoopHandler {
- /**
- * モデル形状パースステージ。
- */
- class PmdShapeStage extends ParseStage{
- /** コンストラクタ。 */
- PmdShapeStage(){ super(); return; }
- }
-
/** 頂点抽出ループ。 */
- PmdShapeStage VERTEX_LIST = new PmdShapeStage();
+ ParseStage VERTEX_LIST = new ParseStage();
/** 面抽出ループ。 */
- PmdShapeStage SURFACE_LIST = new PmdShapeStage();
+ ParseStage SURFACE_LIST = new ParseStage();
/**
* 頂点の座標の通知を受け取る。
*/
public interface PmdToonHandler extends LoopHandler {
- /**
- * 独自トゥーンテクスチャファイル名パースステージ。
- */
- class PmdToonStage extends ParseStage{
- /** コンストラクタ。 */
- PmdToonStage(){ super(); return; }
- }
-
/** トゥーンテクスチャファイル名抽出ループ。 */
- PmdToonStage TOON_LIST = new PmdToonStage();
+ ParseStage TOON_LIST = new ParseStage();
/**
* 独自トゥーンテクスチャファイル名の通知を受け取る。
*/
@Override
public void loopStart(ParseStage stage, int loops){
- assert stage instanceof PmdBoneStage;
-
if(stage == PmdBoneHandler.BONE_LIST){
ListUtil.prepareDefConsList(this.boneList, BoneInfo.class, loops);
ListUtil.assignIndexedSerial(this.boneList);
*/
@Override
public void loopNext(ParseStage stage){
- assert stage instanceof PmdBoneStage;
-
if(stage == PmdBoneHandler.BONE_LIST){
if(this.boneIt.hasNext()){
this.currentBone = this.boneIt.next();
*/
@Override
public void loopEnd(ParseStage stage){
- assert stage instanceof PmdBoneStage;
-
if(stage == PmdBoneHandler.BONE_LIST){
//NOTHING
}else if(stage == PmdBoneHandler.IK_LIST){
*/
@Override
public void loopStart(ParseStage stage, int loops){
- assert stage instanceof PmdMorphStage;
-
if(stage == PmdMorphHandler.MORPH_LIST){
ListUtil.prepareDefConsList(this.morphPartList,
MorphPart.class,
// NOTHING
}else if(stage == PmdMorphHandler.MORPHORDER_LIST){
// NOTHING
+ }else{
+ assert false;
+ throw new AssertionError();
}
return;
*/
@Override
public void loopNext(ParseStage stage){
- assert stage instanceof PmdMorphStage;
-
if(stage == PmdMorphHandler.MORPH_LIST){
if(this.morphPartIt.hasNext()){
this.currentMorphPart = this.morphPartIt.next();
// NOTHING
}else if(stage == PmdMorphHandler.MORPHORDER_LIST){
// NOTHING
+ }else{
+ assert false;
+ throw new AssertionError();
}
return;
*/
@Override
public void loopEnd(ParseStage stage){
- assert stage instanceof PmdMorphStage;
if(stage == PmdMorphHandler.MORPH_LIST){
// NOTHING
}else if(stage == PmdMorphHandler.MORPHVERTEX_LIST){
// NOTHING
}else if(stage == PmdMorphHandler.MORPHORDER_LIST){
// NOTHING
+ }else{
+ assert false;
+ throw new AssertionError();
}
return;
}
*/
@Override
public void loopStart(ParseStage stage, int loops){
- assert stage instanceof PmdEngStage;
-
if(stage == PmdEngHandler.ENGBONE_LIST){
this.boneIt = this.boneList.iterator();
if(this.boneIt.hasNext()){
*/
@Override
public void loopNext(ParseStage stage){
- assert stage instanceof PmdEngStage;
-
if(stage == PmdEngHandler.ENGBONE_LIST){
if(this.boneIt.hasNext()){
this.currentBone = this.boneIt.next();
*/
@Override
public void loopEnd(ParseStage stage){
- assert stage instanceof PmdEngStage;
return;
}
+++ /dev/null
-/*
- *
- */
-
-package jp.sourceforge.mikutoga.parser;
-
-import junit.framework.TestCase;
-import org.junit.Test;
-
-/**
- *
- */
-public class ParseStageTest extends TestCase {
-
- public ParseStageTest(String testName) {
- super(testName);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test of toString method, of class ParseStage.
- */
- @Test
- public void testToString(){
- System.out.println("toString");
-
- ParseStage instance;
-
- instance = new Test1("A.B.C");
- assertEquals("A.B.C", instance.toString());
-
- instance = new Test1("");
- assertEquals("", instance.toString());
-
- try{
- instance = new Test1(null);
- fail();
- }catch(NullPointerException e){
- // OK
- }
-
- instance = new Test2();
- assertEquals("ParseStageTest$Test2", instance.toString());
-
- return;
- }
-
- class Test1 extends ParseStage{
- public Test1(String txt){
- super(txt);
- }
- }
-
- class Test2 extends ParseStage{
- public Test2(){
- super();
- }
- }
-
-}