OSDN Git Service

binioパッケージと統合
authorOlyutorskii <olyutorskii@users.osdn.me>
Wed, 24 Aug 2011 11:12:08 +0000 (20:12 +0900)
committerOlyutorskii <olyutorskii@users.osdn.me>
Wed, 24 Aug 2011 11:12:08 +0000 (20:12 +0900)
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/AbstractExporter.java [deleted file]
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/IllegalPmdException.java
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/PmdExporterBase.java
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/PmdExporterExt1.java
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/PmdExporterExt2.java
src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/PmdExporterExt3.java

diff --git a/src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/AbstractExporter.java b/src/main/java/jp/sourceforge/mikutoga/pmd/model/binio/AbstractExporter.java
deleted file mode 100644 (file)
index 6f21bfc..0000000
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * abstract exporter
- *
- * License : The MIT License
- * Copyright(c) 2010 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.pmd.model.binio;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-
-/**
- * 抽象化されたエクスポーター共通部。
- */
-public abstract class AbstractExporter {
-
-    private static final Charset CS_WIN31J = Charset.forName("windows-31j");
-
-    private static final String ERRMSG_TOOLONGTEXT = "too long text";
-    private static final String ERRMSG_INVUCSSEQ = "invalid unicode sequence";
-    private static final String ERRMSG_NONWIN31J = "no character in win31j";
-
-    private static final int BYTES_SHORT = Short  .SIZE / Byte.SIZE;
-    private static final int BYTES_INT   = Integer.SIZE / Byte.SIZE;
-    private static final int BYTES_FLOAT = Float  .SIZE / Byte.SIZE;
-
-    private static final int BUFSZ_BYTE = 512;
-    private static final int BUFSZ_CHAR = 512;
-
-    private final OutputStream ostream;
-
-    private final byte[] barray;
-    private final ByteBuffer bbuf;
-
-    private final CharBuffer cbuf;
-    private final CharsetEncoder encoder;
-
-
-    /**
-     * コンストラクタ。
-     * @param stream 出力ストリーム
-     * @throws NullPointerException 引数がnull
-     */
-    protected AbstractExporter(OutputStream stream)
-            throws NullPointerException{
-        super();
-
-        if(stream == null) throw new NullPointerException();
-        this.ostream = stream;
-
-        this.barray = new byte[BUFSZ_BYTE];
-        this.bbuf = ByteBuffer.wrap(this.barray);
-        this.bbuf.order(ByteOrder.LITTLE_ENDIAN);
-
-        this.cbuf = CharBuffer.allocate(BUFSZ_CHAR);
-        this.encoder = CS_WIN31J.newEncoder();
-        this.encoder.onMalformedInput(CodingErrorAction.REPORT);
-        this.encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-        this.encoder.reset();
-
-        return;
-    }
-
-    /**
-     * 出力をフラッシュする。
-     * I/O効率とデバッグ効率のバランスを考え、ご利用は計画的に。
-     * @throws IOException 出力エラー
-     */
-    protected void flush() throws IOException{
-        this.ostream.flush();
-        return;
-    }
-
-    /**
-     * byte値を出力する。
-     * @param bVal byte値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpByte(byte bVal) throws IOException{
-        this.ostream.write((int)bVal);
-        return;
-    }
-
-    /**
-     * int値をbyte値で出力する。
-     * byte値に収まらない上位ビットはそのまま捨てられる。
-     * @param iVal int値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpByte(int iVal) throws IOException{
-        dumpByte((byte)iVal);
-        return;
-    }
-
-    /**
-     * short値を出力する。
-     * @param sVal short値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpShort(short sVal) throws IOException{
-        this.bbuf.clear();
-        this.bbuf.putShort(sVal);
-        this.ostream.write(this.barray, 0, BYTES_SHORT);
-        return;
-    }
-
-    /**
-     * int値をshort値で出力する。
-     * short値に収まらない上位ビットはそのまま捨てられる。
-     * @param iVal int値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpShort(int iVal) throws IOException{
-        dumpShort((short)iVal);
-        return;
-    }
-
-    /**
-     * int値を出力する。
-     * @param iVal int値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpInt(int iVal) throws IOException{
-        this.bbuf.clear();
-        this.bbuf.putInt(iVal);
-        this.ostream.write(this.barray, 0, BYTES_INT);
-        return;
-    }
-
-    /**
-     * float値を出力する。
-     * @param fVal float値
-     * @throws IOException 出力エラー
-     */
-    protected void dumpFloat(float fVal) throws IOException{
-        this.bbuf.clear();
-        this.bbuf.putFloat(fVal);
-        this.ostream.write(this.barray, 0, BYTES_FLOAT);
-        return;
-    }
-
-    /**
-     * 文字列をwindows-31jエンコーディングで出力する。
-     * @param seq 文字列
-     * @return 出力されたbyte総数。
-     * @throws IOException 出力エラー
-     * @throws IllegalPmdTextException 文字エンコーディングに関するエラー
-     */
-    protected int dumpCharSequence(CharSequence seq)
-            throws IOException, IllegalPmdTextException{
-        encodeToByteBuffer(seq);
-        this.bbuf.flip();
-        int length = dumpByteBuffer();
-        return length;
-    }
-
-    /**
-     * windows-31jにエンコーディングした文字列を内部バッファに蓄積する。
-     * @param seq 文字列
-     * @throws IllegalPmdTextException 文字エンコーディングに関するエラー。
-     * 考えられる状況としては、
-     * <ul>
-     * <li>入力文字列がUnicodeとしてすでにおかしい。
-     * (サロゲートペアがペアになってないなど)
-     * <li>windows-31jにない文字をエンコーディングしようとした
-     * <li>エンコーディング結果が内部バッファに収まらなかった。
-     * </ul>
-     * など。
-     */
-    private void encodeToByteBuffer(CharSequence seq)
-            throws IllegalPmdTextException{
-        this.cbuf.clear();
-        try{
-            this.cbuf.append(seq);
-        }catch(BufferOverflowException e){
-            throw new IllegalPmdTextException(ERRMSG_TOOLONGTEXT);
-        }
-        this.cbuf.flip();
-
-        this.bbuf.clear();
-
-        CoderResult result = this.encoder.encode(this.cbuf, this.bbuf, true);
-        if( ! result.isUnderflow()){
-            if(result.isOverflow()){
-                throw new IllegalPmdTextException(ERRMSG_TOOLONGTEXT);
-            }else if(result.isMalformed()){
-                throw new IllegalPmdTextException(ERRMSG_INVUCSSEQ);
-            }else if(result.isUnmappable()){
-                throw new IllegalPmdTextException(ERRMSG_NONWIN31J);
-            }else{
-                assert false;
-                throw new AssertionError();
-            }
-        }
-
-        return;
-    }
-
-    /**
-     * 内部バッファに蓄積されたbyte値並びを出力する。
-     * @return 出力されたbyte数
-     * @throws IOException 出力エラー
-     */
-    private int dumpByteBuffer() throws IOException{
-        int offset = this.bbuf.position();
-        int limit = this.bbuf.limit();
-        int length = limit - offset;
-        this.ostream.write(this.barray, offset, length);
-
-        this.bbuf.position(limit);
-
-        return length;
-    }
-
-}
index c744d1c..d9ee392 100644 (file)
@@ -30,4 +30,13 @@ public class IllegalPmdException extends Exception{
         return;
     }
 
         return;
     }
 
+    /**
+     * コンストラクタ。
+     * @param cause 原因
+     */
+    public IllegalPmdException(Throwable cause){
+        super(cause);
+        return;
+    }
+
 }
 }
index f4eced9..b894bbc 100644 (file)
@@ -15,6 +15,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import jp.sourceforge.mikutoga.binio.BinaryExporter;
+import jp.sourceforge.mikutoga.binio.IllegalTextExportException;
 import jp.sourceforge.mikutoga.math.MkPos2D;
 import jp.sourceforge.mikutoga.math.MkPos3D;
 import jp.sourceforge.mikutoga.math.MkVec3D;
 import jp.sourceforge.mikutoga.math.MkPos2D;
 import jp.sourceforge.mikutoga.math.MkPos3D;
 import jp.sourceforge.mikutoga.math.MkVec3D;
@@ -39,7 +41,7 @@ import jp.sourceforge.mikutoga.pmd.parser.PmdLimits;
  * 英名対応以降のPMDファイルフォーマットを
  * 使いたくない場合はこのエクスポーターを用いて出力せよ。
  */
  * 英名対応以降のPMDファイルフォーマットを
  * 使いたくない場合はこのエクスポーターを用いて出力せよ。
  */
-public class PmdExporterBase extends AbstractExporter{
+public class PmdExporterBase extends BinaryExporter{
 
     /** 前(親)ボーンが無い場合の便宜的なボーンID。 */
     public static final int NOPREVBONE_ID = 0xffff;
 
     /** 前(親)ボーンが無い場合の便宜的なボーンID。 */
     public static final int NOPREVBONE_ID = 0xffff;
@@ -109,42 +111,8 @@ public class PmdExporterBase extends AbstractExporter{
      * 指定バイト長をはみ出した。
      */
     protected void dumpText(String text, int maxByteLength)
      * 指定バイト長をはみ出した。
      */
     protected void dumpText(String text, int maxByteLength)
-            throws IOException, IllegalPmdTextException{
-        dumpText(text, maxByteLength, FDFILLER);
-        return;
-    }
-
-    /**
-     * 文字列を指定されたバイト長で出力する。
-     * 文字列の改行記号はLF(0x0a)に正規化される。
-     * エンコード結果がバイト長に満たない場合は
-     * fillerがパディングされる。
-     * @param text 文字列
-     * @param maxByteLength バイト超指定
-     * @param filler 出力結果が足りない場合の詰め物。
-     * それでも足りない場合は最後のbyte要素が繰り返し出力される。
-     * @throws IOException 出力エラー
-     * @throws IllegalPmdTextException エンコード結果が
-     * 指定バイト長をはみ出した
-     */
-    protected void dumpText(String text, int maxByteLength, byte[] filler)
-            throws IOException, IllegalPmdTextException{
-        String normalized = normalizeBreak(text);
-        int blen = dumpCharSequence(normalized);
-        int remain = maxByteLength - blen;
-
-        if(remain < 0) throw new IllegalPmdTextException("too long text");
-
-        int fillerIdx = 0;
-        while(remain > 0){
-            if(fillerIdx >= filler.length){
-                fillerIdx = filler.length - 1;
-            }
-            dumpByte(filler[fillerIdx]);
-            fillerIdx++;
-            remain--;
-        }
-
+            throws IOException, IllegalTextExportException{
+        dumpFixedW31j(text, maxByteLength, FDFILLER);
         return;
     }
 
         return;
     }
 
@@ -156,15 +124,19 @@ public class PmdExporterBase extends AbstractExporter{
      */
     public void dumpPmdModel(PmdModel model)
             throws IOException, IllegalPmdException{
      */
     public void dumpPmdModel(PmdModel model)
             throws IOException, IllegalPmdException{
-        dumpBasic(model);
-        dumpVertexList(model);
-        dumpSurfaceList(model);
-        dumpMaterialList(model);
-        dumpBoneList(model);
-        dumpIKChainList(model);
-        dumpMorphList(model);
-        dumpMorphGroup(model);
-        dumpBoneGroupList(model);
+        try{
+            dumpBasic(model);
+            dumpVertexList(model);
+            dumpSurfaceList(model);
+            dumpMaterialList(model);
+            dumpBoneList(model);
+            dumpIKChainList(model);
+            dumpMorphList(model);
+            dumpMorphGroup(model);
+            dumpBoneGroupList(model);
+        }catch(IllegalTextExportException e){
+            throw new IllegalPmdException(e);
+        }
 
         return;
     }
 
         return;
     }
@@ -176,7 +148,7 @@ public class PmdExporterBase extends AbstractExporter{
      * @throws IllegalPmdTextException モデル名もしくは説明が長すぎる
      */
     private void dumpBasic(PmdModel model)
      * @throws IllegalPmdTextException モデル名もしくは説明が長すぎる
      */
     private void dumpBasic(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         for(int idx=0; idx < MAGIC_BYTES.length; idx++){
             dumpByte(MAGIC_BYTES[idx]);
         }
         for(int idx=0; idx < MAGIC_BYTES.length; idx++){
             dumpByte(MAGIC_BYTES[idx]);
         }
@@ -282,7 +254,7 @@ public class PmdExporterBase extends AbstractExporter{
      * @throws IllegalPmdTextException シェーディングファイル情報が長すぎる
      */
     private void dumpMaterialList(PmdModel model)
      * @throws IllegalPmdTextException シェーディングファイル情報が長すぎる
      */
     private void dumpMaterialList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         List<Material> materialList = model.getMaterialList();
 
         int materialNum = materialList.size();
         List<Material> materialList = model.getMaterialList();
 
         int materialNum = materialList.size();
@@ -338,10 +310,10 @@ public class PmdExporterBase extends AbstractExporter{
      * シェーディングファイル情報を出力する。
      * @param shade シェーディング情報
      * @throws IOException 出力エラー
      * シェーディングファイル情報を出力する。
      * @param shade シェーディング情報
      * @throws IOException 出力エラー
-     * @throws IllegalPmdTextException ファイル名が長すぎる
+     * @throws IllegalTextExportException ファイル名が長すぎる
      */
     private void dumpShadeFileInfo(ShadeInfo shade)
      */
     private void dumpShadeFileInfo(ShadeInfo shade)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         String textureFile   = shade.getTextureFileName();
         String spheremapFile = shade.getSpheremapFileName();
 
         String textureFile   = shade.getTextureFileName();
         String spheremapFile = shade.getSpheremapFileName();
 
@@ -356,9 +328,9 @@ public class PmdExporterBase extends AbstractExporter{
         if(text.length() <= 0) filler = NULLFILLER;
         else                   filler = FDFILLER;
 
         if(text.length() <= 0) filler = NULLFILLER;
         else                   filler = FDFILLER;
 
-        dumpText(text.toString(),
-                 PmdLimits.MAXBYTES_TEXTUREFILENAME,
-                 filler );
+        dumpFixedW31j(text.toString(),
+                      PmdLimits.MAXBYTES_TEXTUREFILENAME,
+                      filler );
 
         return;
     }
 
         return;
     }
@@ -370,7 +342,7 @@ public class PmdExporterBase extends AbstractExporter{
      * @throws IllegalPmdTextException ボーン名が長すぎる
      */
     private void dumpBoneList(PmdModel model)
      * @throws IllegalPmdTextException ボーン名が長すぎる
      */
     private void dumpBoneList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         List<BoneInfo> boneList = model.getBoneList();
 
         int boneNum = boneList.size();
         List<BoneInfo> boneList = model.getBoneList();
 
         int boneNum = boneList.size();
@@ -392,7 +364,7 @@ public class PmdExporterBase extends AbstractExporter{
      * @throws IllegalPmdTextException ボーン名が長すぎる
      */
     private void dumpBone(BoneInfo bone)
      * @throws IllegalPmdTextException ボーン名が長すぎる
      */
     private void dumpBone(BoneInfo bone)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         String boneName = bone.getBoneName().getPrimaryText();
         dumpText(boneName, PmdLimits.MAXBYTES_BONENAME);
 
         String boneName = bone.getBoneName().getPrimaryText();
         dumpText(boneName, PmdLimits.MAXBYTES_BONENAME);
 
@@ -483,7 +455,7 @@ public class PmdExporterBase extends AbstractExporter{
      * @throws IllegalPmdTextException モーフ名が長すぎる
      */
     private void dumpMorphList(PmdModel model)
      * @throws IllegalPmdTextException モーフ名が長すぎる
      */
     private void dumpMorphList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap();
         Set<MorphType> typeSet = morphMap.keySet();
         List<MorphVertex> mergedMorphVertexList = model.mergeMorphVertex();
         Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap();
         Set<MorphType> typeSet = morphMap.keySet();
         List<MorphVertex> mergedMorphVertexList = model.mergeMorphVertex();
@@ -578,10 +550,10 @@ public class PmdExporterBase extends AbstractExporter{
      * デフォルトボーングループ内訳は出力されない。
      * @param model モデルデータ
      * @throws IOException 出力エラー
      * デフォルトボーングループ内訳は出力されない。
      * @param model モデルデータ
      * @throws IOException 出力エラー
-     * @throws IllegalPmdTextException ボーングループ名が長すぎる
+     * @throws IllegalTextExportException ボーングループ名が長すぎる
      */
     private void dumpBoneGroupList(PmdModel model)
      */
     private void dumpBoneGroupList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         List<BoneGroup> groupList = model.getBoneGroupList();
         int groupNum = groupList.size();
         dumpByte(groupNum - 1);
         List<BoneGroup> groupList = model.getBoneGroupList();
         int groupNum = groupList.size();
         dumpByte(groupNum - 1);
@@ -589,8 +561,8 @@ public class PmdExporterBase extends AbstractExporter{
         int dispBoneNum = 0;
         for(BoneGroup group : groupList){
             if(group.isDefaultBoneGroup()) continue;
         int dispBoneNum = 0;
         for(BoneGroup group : groupList){
             if(group.isDefaultBoneGroup()) continue;
-            dumpText(group.getGroupName().getPrimaryText(),
-                     PmdLimits.MAXBYTES_BONEGROUPNAME, LFFILLER );
+            dumpFixedW31j(group.getGroupName().getPrimaryText(),
+                          PmdLimits.MAXBYTES_BONEGROUPNAME, LFFILLER );
             dispBoneNum += group.getBoneList().size();
         }
         dumpInt(dispBoneNum);
             dispBoneNum += group.getBoneList().size();
         }
         dumpInt(dispBoneNum);
index 38f629c..2a3355f 100644 (file)
@@ -11,6 +11,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
 import java.util.Map;
 import java.io.OutputStream;
 import java.util.List;
 import java.util.Map;
+import jp.sourceforge.mikutoga.binio.IllegalTextExportException;
 import jp.sourceforge.mikutoga.pmd.MorphType;
 import jp.sourceforge.mikutoga.pmd.model.BoneGroup;
 import jp.sourceforge.mikutoga.pmd.model.BoneInfo;
 import jp.sourceforge.mikutoga.pmd.MorphType;
 import jp.sourceforge.mikutoga.pmd.model.BoneGroup;
 import jp.sourceforge.mikutoga.pmd.model.BoneInfo;
@@ -60,7 +61,7 @@ public class PmdExporterExt1 extends PmdExporterBase{
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpGlobalInfo(PmdModel model)
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpGlobalInfo(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalPmdException{
         boolean hasGlobal = model.hasGlobalText();
         byte globalFlag;
         if(hasGlobal) globalFlag = 0x01;
         boolean hasGlobal = model.hasGlobalText();
         byte globalFlag;
         if(hasGlobal) globalFlag = 0x01;
@@ -68,10 +69,14 @@ public class PmdExporterExt1 extends PmdExporterBase{
         dumpByte(globalFlag);
 
         if(hasGlobal){
         dumpByte(globalFlag);
 
         if(hasGlobal){
-            dumpBasicGlobal(model);
-            dumpBoneGlobal(model);
-            dumpMorphGlobal(model);
-            dumpBoneGroupGlobal(model);
+            try{
+                dumpBasicGlobal(model);
+                dumpBoneGlobal(model);
+                dumpMorphGlobal(model);
+                dumpBoneGroupGlobal(model);
+            }catch(IllegalTextExportException e){
+                throw new IllegalPmdException(e);
+            }
         }
 
         flush();
         }
 
         flush();
@@ -86,7 +91,7 @@ public class PmdExporterExt1 extends PmdExporterBase{
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpBasicGlobal(PmdModel model)
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpBasicGlobal(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         String modelName = model.getModelName().getGlobalText();
         if(modelName == null) modelName = "";
         dumpText(modelName, PmdLimits.MAXBYTES_MODELNAME);
         String modelName = model.getModelName().getGlobalText();
         if(modelName == null) modelName = "";
         dumpText(modelName, PmdLimits.MAXBYTES_MODELNAME);
@@ -105,7 +110,7 @@ public class PmdExporterExt1 extends PmdExporterBase{
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpBoneGlobal(PmdModel model)
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpBoneGlobal(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         for(BoneInfo bone : model.getBoneList()){
             String boneName = bone.getBoneName().getGlobalText();
             if(boneName == null) boneName = "";
         for(BoneInfo bone : model.getBoneList()){
             String boneName = bone.getBoneName().getGlobalText();
             if(boneName == null) boneName = "";
@@ -122,7 +127,7 @@ public class PmdExporterExt1 extends PmdExporterBase{
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpMorphGlobal(PmdModel model)
      * @throws IllegalPmdTextException 文字列が長すぎる。
      */
     private void dumpMorphGlobal(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap();
 
         for(MorphType type : MorphType.values()){
         Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap();
 
         for(MorphType type : MorphType.values()){
@@ -146,7 +151,7 @@ public class PmdExporterExt1 extends PmdExporterBase{
      * @throws IllegalPmdTextException 文字列が長すぎる
      */
     private void dumpBoneGroupGlobal(PmdModel model)
      * @throws IllegalPmdTextException 文字列が長すぎる
      */
     private void dumpBoneGroupGlobal(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         for(BoneGroup group : model.getBoneGroupList()){
             if(group.isDefaultBoneGroup()) continue;
             String groupName = group.getGroupName().getGlobalText();
         for(BoneGroup group : model.getBoneGroupList()){
             if(group.isDefaultBoneGroup()) continue;
             String groupName = group.getGroupName().getGlobalText();
index 290c150..78fb5cd 100644 (file)
@@ -9,6 +9,7 @@ package jp.sourceforge.mikutoga.pmd.model.binio;
 
 import java.io.IOException;
 import java.io.OutputStream;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import jp.sourceforge.mikutoga.binio.IllegalTextExportException;
 import jp.sourceforge.mikutoga.pmd.model.PmdModel;
 import jp.sourceforge.mikutoga.pmd.model.ToonMap;
 import jp.sourceforge.mikutoga.pmd.parser.PmdLimits;
 import jp.sourceforge.mikutoga.pmd.model.PmdModel;
 import jp.sourceforge.mikutoga.pmd.model.ToonMap;
 import jp.sourceforge.mikutoga.pmd.parser.PmdLimits;
@@ -43,7 +44,11 @@ public class PmdExporterExt2 extends PmdExporterExt1{
             throws IOException, IllegalPmdException{
         super.dumpPmdModel(model);
 
             throws IOException, IllegalPmdException{
         super.dumpPmdModel(model);
 
-        dumpToonMap(model);
+        try{
+            dumpToonMap(model);
+        }catch(IllegalTextExportException e){
+            throw new IllegalPmdException(e);
+        }
 
         return;
     }
 
         return;
     }
@@ -55,7 +60,7 @@ public class PmdExporterExt2 extends PmdExporterExt1{
      * @throws IllegalPmdTextException トゥーンファイル名が長すぎる
      */
     private void dumpToonMap(PmdModel model)
      * @throws IllegalPmdTextException トゥーンファイル名が長すぎる
      */
     private void dumpToonMap(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         ToonMap map = model.getToonMap();
 
         for(int idx = 0; idx < PmdLimits.TOON_FIXEDNUM; idx++){
         ToonMap map = model.getToonMap();
 
         for(int idx = 0; idx < PmdLimits.TOON_FIXEDNUM; idx++){
index 2f978ec..d34bb1c 100644 (file)
@@ -10,6 +10,7 @@ package jp.sourceforge.mikutoga.pmd.model.binio;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.util.List;
+import jp.sourceforge.mikutoga.binio.IllegalTextExportException;
 import jp.sourceforge.mikutoga.pmd.Deg3d;
 import jp.sourceforge.mikutoga.pmd.Rad3d;
 import jp.sourceforge.mikutoga.pmd.RigidShapeType;
 import jp.sourceforge.mikutoga.pmd.Deg3d;
 import jp.sourceforge.mikutoga.pmd.Rad3d;
 import jp.sourceforge.mikutoga.pmd.RigidShapeType;
@@ -55,8 +56,12 @@ public class PmdExporterExt3 extends PmdExporterExt2{
             throws IOException, IllegalPmdException{
         super.dumpPmdModel(model);
 
             throws IOException, IllegalPmdException{
         super.dumpPmdModel(model);
 
-        dumpRigidList(model);
-        dumpJointList(model);
+        try{
+            dumpRigidList(model);
+            dumpJointList(model);
+        }catch(IllegalTextExportException e){
+            throw new IllegalPmdException(e);
+        }
 
         return;
     }
 
         return;
     }
@@ -68,7 +73,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{
      * @throws IllegalPmdTextException 長すぎる剛体名
      */
     private void dumpRigidList(PmdModel model)
      * @throws IllegalPmdTextException 長すぎる剛体名
      */
     private void dumpRigidList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         List<RigidInfo> rigidList = model.getRigidList();
         int rigidNum = rigidList.size();
         dumpInt(rigidNum);
         List<RigidInfo> rigidList = model.getRigidList();
         int rigidNum = rigidList.size();
         dumpInt(rigidNum);
@@ -89,7 +94,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{
      * @throws IllegalPmdTextException 長すぎる剛体名
      */
     private void dumpRigid(RigidInfo rigid)
      * @throws IllegalPmdTextException 長すぎる剛体名
      */
     private void dumpRigid(RigidInfo rigid)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         String rigidName = rigid.getRigidName().getPrimaryText();
         dumpText(rigidName, PmdLimits.MAXBYTES_RIGIDNAME);
 
         String rigidName = rigid.getRigidName().getPrimaryText();
         dumpText(rigidName, PmdLimits.MAXBYTES_RIGIDNAME);
 
@@ -172,7 +177,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{
      * @throws IllegalPmdTextException 長すぎるジョイント名
      */
     private void dumpJointList(PmdModel model)
      * @throws IllegalPmdTextException 長すぎるジョイント名
      */
     private void dumpJointList(PmdModel model)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         List<JointInfo> jointList = model.getJointList();
         int jointNum = jointList.size();
         dumpInt(jointNum);
         List<JointInfo> jointList = model.getJointList();
         int jointNum = jointList.size();
         dumpInt(jointNum);
@@ -193,7 +198,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{
      * @throws IllegalPmdTextException 長すぎるジョイント名
      */
     private void dumpJoint(JointInfo joint)
      * @throws IllegalPmdTextException 長すぎるジョイント名
      */
     private void dumpJoint(JointInfo joint)
-            throws IOException, IllegalPmdTextException{
+            throws IOException, IllegalTextExportException{
         String jointName = joint.getJointName().getPrimaryText();
         dumpText(jointName, PmdLimits.MAXBYTES_JOINTNAME);
 
         String jointName = joint.getJointName().getPrimaryText();
         dumpText(jointName, PmdLimits.MAXBYTES_JOINTNAME);