OSDN Git Service

パッケージ変更。テスト整備。
authorOlyutorskii <olyutorskii@users.osdn.me>
Sun, 17 Mar 2013 14:39:45 +0000 (23:39 +0900)
committerOlyutorskii <olyutorskii@users.osdn.me>
Sun, 17 Mar 2013 14:39:45 +0000 (23:39 +0900)
66 files changed:
CHANGELOG.txt
pom.xml
src/main/config/checks.xml
src/main/java/jp/sfjp/mikutoga/bin/export/BinaryExporter.java [moved from src/main/java/jp/sourceforge/mikutoga/binio/BinaryExporter.java with 83% similarity]
src/main/java/jp/sfjp/mikutoga/bin/export/IllegalTextExportException.java [moved from src/main/java/jp/sourceforge/mikutoga/binio/IllegalTextExportException.java with 97% similarity]
src/main/java/jp/sfjp/mikutoga/bin/export/TextExporter.java [moved from src/main/java/jp/sourceforge/mikutoga/binio/TextExporter.java with 96% similarity]
src/main/java/jp/sfjp/mikutoga/bin/export/package-info.java [new file with mode: 0644]
src/main/java/jp/sfjp/mikutoga/bin/parser/CommonParser.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/CommonParser.java with 73% similarity]
src/main/java/jp/sfjp/mikutoga/bin/parser/LoopHandler.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/LoopHandler.java with 71% similarity]
src/main/java/jp/sfjp/mikutoga/bin/parser/MmdEofException.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/MmdEofException.java with 93% similarity]
src/main/java/jp/sfjp/mikutoga/bin/parser/MmdFormatException.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/MmdFormatException.java with 91% similarity]
src/main/java/jp/sfjp/mikutoga/bin/parser/ParseStage.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/ParseStage.java with 59% similarity]
src/main/java/jp/sfjp/mikutoga/bin/parser/TextDecoder.java [new file with mode: 0644]
src/main/java/jp/sfjp/mikutoga/bin/parser/package-info.java [moved from src/main/java/jp/sourceforge/mikutoga/parser/package-info.java with 71% similarity]
src/main/java/jp/sfjp/mikutoga/corelib/I18nText.java [moved from src/main/java/jp/sourceforge/mikutoga/corelib/I18nText.java with 84% similarity]
src/main/java/jp/sfjp/mikutoga/corelib/package-info.java [moved from src/main/java/jp/sourceforge/mikutoga/corelib/package-info.java with 81% similarity]
src/main/java/jp/sfjp/mikutoga/math/EulerYXZ.java [moved from src/main/java/jp/sourceforge/mikutoga/math/EulerYXZ.java with 57% similarity]
src/main/java/jp/sfjp/mikutoga/math/MkPos2D.java [moved from src/main/java/jp/sourceforge/mikutoga/math/MkPos2D.java with 97% similarity]
src/main/java/jp/sfjp/mikutoga/math/MkPos3D.java [moved from src/main/java/jp/sourceforge/mikutoga/math/MkPos3D.java with 86% similarity]
src/main/java/jp/sfjp/mikutoga/math/MkQuat.java [moved from src/main/java/jp/sourceforge/mikutoga/math/MkQuat.java with 84% similarity]
src/main/java/jp/sfjp/mikutoga/math/MkVec3D.java [moved from src/main/java/jp/sourceforge/mikutoga/math/MkVec3D.java with 64% similarity]
src/main/java/jp/sfjp/mikutoga/math/package-info.java [moved from src/main/java/jp/sourceforge/mikutoga/math/package-info.java with 88% similarity]
src/main/java/jp/sourceforge/mikutoga/binio/FileUtils.java [deleted file]
src/main/java/jp/sourceforge/mikutoga/binio/package-info.java [deleted file]
src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java [deleted file]
src/main/java/jp/sourceforge/mikutoga/pmd/Deg3d.java
src/main/java/jp/sourceforge/mikutoga/pmd/Rad3d.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdBasicHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdBoneHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdEngHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdJointHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdMaterialHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdMorphHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdParserBase.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdParserExt1.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdParserExt2.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdParserExt3.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdRigidHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdShapeHandler.java
src/main/java/jp/sourceforge/mikutoga/pmd/parser/PmdToonHandler.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdBasicHandler.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdBasicParser.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdCameraHandler.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdCameraParser.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdLightingHandler.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdLightingParser.java
src/main/java/jp/sourceforge/mikutoga/vmd/parser/VmdParser.java
src/test/java/jp/sfjp/mikutoga/bin/export/BinaryExporterTest.java [moved from src/test/java/jp/sourceforge/mikutoga/binio/BinaryExporterTest.java with 88% similarity]
src/test/java/jp/sfjp/mikutoga/bin/export/IllegalTextExportExceptionTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/bin/export/TextExporterTest.java [moved from src/test/java/jp/sourceforge/mikutoga/binio/TextExporterTest.java with 84% similarity]
src/test/java/jp/sfjp/mikutoga/bin/parser/CommonParserTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/bin/parser/DummyInputStream.java [moved from src/test/java/jp/sourceforge/mikutoga/parser/DummyInputStream.java with 99% similarity]
src/test/java/jp/sfjp/mikutoga/bin/parser/MmdEofExceptionTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/bin/parser/MmdFormatExceptionTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/bin/parser/ParseStageTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/bin/parser/TextDecoderTest.java [moved from src/test/java/jp/sourceforge/mikutoga/parser/TextDecoderTest.java with 90% similarity]
src/test/java/jp/sfjp/mikutoga/corelib/I18nTextTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/math/EulerYXZTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/math/MkPos2DTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/math/MkPos3DTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/math/MkQuatTest.java [new file with mode: 0644]
src/test/java/jp/sfjp/mikutoga/math/MkVec3DTest.java [new file with mode: 0644]
src/test/java/sample/pmd/DummyHandler.java
src/test/java/sample/pmd/DummyMain.java
src/test/java/sample/vmd/DummyHandler.java
src/test/java/sample/vmd/DummyMain.java

index ce52a79..de44ca5 100644 (file)
@@ -5,7 +5,8 @@ TogaGem 変更履歴
 
 
 X.XXX.X (20XX-XX-XX)
-    ・
+    ・逆正接の分母に小さな値が来たときの判定を甘くした。
+    ・パッケージ構成を変更。
 
 2.102.2 (2013-03-17)
     ・Maven3対応。
diff --git a/pom.xml b/pom.xml
index 54292df..829fa97 100644 (file)
--- a/pom.xml
+++ b/pom.xml
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-plugin</artifactId>
-                <version>2.13</version>
+                <version>2.14</version>
                 <configuration>
                     <skipTests>false</skipTests>
                     <enableAssertions>true</enableAssertions>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>2.9.1</version>
+                <version>2.10</version>
                 <!-- config from property value -->
             </plugin>
 
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-surefire-report-plugin</artifactId>
-                <version>2.13</version>
+                <version>2.14</version>
                 <configuration>
                     <showSuccess>false</showSuccess>
                 </configuration>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
-                <version>2.9.1</version>
+                <version>2.10</version>
                 <configuration>
                     <skip>false</skip>
                     <!-- config from property value -->
index cf55cf6..445ddf4 100644 (file)
         <module name="ArrayTrailingComma" />
         <module name="AvoidInlineConditionals" />
         <module name="CovariantEquals" />
-        <module name="DoubleCheckedLocking" />
+<!--    <module name="DoubleCheckedLocking" />  5.6 obsolete -->
         <module name="EmptyStatement" />
         <module name="EqualsAvoidNull" />
         <module name="EqualsHashCode" />
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.io.ByteArrayOutputStream;
 import java.io.Closeable;
@@ -18,7 +18,7 @@ import java.text.MessageFormat;
 
 /**
  * バイナリデータの出力を行う汎用エクスポーター。
- * <p>デフォルトではリトルエンディアン形式で出力される。
+ * <p>基本的にリトルエンディアン形式で出力される。
  */
 public class BinaryExporter implements Closeable, Flushable{
 
@@ -30,9 +30,6 @@ public class BinaryExporter implements Closeable, Flushable{
               "too long text: "
             + "text \"{0}\" needs {1}bytes encoded but limit={2}bytes";
 
-    private static final int MASK_16 = 0xffff;
-    private static final int MASK_8  =   0xff;
-
     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_LONG   = Long    .SIZE / Byte.SIZE;
@@ -41,6 +38,32 @@ public class BinaryExporter implements Closeable, Flushable{
 
     private static final int BUFSZ_PRIM = BYTES_DOUBLE;
 
+    private static final int IDX0 = 0;
+    private static final int IDX1 = 1;
+    private static final int IDX2 = 2;
+    private static final int IDX3 = 3;
+    private static final int IDX4 = 4;
+    private static final int IDX5 = 5;
+    private static final int IDX6 = 6;
+    private static final int IDX7 = 7;
+
+    private static final int SH00 =  0;
+    private static final int SH08 =  8;
+    private static final int SH16 = 16;
+    private static final int SH24 = 24;
+    private static final int SH32 = 32;
+    private static final int SH40 = 40;
+    private static final int SH48 = 48;
+    private static final int SH56 = 56;
+
+    static{
+        assert BYTES_DOUBLE <= BUFSZ_PRIM;
+        assert BYTES_FLOAT  <= BUFSZ_PRIM;
+        assert BYTES_LONG   <= BUFSZ_PRIM;
+        assert BYTES_INT    <= BUFSZ_PRIM;
+        assert BYTES_SHORT  <= BUFSZ_PRIM;
+    }
+
 
     private final OutputStream ostream;
 
@@ -100,7 +123,7 @@ public class BinaryExporter implements Closeable, Flushable{
      * @throws IOException 出力エラー
      */
     public BinaryExporter dumpByte(byte bVal) throws IOException{
-        this.ostream.write((int)bVal);
+        this.ostream.write(bVal);
         return this;
     }
 
@@ -123,7 +146,7 @@ public class BinaryExporter implements Closeable, Flushable{
      */
     public BinaryExporter dumpByteArray(byte[] array)
             throws IOException{
-        dumpByteArray(array, 0, array.length);
+        this.ostream.write(array);
         return this;
     }
 
@@ -149,8 +172,8 @@ public class BinaryExporter implements Closeable, Flushable{
      */
     @SuppressWarnings("PMD.AvoidUsingShortType")
     public BinaryExporter dumpLeShort(short sVal) throws IOException{
-        this.barray[0] = (byte)( (sVal >>  0) & MASK_8 );
-        this.barray[1] = (byte)( (sVal >>  8) & MASK_8 );
+        this.barray[IDX0] = (byte)(sVal >>> SH00);
+        this.barray[IDX1] = (byte)(sVal >>> SH08);
 
         this.ostream.write(this.barray, 0, BYTES_SHORT);
 
@@ -165,7 +188,7 @@ public class BinaryExporter implements Closeable, Flushable{
      */
     @SuppressWarnings("PMD.AvoidUsingShortType")
     public BinaryExporter dumpLeShort(int iVal) throws IOException{
-        short sVal = (short)(iVal & MASK_16);
+        short sVal = (short)iVal;
         dumpLeShort(sVal);
         return this;
     }
@@ -177,10 +200,10 @@ public class BinaryExporter implements Closeable, Flushable{
      * @throws IOException 出力エラー
      */
     public BinaryExporter dumpLeInt(int iVal) throws IOException{
-        this.barray[0] = (byte)( (iVal >>  0) & MASK_8 );
-        this.barray[1] = (byte)( (iVal >>  8) & MASK_8 );
-        this.barray[2] = (byte)( (iVal >> 16) & MASK_8 );
-        this.barray[3] = (byte)( (iVal >> 24) & MASK_8 );
+        this.barray[IDX0] = (byte)(iVal >>> SH00);
+        this.barray[IDX1] = (byte)(iVal >>> SH08);
+        this.barray[IDX2] = (byte)(iVal >>> SH16);
+        this.barray[IDX3] = (byte)(iVal >>> SH24);
 
         this.ostream.write(this.barray, 0, BYTES_INT);
 
@@ -194,14 +217,14 @@ public class BinaryExporter implements Closeable, Flushable{
      * @throws IOException 出力エラー
      */
     public BinaryExporter dumpLeLong(long lVal) throws IOException{
-        this.barray[0] = (byte)( (lVal >>  0) & 0xffL );
-        this.barray[1] = (byte)( (lVal >>  8) & 0xffL );
-        this.barray[2] = (byte)( (lVal >> 16) & 0xffL );
-        this.barray[3] = (byte)( (lVal >> 24) & 0xffL );
-        this.barray[4] = (byte)( (lVal >> 32) & 0xffL );
-        this.barray[5] = (byte)( (lVal >> 40) & 0xffL );
-        this.barray[6] = (byte)( (lVal >> 48) & 0xffL );
-        this.barray[7] = (byte)( (lVal >> 56) & 0xffL );
+        this.barray[IDX0] = (byte)(lVal >>> SH00);
+        this.barray[IDX1] = (byte)(lVal >>> SH08);
+        this.barray[IDX2] = (byte)(lVal >>> SH16);
+        this.barray[IDX3] = (byte)(lVal >>> SH24);
+        this.barray[IDX4] = (byte)(lVal >>> SH32);
+        this.barray[IDX5] = (byte)(lVal >>> SH40);
+        this.barray[IDX6] = (byte)(lVal >>> SH48);
+        this.barray[IDX7] = (byte)(lVal >>> SH56);
 
         this.ostream.write(this.barray, 0, BYTES_LONG);
 
@@ -216,14 +239,7 @@ public class BinaryExporter implements Closeable, Flushable{
      */
     public BinaryExporter dumpLeFloat(float fVal) throws IOException{
         int rawiVal = Float.floatToRawIntBits(fVal);
-
-        this.barray[0] = (byte)( (rawiVal >>  0) & MASK_8 );
-        this.barray[1] = (byte)( (rawiVal >>  8) & MASK_8 );
-        this.barray[2] = (byte)( (rawiVal >> 16) & MASK_8 );
-        this.barray[3] = (byte)( (rawiVal >> 24) & MASK_8 );
-
-        this.ostream.write(this.barray, 0, BYTES_FLOAT);
-
+        dumpLeInt(rawiVal);
         return this;
     }
 
@@ -235,18 +251,7 @@ public class BinaryExporter implements Closeable, Flushable{
      */
     public BinaryExporter dumpLeDouble(double dVal) throws IOException{
         long rawlVal = Double.doubleToRawLongBits(dVal);
-
-        this.barray[0] = (byte)( (rawlVal >>  0) & MASK_8 );
-        this.barray[1] = (byte)( (rawlVal >>  8) & MASK_8 );
-        this.barray[2] = (byte)( (rawlVal >> 16) & MASK_8 );
-        this.barray[3] = (byte)( (rawlVal >> 24) & MASK_8 );
-        this.barray[4] = (byte)( (rawlVal >> 32) & MASK_8 );
-        this.barray[5] = (byte)( (rawlVal >> 40) & MASK_8 );
-        this.barray[6] = (byte)( (rawlVal >> 48) & MASK_8 );
-        this.barray[7] = (byte)( (rawlVal >> 56) & MASK_8 );
-
-        this.ostream.write(this.barray, 0, BYTES_DOUBLE);
-
+        dumpLeLong(rawlVal);
         return this;
     }
 
@@ -345,6 +350,7 @@ public class BinaryExporter implements Closeable, Flushable{
             encodedSize =
                     this.texporter_u16le.encodeToByteStream(text, this.xos);
         }catch(CharacterCodingException e){
+            assert false;  // これはない
             throw new IllegalTextExportException(ERRMSG_ILLENC, e);
         }
 
@@ -352,6 +358,7 @@ public class BinaryExporter implements Closeable, Flushable{
 
         this.xos.writeTo(this.ostream);
         int xferred = this.xos.size();
+
         assert xferred == encodedSize;
 
         return xferred;
@@ -5,12 +5,13 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.nio.charset.CharacterCodingException;
 
 /**
  * バイナリファイルへの不正なテキスト情報の出力が検出された場合の例外。
+ * <p>
  * {@link java.nio.charset.CharacterCodingException}に由来する異常系を
  * {@link java.io.IOException}から分離するために設計された。
  * <p>
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -49,9 +49,13 @@ public class TextExporter {
 
         if(encoder == null) throw new NullPointerException();
         this.encoder = encoder;
+        this.encoder.reset();
         this.encoder.onMalformedInput(CodingErrorAction.REPORT);
         this.encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
 
+        this.cbuf.clear();
+        this.bbuf.clear();
+
         return;
     }
 
@@ -80,8 +84,10 @@ public class TextExporter {
     public void setCharBufSize(int newSize)
             throws IllegalArgumentException {
         if(newSize <= 0) throw new IllegalArgumentException();
+
         this.cbuf = CharBuffer.allocate(newSize);
         this.cbuf.clear();
+
         return;
     }
 
@@ -96,9 +102,11 @@ public class TextExporter {
         float ratio = this.encoder.maxBytesPerChar();
         int minSz = (int)( StrictMath.floor(ratio) );
         if(newSize < minSz) throw new IllegalArgumentException();
+
         this.barray = new byte[newSize];
         this.bbuf = ByteBuffer.wrap(this.barray);
         this.bbuf.clear();
+
         return;
     }
 
@@ -185,7 +193,8 @@ public class TextExporter {
 
     /**
      * 入力バッファに文字を埋める。
-     * <p>入力バッファが一杯になるか入力文字列がなくなるまでバッファが埋められる。
+     * <p>入力バッファが一杯になるか
+     * 入力文字列がなくなるまでバッファが埋められる。
      */
     private void loadCharBuffer(){
         while(this.cbuf.hasRemaining() && hasMoreInput()){
diff --git a/src/main/java/jp/sfjp/mikutoga/bin/export/package-info.java b/src/main/java/jp/sfjp/mikutoga/bin/export/package-info.java
new file mode 100644 (file)
index 0000000..ed0d91e
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * binary data output
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+/**
+ * バイナリデータの出力を補佐する一連のクラス。
+ */
+
+package jp.sfjp.mikutoga.bin.export;
+
+/* EOF */
@@ -5,7 +5,7 @@
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -13,12 +13,22 @@ import java.io.InputStream;
 import java.io.PushbackInputStream;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.MalformedInputException;
+import java.nio.charset.UnmappableCharacterException;
 
 /**
- * 各種パーサの共通実装。
+ * 各種バイナリファイルパーサの共通実装。
+ * <p>バイト列、各種プリミティブ型値およびエンコードされた文字列を読み込む。
+ * <p>long,double、およびビッグエンディアン形式のデータは未サポート。
  */
 public class CommonParser {
 
+    private static final String ERRMSG_ILLENC =
+            "illegal character encoding";
+    private static final String ERRMSG_UNMAP =
+            "unmapped character";
+
     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;
@@ -37,11 +47,13 @@ public class CommonParser {
     private final PushbackInputStream is;
 
     private final byte[] readBuffer;
-    private final ByteBuffer beBuf;
+//  private final ByteBuffer beBuf;
     private final ByteBuffer leBuf;
 
     private long position = 0L;
 
+    private ByteBuffer btextBuf;
+
 
     /**
      * コンストラクタ。
@@ -54,10 +66,10 @@ public class CommonParser {
 
         this.readBuffer = new byte[BYTES_PRIM];
 
-        this.beBuf = ByteBuffer.wrap(this.readBuffer);
+//      this.beBuf = ByteBuffer.wrap(this.readBuffer);
         this.leBuf = ByteBuffer.wrap(this.readBuffer);
 
-        this.beBuf.order(ByteOrder.BIG_ENDIAN);
+//      this.beBuf.order(ByteOrder.BIG_ENDIAN);
         this.leBuf.order(ByteOrder.LITTLE_ENDIAN);
 
         return;
@@ -153,7 +165,7 @@ public class CommonParser {
 
     /**
      * byte配列を読み込む。
-     * 配列要素全ての読み込みが試みられる。
+     * <p>配列要素全ての読み込みが試みられる。
      * @param dst 格納先配列
      * @throws IOException IOエラー
      * @throws NullPointerException 配列がnull
@@ -168,9 +180,9 @@ public class CommonParser {
 
     /**
      * 内部バッファへ指定バイト数だけ読み込む。
-     * @param fillSize
-     * @throws IOException
-     * @throws MmdEofException
+     * @param fillSize バイト長
+     * @throws IOException IOエラー
+     * @throws MmdEofException 読み込む途中でストリーム終端に達した。
      */
     private void fillBuffer(int fillSize)
             throws IOException, MmdEofException {
@@ -199,19 +211,19 @@ public class CommonParser {
 
     /**
      * 符号無し値としてbyte値を読み込み、int型に変換して返す。
-     * 符号は拡張されない。(0xffは0x000000ffとなる)
+     * <p>符号は拡張されない。(0xffは0x000000ffとなる)
      * @return 読み込まれた値のint値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
      */
     protected int parseUByteAsInt()
             throws IOException, MmdEofException{
-        return ((int) parseByte()) & MASK_8BIT;
+        return parseByte() & MASK_8BIT;
     }
 
     /**
      * byte値を読み込み、boolean型に変換して返す。
-     * 0x00は偽、それ以外は真と解釈される。
+     * <p>0x00は偽、それ以外は真と解釈される。
      * @return 読み込まれた値のboolean値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
@@ -225,7 +237,7 @@ public class CommonParser {
 
     /**
      * short値を読み込む。
-     * short値はリトルエンディアンで格納されていると仮定される。
+     * <p>short値はリトルエンディアンで格納されていると仮定される。
      * @return 読み込んだshort値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
@@ -239,20 +251,20 @@ public class CommonParser {
 
     /**
      * 符号無し値としてshort値を読み込み、int型に変換して返す。
-     * 符号は拡張されない。(0xffffは0x0000ffffとなる)
-     * short値はリトルエンディアンで格納されていると仮定される。
+     * <p>符号は拡張されない。(0xffffは0x0000ffffとなる)
+     * <p>short値はリトルエンディアンで格納されていると仮定される。
      * @return 読み込まれた値のint値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
      */
     protected int parseLeUShortAsInt()
             throws IOException, MmdEofException{
-        return ((int) parseLeShort()) & MASK_16BIT;
+        return parseLeShort() & MASK_16BIT;
     }
 
     /**
      * int値を読み込む。
-     * int値はリトルエンディアンで格納されていると仮定される。
+     * <p>int値はリトルエンディアンで格納されていると仮定される。
      * @return 読み込んだint値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
@@ -266,7 +278,7 @@ public class CommonParser {
 
     /**
      * float値を読み込む。
-     * float値はリトルエンディアンで格納されていると仮定される。
+     * <p>float値はリトルエンディアンで格納されていると仮定される。
      * @return 読み込んだfloat値
      * @throws IOException IOエラー
      * @throws MmdEofException 読み込む途中でストリーム終端に達した。
@@ -289,10 +301,39 @@ public class CommonParser {
      */
     protected String parseString(TextDecoder decoder, int byteLen)
             throws IOException, MmdEofException, MmdFormatException {
-        byte[] buf = decoder.prepareBuffer(byteLen);
+        if(this.btextBuf == null || this.btextBuf.capacity() < byteLen){
+            this.btextBuf = ByteBuffer.allocate(byteLen);
+        }
+
+        byte[] buf = this.btextBuf.array();
+        this.btextBuf.clear();
         parseByteArray(buf, 0, byteLen);
-        long basePos = getPosition();
-        String result= decoder.decode(basePos, byteLen);
+        this.btextBuf.limit(byteLen);
+
+        String result;
+
+        try{
+            result = decoder.decode(this.btextBuf);
+        }catch(UnmappableCharacterException e){
+            String errmsg = ERRMSG_UNMAP;
+            long errpos = getPosition() - byteLen + e.getInputLength();
+            MmdFormatException ex = new MmdFormatException(errmsg, errpos);
+            ex.initCause(e);
+            throw ex;
+        }catch(MalformedInputException e){
+            String errmsg = ERRMSG_ILLENC;
+            long errpos = getPosition() - byteLen + e.getInputLength();
+            MmdFormatException ex = new MmdFormatException(errmsg, errpos);
+            ex.initCause(e);
+            throw ex;
+        }catch(CharacterCodingException e){  // 状況不明
+            String errmsg = ERRMSG_ILLENC;
+            long errpos = getPosition();
+            MmdFormatException ex = new MmdFormatException(errmsg, errpos);
+            ex.initCause(e);
+            throw ex;
+        }
+
         return result;
     }
 
@@ -5,17 +5,17 @@
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 /**
- * ループ構造の通知用ハンドラ。
- * ステージ指定により、多重ネストループをもサポートする。
+ * ã\83\90ã\82¤ã\83\8aã\83ªã\83\95ã\82¡ã\82¤ã\83«ä¸­ã\83«ã\83¼ã\83\97æ§\8bé\80 ã\81®é\80\9aç\9f¥ç\94¨ã\83\8fã\83³ã\83\89ã\83©ã\80\82
+ * <p>ステージ指定により、多重ネストループをもサポートする。
  */
 public interface LoopHandler {
 
     /**
      * ループ構造開始の通知を受け取る。
-     * 0回ループの場合も含め一度呼ばれる。
+     * <p>0回ループの場合も含め一度呼ばれる。
      * @param stage ループ種別
      * @param loops ループ予定回数。未知の場合は負の値。
      * @throws MmdFormatException 不正フォーマットによる
@@ -25,7 +25,8 @@ public interface LoopHandler {
 
     /**
      * ループ構造の1イテレーション終了の通知を受け取る。
-     * 1度しか回らないループでも呼ばれる。0回ループでは決して呼ばれない。
+     * <p>1度しか回らないループでも呼ばれる。
+     * 0回ループでは決して呼ばれない。
      * @param stage ループ種別
      * @throws MmdFormatException 不正フォーマットによる
      * パース処理の中断をパーサに指示
@@ -34,7 +35,7 @@ public interface LoopHandler {
 
     /**
      * ループ構造終了の通知を受け取る。
-     * 0回ループの場合も含め一度呼ばれる。
+     * <p>0回ループの場合も含め一度呼ばれる。
      * @param stage ループ種別
      * @throws MmdFormatException 不正フォーマットによる
      * パース処理の中断をパーサに指示
@@ -1,11 +1,11 @@
 /*
- * unexpected file EOF founded exception
+ * unexpected binary-file EOF founded exception
  *
  * License : The MIT License
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 /**
  * 入力ソースが予期せずに終了した異常系。
@@ -1,15 +1,15 @@
 /*
- * unexpected file format founded exception
+ * unexpected binary-file format founded exception
  *
  * License : The MIT License
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 /**
  * MMD関連ファイルのパース異常系。
- * 必要に応じて、パースに失敗した位置を保持する。
+ * <p>必要に応じて、パースに失敗した位置を保持する。
  */
 @SuppressWarnings("serial")
 public class MmdFormatException extends Exception {
@@ -57,7 +57,8 @@ public class MmdFormatException extends Exception {
 
     /**
      * {@inheritDoc}
-     * 有効なエラー発生位置を保持している場合、追加出力される。
+     * 有効なエラー発生位置を保持している場合、
+     * エラー文字列に追加出力される。
      * @return {@inheritDoc}
      */
     @Override
@@ -5,26 +5,28 @@
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
  * パース処理の進行ステージ種別を表す。
- * ループ構造の識別に用いられる。
+ * <p>ループ構造の識別に用いられる。
+ * <p>enum型と異なり、実行時での要素の追加が可能。
  */
 public class ParseStage {
 
-    private static final AtomicInteger lastNo = new AtomicInteger(0);
+    private static final AtomicInteger LAST_NO = new AtomicInteger(0);
 
-    private final int no;
+    /** 全インスタンスに割り振られたユニークな番号。変更不可。 */
+    public final int no;
 
     /**
      * コンストラクタ。
      */
     public ParseStage(){
         super();
-        this.no = lastNo.getAndIncrement();
+        this.no = LAST_NO.getAndIncrement();
         assert this.no >= 0;
         return;
     }
diff --git a/src/main/java/jp/sfjp/mikutoga/bin/parser/TextDecoder.java b/src/main/java/jp/sfjp/mikutoga/bin/parser/TextDecoder.java
new file mode 100644 (file)
index 0000000..20095fb
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+ * character decoder
+ *
+ * License : The MIT License
+ * Copyright(c) 2011 MikuToga Partners
+ */
+
+package jp.sfjp.mikutoga.bin.parser;
+
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
+
+/**
+ * 文字デコーダー。
+ * <p>あらかじめバイト長が既知であるバイトバッファを読み取り、
+ * 文字列へのデコード結果を返す。
+ * <p>デコード対象のバイト列が全てメモリ上に展開される必要があるので、
+ * 巨大なテキストのデコードには不適当。
+ * <p>入力バイト値0x00以降をデコード処理の対象から外す
+ * 「ゼロチョップモード」を備える。
+ * デフォルトではゼロチョップモードはオフ。
+ * ゼロチョップモードはUTF16などのデコーディング時に使ってはならない。
+ */
+public class TextDecoder {
+
+    private final CharsetDecoder decoder;
+
+    private CharBuffer charBuffer;
+
+    private boolean chopZero = false;
+
+
+    /**
+     * コンストラクタ。
+     * @param cs キャラクタセット
+     */
+    public TextDecoder(Charset cs){
+        this(cs.newDecoder());
+        return;
+    }
+
+    /**
+     * コンストラクタ。
+     * @param decoder デコーダ
+     */
+    public TextDecoder(CharsetDecoder decoder){
+        super();
+
+        this.decoder = decoder;
+        this.decoder.reset();
+        this.decoder.onMalformedInput     (CodingErrorAction.REPORT);
+        this.decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
+
+        return;
+    }
+
+    /**
+     * 指定されたバイト長のデコードに必要な出力バッファを用意する。
+     * <p>既存バッファで足りなければ新たに確保し直す。
+     * @param byteLength 入力バイト長
+     * @return 出力バッファ長。(キャラクタ単位)
+     */
+    protected int prepareCharBuffer(int byteLength){
+        float maxCharsPerByte = this.decoder.maxCharsPerByte();
+        int maxChars = (int)( byteLength * maxCharsPerByte ) + 1;
+
+        if(this.charBuffer != null){
+            int capacity = this.charBuffer.capacity();
+            if(capacity >= maxChars){
+                return capacity;
+            }
+        }
+
+        this.charBuffer = CharBuffer.allocate(maxChars);
+
+        return maxChars;
+    }
+
+    /**
+     * ゼロチョップモードを設定する。
+     * ゼロチョップモードをオンにすると、
+     * 入力バイト値0x00以降はデコード対象外となる。
+     * @param chop trueならゼロチョップモードオン
+     */
+    public void setZeroChopMode(boolean chop){
+        this.chopZero = chop;
+        return;
+    }
+
+    /**
+     * ゼロチョップモードか否か判定する。
+     * @return ゼロチョップモードならtrue
+     */
+    public boolean isZeroChopMode(){
+        return this.chopZero;
+    }
+
+    /**
+     * 入力バイトバッファのバイト値'0'出現以降をチョップする。
+     * ゼロチョップモードでなければ何もしない。
+     * @param bBuf 入力バイトバッファ
+     */
+    protected void chopZeroTermed(ByteBuffer bBuf){
+        if( ! this.chopZero ) return;
+
+        int start = bBuf.position();
+        int limit = bBuf.limit();
+        for(int idx = start; idx < limit; idx++){
+            byte bVal = bBuf.get(idx);
+            if(bVal == 0x00){
+                bBuf.limit(idx);
+                break;
+            }
+        }
+
+        return;
+    }
+
+    /**
+     * バイトバッファの文字列デコードを行う。
+     * @param bBuf バイトバッファ
+     * @return デコードされた文字列
+     * @throws CharacterCodingException デコード異常
+     */
+    public String decode(ByteBuffer bBuf) throws CharacterCodingException{
+        chopZeroTermed(bBuf);
+
+        int blen = bBuf.remaining();
+        prepareCharBuffer(blen);
+        this.charBuffer.clear();
+
+        this.decoder.reset();
+        CoderResult decResult;
+        decResult = this.decoder.decode(bBuf, this.charBuffer, true);
+
+        if(decResult.isError()){
+            decResult.throwException();
+            assert false;
+        }
+
+        assert ! decResult.isOverflow();
+
+        String result = this.charBuffer.flip().toString();
+        return result;
+    }
+
+}
@@ -6,12 +6,12 @@
  */
 
 /**
- * MMD用各種パーサ共通ライブラリ。
+ * MMDç\94¨å\90\84種ã\83\90ã\82¤ã\83\8aã\83ªã\83\95ã\82¡ã\82¤ã\83«ã\83\91ã\83¼ã\82µå\85±é\80\9aã\83©ã\82¤ã\83\96ã\83©ã\83ªã\80\82
  * <p>
  * PMDモデルファイルやVMDモーションファイルなどの個別のパーサは
  * 別パッケージにより提供される。
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
 /* EOF */
@@ -1,15 +1,14 @@
 /*
- * international text
+ * internationalization text
  *
  * License : The MIT License
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.corelib;
+package jp.sfjp.mikutoga.corelib;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -17,8 +16,10 @@ import java.util.Set;
 
 /**
  * 多言語のバリアントを持つ文字列情報。
+ * 言語はISO639言語コードで区別される。
  * <ul>
- * <li>プライマリ:識別子にはこちらを使う。基本は日本語。
+ * <li>プライマリ:識別子にはこちらを使う。
+ * 基本はMMD発祥の地に敬意を表して日本語。
  * <li>グローバル:基本は英語。UCS Basic-Latinオンリーの貧弱な言語環境でも
  * 読める文字列が望ましい。
  * <li>その他:必要に応じて好きな言語を。
@@ -28,20 +29,28 @@ public class I18nText implements CharSequence {
 
     /** プライマリ言語のロケール。 */
     public static final Locale LOCALE_PRIMARY = Locale.JAPANESE;
-    /** プライマリ言語の言語コード。 */
-    public static final String CODE639_PRIMARY = LOCALE_PRIMARY.getLanguage();
+    /** プライマリ言語のISO639言語コード。 */
+    public static final String CODE639_PRIMARY =
+            LOCALE_PRIMARY.getLanguage();
 
     /** グローバル言語のロケール。 */
     public static final Locale LOCALE_GLOBAL = Locale.ENGLISH;
-    /** グローバル言語の言語コード。 */
-    public static final String CODE639_GLOBAL = LOCALE_GLOBAL.getLanguage();
+    /** グローバル言語のISO639言語コード。 */
+    public static final String CODE639_GLOBAL =
+            LOCALE_GLOBAL.getLanguage();
 
     static{
         assert "ja".equals(CODE639_PRIMARY);
         assert "en".equals(CODE639_GLOBAL);
     }
 
-    private final Map<String, String> nameMap = new HashMap<String, String>();
+
+    /**
+     * キーはISO639、値は多言語テキスト。
+     */
+    private final Map<String, String> nameMap =
+            new HashMap<String, String>();
+
 
     /**
      * コンストラクタ。
@@ -146,8 +155,9 @@ public class I18nText implements CharSequence {
 
     /**
      * プライマリ文字列を返す。
-     * 見つからなければグローバル文字列を返す。
-     * それでも見つからなければ空文字列を返す。
+     * <p>見つからなければグローバル文字列を返す。
+     * それでも見つからなければ長さ0の空文字列を返す。
+     * <p>※決してnullは返さない。
      * @return 文字列
      */
     public String getText(){
@@ -168,10 +178,11 @@ public class I18nText implements CharSequence {
 
     /**
      * 実行環境のデフォルトロケールに応じた文字列を返す。
-     * 見つからなければグローバル文字列、プライマリ文字列の順に返す。
+     * <p>見つからなければグローバル文字列、プライマリ文字列の順に返す。
      * それでも見つからなければ適当な言語コードの文字列を返す。
      * それでも見つからなければ長さ0の空文字列を返す。
-     * デフォルトロケールの確認はその都度行われる。
+     * <p>デフォルトロケールの確認はその都度行われる。
+     * <p>※決してnullは返さない。
      * @return 文字列
      */
     public String getLocalizedText(){
@@ -192,9 +203,7 @@ public class I18nText implements CharSequence {
 
         if(result == null){
             Set<String> langSet = this.nameMap.keySet();
-            Iterator<String> it = langSet.iterator();
-            while(it.hasNext()){
-                String lang = it.next();
+            for(String lang : langSet){
                 result = this.nameMap.get(lang);
                 if(result != null) break;
             }
@@ -261,7 +270,7 @@ public class I18nText implements CharSequence {
 
     /**
      * {@inheritDoc}
-     * {@link #getText()}に準ずる。
+     * {@link #getText()}仕様に準ずる。
      * @param index {@inheritDoc}
      * @return {@inheritDoc}
      */
@@ -274,7 +283,7 @@ public class I18nText implements CharSequence {
 
     /**
      * {@inheritDoc}
-     * {@link #getText()}に準ずる。
+     * {@link #getText()}仕様に準ずる。
      * @return {@inheritDoc}
      */
     @Override
@@ -286,7 +295,7 @@ public class I18nText implements CharSequence {
 
     /**
      * {@inheritDoc}
-     * {@link #getText()}に準ずる。
+     * {@link #getText()}仕様に準ずる。
      * @param start {@inheritDoc}
      * @param end {@inheritDoc}
      * @return {@inheritDoc}
@@ -300,7 +309,7 @@ public class I18nText implements CharSequence {
 
     /**
      * {@inheritDoc}
-     * {@link #getText()}に準ずる。
+     * {@link #getText()}仕様に準ずる。
      * @return {@inheritDoc}
      */
     @Override
@@ -9,6 +9,6 @@
  * MikuToga共通基盤ライブラリ。
  */
 
-package jp.sourceforge.mikutoga.corelib;
+package jp.sfjp.mikutoga.corelib;
 
 /* EOF */
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.math;
+package jp.sfjp.mikutoga.math;
 
 /**
  * YXZオイラー角。
@@ -69,58 +69,84 @@ public strictfp class EulerYXZ {
 
     /**
      * X軸回転量を設定する。
-     * @param xRot X軸回転量。(ラジアン)
+     * @param xRotArg X軸回転量。(ラジアン)
      */
-    public void setXRot(double xRot){
-        this.xRot = xRot;
+    public void setXRot(double xRotArg){
+        this.xRot = xRotArg;
         return;
     }
 
     /**
      * Y軸回転量を設定する。
-     * @param yRot Y軸回転量。(ラジアン)
+     * @param yRotArg Y軸回転量。(ラジアン)
      */
-    public void setYRot(double yRot){
-        this.yRot = yRot;
+    public void setYRot(double yRotArg){
+        this.yRot = yRotArg;
         return;
     }
 
     /**
      * Z軸回転量を設定する。
-     * @param zRot Z軸回転量。(ラジアン)
+     * @param zRotArg Z軸回転量。(ラジアン)
      */
-    public void setZRot(double zRot){
-        this.zRot = zRot;
+    public void setZRot(double zRotArg){
+        this.zRot = zRotArg;
         return;
     }
 
     /**
-     * {@inheritDoc}
-     * @return {@inheritDoc}
+     * 三軸の回転量を設定する。
+     * @param xRotArg X軸回転量。(ラジアン)
+     * @param yRotArg Y軸回転量。(ラジアン)
+     * @param zRotArg Z軸回転量。(ラジアン)
      */
-    @Override
-    public String toString(){
+    public void setRot(double xRotArg, double yRotArg, double zRotArg){
+        this.xRot = xRotArg;
+        this.yRot = yRotArg;
+        this.zRot = zRotArg;
+        return;
+    }
+
+    /**
+     * パラメータ情報の文字列化。
+     * @param x x値
+     * @param y y値
+     * @param z z値
+     * @return 文字列
+     */
+    private static String toString(double x, double y, double z){
         StringBuilder result = new StringBuilder();
 
-        result.append("x=") .append(this.xRot);
-        result.append(" y=").append(this.yRot);
-        result.append(" z=").append(this.zRot);
+        result.append("x=") .append(x);
+        result.append(" y=").append(y);
+        result.append(" z=").append(z);
 
         return result.toString();
     }
 
     /**
+     * {@inheritDoc}
+     * @return {@inheritDoc}
+     */
+    @Override
+    public String toString(){
+        String result;
+        result = toString(this.xRot, this.yRot, this.zRot);
+        return result;
+    }
+
+    /**
      * 度数法による文字列表現を返す。
      * @return 文字列表現
      */
     public String toDegString(){
-        StringBuilder result = new StringBuilder();
-
-        result.append("x=") .append(StrictMath.toDegrees(this.xRot));
-        result.append(" y=").append(StrictMath.toDegrees(this.yRot));
-        result.append(" z=").append(StrictMath.toDegrees(this.zRot));
+        double xDeg = StrictMath.toDegrees(this.xRot);
+        double yDeg = StrictMath.toDegrees(this.yRot);
+        double zDeg = StrictMath.toDegrees(this.zRot);
 
-        return result.toString();
+        String result;
+        result = toString(xDeg, yDeg, zDeg);
+        return result;
     }
 
 }
@@ -5,14 +5,14 @@
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.math;
+package jp.sfjp.mikutoga.math;
 
 /**
  * 二次元空間座標及び変量を表す。
  * <p>直交座標を二つの倍精度値で表す。
  * <p>主な用途はUVマッピングなど。
  */
-public class MkPos2D {
+public strictfp class MkPos2D {
 
     private double xPos;
     private double yPos;
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.math;
+package jp.sfjp.mikutoga.math;
 
 /**
  * 三次元位置情報。
@@ -23,12 +23,22 @@ public strictfp class MkPos3D {
      * コンストラクタ。
      */
     public MkPos3D(){
-        this.xPos = 0.0;
-        this.yPos = 0.0;
-        this.zPos = 0.0;
+        this(0.0, 0.0, 0.0);
         return;
     }
 
+    /**
+     * コンストラクタ。
+     * @param xPosArg X軸座標
+     * @param yPosArg Y軸座標
+     * @param zPosArg Z軸座標
+     */
+    public MkPos3D(double xPosArg, double yPosArg, double zPosArg){
+        this.xPos = xPosArg;
+        this.yPos = yPosArg;
+        this.zPos = zPosArg;
+        return;
+    }
 
     /**
      * X軸座標を返す。
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.math;
+package jp.sfjp.mikutoga.math;
 
 /**
  * クォータニオンによる回転表現。
@@ -14,6 +14,12 @@ package jp.sourceforge.mikutoga.math;
 public strictfp class MkQuat {
 
     private static final double HALF_PI = StrictMath.PI / 2.0;
+    private static final double EPSILON = StrictMath.ulp(1.0);
+    private static final double TDELTA = EPSILON * 4;
+
+    static{
+        assert StrictMath.ulp(StrictMath.PI) <= TDELTA;
+    }
 
 
     private double q1;
@@ -134,7 +140,8 @@ public strictfp class MkQuat {
 
     /**
      * 逆元クォータニオンを求め格納する。
-     * <p>対象クォータニオンの絶対値が小さい場合、無限大が虚部実部に入る可能性がある。
+     * <p>対象クォータニオンの絶対値が小さい場合、
+     * 無限大が虚部実部に入る可能性がある。
      * <p>引数は同一インスタンスでもよい。
      * @param q クォータニオン
      * @param result 格納先
@@ -194,37 +201,53 @@ public strictfp class MkQuat {
 
     /**
      * 虚部1を設定する。
-     * @param q1 虚部1
+     * @param q1Arg 虚部1
      */
-    public void setQ1(double q1) {
-        this.q1 = q1;
+    public void setQ1(double q1Arg) {
+        this.q1 = q1Arg;
         return;
     }
 
     /**
      * 虚部2を設定する。
-     * @param q2 虚部2
+     * @param q2Arg 虚部2
      */
-    public void setQ2(double q2) {
-        this.q2 = q2;
+    public void setQ2(double q2Arg) {
+        this.q2 = q2Arg;
         return;
     }
 
     /**
      * 虚部3を設定する。
-     * @param q3 虚部3
+     * @param q3Arg 虚部3
      */
-    public void setQ3(double q3) {
-        this.q3 = q3;
+    public void setQ3(double q3Arg) {
+        this.q3 = q3Arg;
         return;
     }
 
     /**
      * 実部を設定する。
-     * @param w 実部
+     * @param wArg 実部
+     */
+    public void setQW(double wArg) {
+        this.qw = wArg;
+        return;
+    }
+
+    /**
+     * 虚部実部を設定する。
+     * @param q1Arg 虚部1
+     * @param q2Arg 虚部2
+     * @param q3Arg 虚部3
+     * @param wArg 実部
      */
-    public void setQW(double w) {
-        this.qw = w;
+    public void setQ123W(double q1Arg, double q2Arg, double q3Arg,
+                          double wArg ){
+        this.q1 = q1Arg;
+        this.q2 = q2Arg;
+        this.q3 = q3Arg;
+        this.qw = wArg;
         return;
     }
 
@@ -250,7 +273,7 @@ public strictfp class MkQuat {
      * @param yPos Y位置
      * @param zPos Z位置
      */
-    public void readPos3D(double xPos, double yPos, double zPos){
+    public void setPos3D(double xPos, double yPos, double zPos){
         this.q1 = xPos;
         this.q2 = yPos;
         this.q3 = zPos;
@@ -264,19 +287,20 @@ public strictfp class MkQuat {
      * <p>実部には0が入る。
      * @param pos 位置情報
      */
-    public void readPos3D(MkPos3D pos){
-        readPos3D(pos.getXpos(), pos.getYpos(), pos.getZpos());
+    public void setPos3D(MkPos3D pos){
+        setPos3D(pos.getXpos(), pos.getYpos(), pos.getZpos());
         return;
     }
 
     /**
      * YXZオイラー角を読み込む。
-     * <p>Y軸回転、X軸回転、Z軸回転の順に個別回転クォータニオンの積をとったものと等しい。
+     * <p>Y軸回転、X軸回転、Z軸回転の順に
+     * 個別回転クォータニオンの積をとったものと等しい。
      * @param xRot X軸回転量(ラジアン)。第2軸
      * @param yRot Y軸回転量(ラジアン)。第1軸
      * @param zRot Z軸回転量(ラジアン)。第3軸
      */
-    public void readEulerYXZ(double xRot, double yRot, double zRot){
+    public void setEulerYXZ(double xRot, double yRot, double zRot){
         double hx = xRot / 2.0;
         double hy = yRot / 2.0;
         double hz = zRot / 2.0;
@@ -299,11 +323,12 @@ public strictfp class MkQuat {
 
     /**
      * YXZオイラー角を読み込む。
-     * <p>Y軸回転、X軸回転、Z軸回転の順に個別回転クォータニオンの積をとったものと等しい。
+     * <p>Y軸回転、X軸回転、Z軸回転の順に
+     * 個別回転クォータニオンの積をとったものと等しい。
      * @param rot YXZオイラー角
      */
-    public void readEulerYXZ(EulerYXZ rot){
-        readEulerYXZ(rot.getXRot(), rot.getYRot(), rot.getZRot());
+    public void setEulerYXZ(EulerYXZ rot){
+        setEulerYXZ(rot.getXRot(), rot.getYRot(), rot.getZRot());
         return;
     }
 
@@ -311,7 +336,8 @@ public strictfp class MkQuat {
      * クォータニオンをYXZオイラー角へと変換する。
      * <p>ジンバルロック時のYZ配分が指定可能。
      * @param result YXZオイラー角
-     * @param oldY ジンバルロック時に使われるY軸回転量
+     * @param oldY ジンバルロック時(オイラー角Xが直角etc.)
+     * に使われるY軸回転量
      */
     public void toEulerYXZ(EulerYXZ result, double oldY){
         double qx = this.q1;
@@ -351,7 +377,8 @@ public strictfp class MkQuat {
         else if(m12 > +1.0) resultX = -HALF_PI;
         else                resultX = StrictMath.asin(-m12);
 
-        if(m11 == 0.0 || m22 == 0.0){     // Y,Zが一意に定まらない場合
+        if(   StrictMath.abs(m11) <= TDELTA    // Y,Zが一意に定まらない場合
+           || StrictMath.abs(m22) <= TDELTA ){
             resultY = oldY;
             resultZ = StrictMath.atan2(-m01, m00) + oldY;
         }else{
@@ -5,12 +5,14 @@
  * Copyright(c) 2010 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.math;
+package jp.sfjp.mikutoga.math;
 
 /**
  * XYZ三次元ベクトル。
  */
-public class MkVec3D {
+public strictfp class MkVec3D {
+
+    private static final String DELIM = ", ";
 
     private double xVal;
     private double yVal;
@@ -20,16 +22,29 @@ public class MkVec3D {
      * コンストラクタ。
      */
     public MkVec3D(){
-        super();
+        this(0.0, 0.0, 0.0);
+        return;
+    }
+
+    /**
+     * コンストラクタ。
+     * @param xValArg X値
+     * @param yValArg Y値
+     * @param zValArg Z値
+     */
+    public MkVec3D(double xValArg, double yValArg, double zValArg){
+        this.xVal = xValArg;
+        this.yVal = yValArg;
+        this.zVal = zValArg;
         return;
     }
 
     /**
      * X値を設定する。
-     * @param xVal X値
+     * @param xValArg X値
      */
-    public void setXVal(double xVal){
-        this.xVal = xVal;
+    public void setXVal(double xValArg){
+        this.xVal = xValArg;
         return;
     }
 
@@ -43,10 +58,10 @@ public class MkVec3D {
 
     /**
      * Y値を設定する。
-     * @param yVal Y値
+     * @param yValArg Y値
      */
-    public void setYVal(double yVal){
-        this.yVal = yVal;
+    public void setYVal(double yValArg){
+        this.yVal = yValArg;
         return;
     }
 
@@ -60,10 +75,10 @@ public class MkVec3D {
 
     /**
      * Z値を設定する。
-     * @param zVal Z値
+     * @param zValArg Z値
      */
-    public void setZVal(double zVal){
-        this.zVal = zVal;
+    public void setZVal(double zValArg){
+        this.zVal = zValArg;
         return;
     }
 
@@ -97,8 +112,8 @@ public class MkVec3D {
         StringBuilder result = new StringBuilder();
 
         result.append("vec=[")
-              .append(this.xVal).append(", ")
-              .append(this.yVal).append(", ")
+              .append(this.xVal).append(DELIM)
+              .append(this.yVal).append(DELIM)
               .append(this.zVal).append(']');
 
         return result.toString();
diff --git a/src/main/java/jp/sourceforge/mikutoga/binio/FileUtils.java b/src/main/java/jp/sourceforge/mikutoga/binio/FileUtils.java
deleted file mode 100644 (file)
index a84943e..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * file utils
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.binio;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileChannel;
-
-/**
- * ファイルユーティリティ。
- */
-public final class FileUtils {
-
-    /**
-     * コンストラクタ。
-     */
-    private FileUtils(){
-        super();
-        assert false;
-        throw new AssertionError();
-    }
-
-
-    /**
-     * 既に存在する通常ファイルか否か判定する。
-     * @param file 判定対象
-     * @return 既に存在する通常ファイルならtrue
-     */
-    public static boolean isExistsNormalFile(File file){
-        if( ! file.exists() ) return false;
-        if( ! file.isFile() ) return false;
-        return true;
-    }
-
-    /**
-     * 既に存在する特殊ファイルか否か判定する。
-     * @param file 判定対象
-     * @return 既に存在する特殊ファイルならtrue
-     */
-    public static boolean isExistsUnnormalFile(File file){
-        if( ! file.exists() ) return false;
-        if( file.isFile() ) return false;
-        return true;
-    }
-
-    /**
-     * ファイルサイズを0に切り詰める。
-     * <p>既に存在する通常ファイルでないならなにもしない。
-     * @param file ファイル
-     * @throws IOException 入出力エラー
-     */
-    public static void trunc(File file) throws IOException{
-        if( ! isExistsNormalFile(file) ) return;
-        if(file.length() <= 0L) return;
-
-        FileOutputStream foStream = new FileOutputStream(file);
-        try{
-            FileChannel channnel = foStream.getChannel();
-            try{
-                channnel.truncate(0L);
-            }finally{
-                channnel.close();
-            }
-        }finally{
-            foStream.close();
-        }
-
-        assert file.length() <= 0L;
-
-        return;
-    }
-
-}
diff --git a/src/main/java/jp/sourceforge/mikutoga/binio/package-info.java b/src/main/java/jp/sourceforge/mikutoga/binio/package-info.java
deleted file mode 100644 (file)
index b36080b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * binary data I/O
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-/**
- * バイナリデータの入出力を補佐する一連のクラス。
- */
-
-package jp.sourceforge.mikutoga.binio;
-
-/* EOF */
diff --git a/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java b/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java
deleted file mode 100644 (file)
index 1b3419b..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * character decoder
- *
- * License : The MIT License
- * Copyright(c) 2011 MikuToga Partners
- */
-
-package jp.sourceforge.mikutoga.parser;
-
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CoderResult;
-import java.nio.charset.CodingErrorAction;
-
-/**
- * 文字デコーダー。
- * <p>あらかじめ長さが既知であるバイト列を読み取り、
- * 文字列へのデコード結果を返す。
- * <p>デコード対象のバイト列が全てメモリ上に展開されるので、
- * 巨大なテキストのデコードには不適当。
- * <p>入力バイト値0x00以降をデコード処理の対象から外す
- * 「ゼロチョップモード」を備える。
- * デフォルトではゼロチョップモードはオフ。
- * ゼロチョップモードはUTF16などのデコーディング時に使ってはならない。
- */
-public class TextDecoder {
-
-    /** デコード作業用入力バッファ長のデフォルト。バイト単位。 */
-    public static final int DEF_BUFSZ = 512;
-
-
-    private final CharsetDecoder decoder;
-
-    private byte[] byteArray;
-    private ByteBuffer byteBuffer;  // byteArrayの別ビュー
-    private CharBuffer charBuffer;
-
-    private boolean chopZero = false;
-
-
-    /**
-     * コンストラクタ。
-     * @param cs キャラクタセット
-     */
-    public TextDecoder(Charset cs){
-        this(cs.newDecoder());
-        return;
-    }
-
-    /**
-     * コンストラクタ。
-     * @param decoder デコーダ
-     */
-    public TextDecoder(CharsetDecoder decoder){
-        super();
-
-        if(decoder == null) throw new NullPointerException();
-
-        this.decoder = decoder;
-        this.decoder.onMalformedInput     (CodingErrorAction.REPORT);
-        this.decoder.onUnmappableCharacter(CodingErrorAction.REPORT);
-
-        return;
-    }
-
-    /**
-     * 指定されたバイト長を満たす、デコード用入力バッファを用意する。
-     * 既存バッファで足りなければ新たに確保し直す。
-     * <p>内部用出力用バッファも同時に適切な長さで確保される。
-     * @param newSize 新たなバッファ長。単位はバイト数。
-     * @return 入力バッファ。指定バイト長より長いかもしれない。他用厳禁
-     */
-    public byte[] prepareBuffer(int newSize){
-        if(this.byteArray != null && this.byteArray.length >= newSize){
-            return this.byteArray;
-        }
-
-        int rounded = newSize;
-        if(rounded < DEF_BUFSZ) rounded = DEF_BUFSZ;
-
-        this.byteArray = new byte[rounded];
-        this.byteBuffer = ByteBuffer.wrap(this.byteArray);
-
-        float maxCharsPerByte = this.decoder.maxCharsPerByte();
-        int maxChars =
-                (int)( this.byteArray.length * maxCharsPerByte ) + 1;
-        this.charBuffer = CharBuffer.allocate(maxChars);
-
-        return this.byteArray;
-    }
-
-    /**
-     * ゼロチョップモードを設定する。
-     * ゼロチョップモードをオンにすると、
-     * 入力バイト値0x00以降はデコード対象外となる。
-     * @param chop trueならゼロチョップモードオン
-     */
-    public void setZeroChopMode(boolean chop){
-        this.chopZero = chop;
-        return;
-    }
-
-    /**
-     * ゼロチョップモードか否か判定する。
-     * @return ゼロチョップモードならtrue
-     */
-    public boolean isZeroChopMode(){
-        return this.chopZero;
-    }
-
-    /**
-     * 入力バイト列のバイト値'0'出現以降をチョップする。
-     * ゼロチョップモードでなければ何もしない。
-     */
-    protected void chopZeroTermed(){
-        if( ! this.chopZero ) return;
-
-        int limit = this.byteBuffer.limit();
-
-        for(int idx = 0; idx < limit; idx++){
-            byte bVal = this.byteArray[idx];
-            if(bVal == 0x00){
-                this.byteBuffer.limit(idx);
-                break;
-            }
-        }
-
-        return;
-    }
-
-    /**
-     * 指定配列を内部にコピーした後、デコード処理を行う。
-     * @param basePos エラー情報に含まれるストリーム位置
-     * @param buf 入力バッファ
-     * @return デコードされた文字列
-     * @throws MmdFormatException デコード異常
-     */
-    public String decode(long basePos, byte[] buf)
-            throws MmdFormatException {
-        String result = decode(basePos, buf, 0, buf.length);
-        return result;
-    }
-
-    /**
-     * 指定配列の一部を内部にコピーした後、デコード処理を行う。
-     * @param basePos エラー情報に含まれるストリーム位置
-     * @param buf 入力バッファ
-     * @param off 位置オフセット
-     * @param byteLen バイト長
-     * @return デコードされた文字列
-     * @throws MmdFormatException デコード異常
-     * @throws IndexOutOfBoundsException 不正な位置指定。
-     */
-    public String decode(long basePos, byte[] buf, int off, int byteLen)
-            throws MmdFormatException, IndexOutOfBoundsException {
-        prepareBuffer(byteLen);
-        System.arraycopy(buf, off, this.byteArray, 0, byteLen);
-        String result = decode(basePos, byteLen);
-        return result;
-    }
-
-    /**
-     * 内部バッファのデコード処理を行う。
-     * @param basePos エラー情報に含まれるストリーム位置
-     * @param byteLen バイト長
-     * @return デコードされた文字列
-     * @throws MmdFormatException デコード異常
-     * @throws IndexOutOfBoundsException 不正なバイト長。
-     */
-    public String decode(long basePos, int byteLen)
-            throws MmdFormatException, IndexOutOfBoundsException {
-        if(this.byteArray.length < byteLen){
-            throw new IndexOutOfBoundsException();
-        }
-
-        this.byteBuffer.rewind().limit(byteLen);
-        chopZeroTermed();
-
-        this.charBuffer.clear();
-
-        this.decoder.reset();
-        CoderResult decResult =
-                this.decoder.decode(this.byteBuffer, this.charBuffer, true);
-
-        if(decResult.isError()){
-            String errMsg;
-            if(decResult.isUnmappable()){
-                errMsg = "unmapped character";
-            }else{
-                errMsg = "illegal character encoding";
-            }
-            long errPos = basePos + decResult.length();
-            throw new MmdFormatException(errMsg, errPos);
-        }
-
-        assert ! decResult.isOverflow();
-
-        String result = this.charBuffer.flip().toString();
-        return result;
-    }
-
-}
index 63979b7..c34ff07 100644 (file)
@@ -13,6 +13,8 @@ package jp.sourceforge.mikutoga.pmd;
  */
 public class Deg3d {
 
+    private static final String DELIM = ", ";
+
     private float xDeg;
     private float yDeg;
     private float zDeg;
@@ -27,10 +29,10 @@ public class Deg3d {
 
     /**
      * X軸回転量を設定する。
-     * @param xDeg X軸回転量(degree)
+     * @param xDegArg X軸回転量(degree)
      */
-    public void setXDeg(float xDeg){
-        this.xDeg = xDeg;
+    public void setXDeg(float xDegArg){
+        this.xDeg = xDegArg;
         return;
     }
 
@@ -44,10 +46,10 @@ public class Deg3d {
 
     /**
      * Y軸回転量を設定する。
-     * @param yDeg Y軸回転量(degree)
+     * @param yDegArg Y軸回転量(degree)
      */
-    public void setYDeg(float yDeg){
-        this.yDeg = yDeg;
+    public void setYDeg(float yDegArg){
+        this.yDeg = yDegArg;
         return;
     }
 
@@ -61,10 +63,10 @@ public class Deg3d {
 
     /**
      * Z軸回転量を設定する。
-     * @param zDeg Z軸回転量(degree)
+     * @param zDegArg Z軸回転量(degree)
      */
-    public void setZDeg(float zDeg){
-        this.zDeg = zDeg;
+    public void setZDeg(float zDegArg){
+        this.zDeg = zDegArg;
         return;
     }
 
@@ -85,8 +87,8 @@ public class Deg3d {
         StringBuilder result = new StringBuilder();
 
         result.append("deg=[")
-              .append(this.xDeg).append(", ")
-              .append(this.yDeg).append(", ")
+              .append(this.xDeg).append(DELIM)
+              .append(this.yDeg).append(DELIM)
               .append(this.zDeg).append(']');
 
         return result.toString();
index 33dc633..7e1cce3 100644 (file)
@@ -13,6 +13,8 @@ package jp.sourceforge.mikutoga.pmd;
  */
 public class Rad3d {
 
+    private static final String DELIM = ", ";
+
     private float xRad;
     private float yRad;
     private float zRad;
@@ -27,10 +29,10 @@ public class Rad3d {
 
     /**
      * X軸回転量を設定する。
-     * @param xRad X軸回転量(radian)
+     * @param xRadArg X軸回転量(radian)
      */
-    public void setXRad(float xRad){
-        this.xRad = xRad;
+    public void setXRad(float xRadArg){
+        this.xRad = xRadArg;
         return;
     }
 
@@ -44,10 +46,10 @@ public class Rad3d {
 
     /**
      * Y軸回転量を設定する。
-     * @param yRad Y軸回転量(radian)
+     * @param yRadArg Y軸回転量(radian)
      */
-    public void setYRad(float yRad){
-        this.yRad = yRad;
+    public void setYRad(float yRadArg){
+        this.yRad = yRadArg;
         return;
     }
 
@@ -61,10 +63,10 @@ public class Rad3d {
 
     /**
      * Z軸回転量を設定する。
-     * @param zRad Z軸回転量(radian)
+     * @param zRadArg Z軸回転量(radian)
      */
-    public void setZRad(float zRad){
-        this.zRad = zRad;
+    public void setZRad(float zRadArg){
+        this.zRad = zRadArg;
         return;
     }
 
@@ -85,8 +87,8 @@ public class Rad3d {
         StringBuilder result = new StringBuilder();
 
         result.append("rad=[")
-              .append(this.xRad).append(", ")
-              .append(this.yRad).append(", ")
+              .append(this.xRad).append(DELIM)
+              .append(this.yRad).append(DELIM)
               .append(this.zRad).append(']');
 
         return result.toString();
index 77dcbd7..ca4010f 100644 (file)
@@ -7,7 +7,7 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 
 /**
  * PMDモデル情報ファイルの基本情報の通知用ハンドラ。
index 97451ac..76a3587 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの各種ボーン情報の通知用ハンドラ。
index 4883884..6cd8c34 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの英語情報の通知用ハンドラ。
index 64b139f..b217ceb 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの各種剛体間ジョイント情報の通知用ハンドラ。
index b8f21e8..ab5f60c 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの各種材質情報の通知用ハンドラ。
index d0836b0..d745e1e 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルのモーフ情報の通知用ハンドラ。
index a0eb060..da8bfa7 100644 (file)
@@ -11,10 +11,10 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
 import java.util.Arrays;
-import jp.sourceforge.mikutoga.parser.CommonParser;
-import jp.sourceforge.mikutoga.parser.MmdEofException;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.TextDecoder;
+import jp.sfjp.mikutoga.bin.parser.CommonParser;
+import jp.sfjp.mikutoga.bin.parser.MmdEofException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.TextDecoder;
 
 /**
  * PMDモデルファイルのパーサ基本部。
index a72e97d..159d2f9 100644 (file)
@@ -9,7 +9,7 @@ package jp.sourceforge.mikutoga.pmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 
 /**
  * PMDモデルファイルのパーサ拡張その1。
index 6824a85..9bf559b 100644 (file)
@@ -9,7 +9,7 @@ package jp.sourceforge.mikutoga.pmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 
 /**
  * PMDモデルファイルのパーサ拡張その2。
index a5483d7..4a80b06 100644 (file)
@@ -9,7 +9,7 @@ package jp.sourceforge.mikutoga.pmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 
 /**
  * PMDモデルファイルのパーサ拡張その3。
index 19cfad8..d76b0b1 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの各種剛体情報の通知用ハンドラ。
index 06b92e0..ff6174d 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの各種形状(頂点、面)の通知用ハンドラ。
index dca87cb..1d7bd82 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.pmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * PMDモデルの独自トゥーンテクスチャファイル名の通知用ハンドラ。
index c62d3c4..1c97284 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.vmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * VMDモーションファイルの基本情報(ボーンモーション/モーフモーション)
index 5d8a983..969d9f0 100644 (file)
@@ -10,10 +10,10 @@ package jp.sourceforge.mikutoga.vmd.parser;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.charset.Charset;
-import jp.sourceforge.mikutoga.parser.CommonParser;
-import jp.sourceforge.mikutoga.parser.MmdEofException;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.TextDecoder;
+import jp.sfjp.mikutoga.bin.parser.CommonParser;
+import jp.sfjp.mikutoga.bin.parser.MmdEofException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.TextDecoder;
 import jp.sourceforge.mikutoga.vmd.VmdConst;
 
 /**
index 7ac11a4..712578a 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.vmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * VMDモーションファイルのカメラワーク情報の通知用ハンドラ。
index bf63851..2bf60a5 100644 (file)
@@ -9,8 +9,8 @@ package jp.sourceforge.mikutoga.vmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.CommonParser;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.CommonParser;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 import jp.sourceforge.mikutoga.vmd.VmdConst;
 
 /**
index f49a36f..ee39f92 100644 (file)
@@ -7,9 +7,9 @@
 
 package jp.sourceforge.mikutoga.vmd.parser;
 
-import jp.sourceforge.mikutoga.parser.LoopHandler;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.LoopHandler;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 
 /**
  * VMDモーションファイルのライティング情報(照明光源・セルフシャドウ)
index 000f0f8..dddb629 100644 (file)
@@ -9,8 +9,8 @@ package jp.sourceforge.mikutoga.vmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.CommonParser;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.CommonParser;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 import jp.sourceforge.mikutoga.vmd.VmdConst;
 
 /**
index 1d0718c..968c74c 100644 (file)
@@ -9,7 +9,7 @@ package jp.sourceforge.mikutoga.vmd.parser;
 
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 
 /**
  * VMDモーションファイルのパーサ。
@@ -1,11 +1,12 @@
 /*
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.io.ByteArrayOutputStream;
 import java.io.FilterOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
@@ -38,7 +39,32 @@ public class BinaryExporterTest {
     }
 
     /**
+     * Test of constructor, of class BinaryExporter.
+     * @throws Exception
+     */
+    @Test
+    public void testCons() throws Exception {
+        System.out.println("constructor");
+
+        BinaryExporter ex;
+        OutputStream stream;
+
+        stream = new ByteArrayOutputStream();
+        ex = new BinaryExporter(stream);
+
+        try{
+            ex = new BinaryExporter(null);
+            fail();
+        }catch(NullPointerException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
      * Test of close method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testClose() throws Exception {
@@ -57,6 +83,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of flush method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testFlush() throws Exception {
@@ -75,6 +102,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpByte method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpByte_byte() throws Exception {
@@ -99,6 +127,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpByte method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpByte_int() throws Exception {
@@ -130,6 +159,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpByteArray method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpByteArray_byteArr() throws Exception {
@@ -156,6 +186,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpByteArray method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpByteArray_3args() throws Exception {
@@ -183,6 +214,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeShort method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeShort_short() throws Exception {
@@ -216,6 +248,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeShort method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeShort_int() throws Exception {
@@ -257,6 +290,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeInt method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeInt() throws Exception {
@@ -294,6 +328,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeLong method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeLong() throws Exception {
@@ -339,6 +374,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeFloat method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeFloat() throws Exception {
@@ -376,6 +412,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpLeDouble method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpLeDouble() throws Exception {
@@ -421,6 +458,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpFiller method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpFiller() throws Exception {
@@ -464,11 +502,22 @@ public class BinaryExporterTest {
         assertEquals((byte)0x01, barr[0]);
         assertEquals((byte)0x02, barr[1]);
 
+        bos.reset();
+        bex.dumpFiller(new byte[]{}, 3);
+        bex.flush();
+        assertEquals(0, bos.size());
+
+        bos.reset();
+        bex.dumpFiller(new byte[]{0x01, 0x02, 0x03}, 0);
+        bex.flush();
+        assertEquals(0, bos.size());
+
         return;
     }
 
     /**
      * Test of dumpFixedW31j method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpFixedW31j() throws Exception {
@@ -495,6 +544,26 @@ public class BinaryExporterTest {
         assertEquals((byte)0x02, barr[6]);
 
         bos.reset();
+        bex.dumpFixedW31j("あい", 4, new byte[]{0x01, 0x02});
+        bex.flush();
+        barr = bos.toByteArray();
+        assertEquals(4, barr.length);
+        assertEquals((byte)0x82, barr[0]);
+        assertEquals((byte)0xA0, barr[1]);
+        assertEquals((byte)0x82, barr[2]);
+        assertEquals((byte)0xA2, barr[3]);
+
+        bos.reset();
+        bex.dumpFixedW31j("あい", 0, new byte[]{0x01, 0x02});
+        bex.flush();
+        barr = bos.toByteArray();
+        assertEquals(4, barr.length);
+        assertEquals((byte)0x82, barr[0]);
+        assertEquals((byte)0xA0, barr[1]);
+        assertEquals((byte)0x82, barr[2]);
+        assertEquals((byte)0xA2, barr[3]);
+
+        bos.reset();
         try{
             bex.dumpFixedW31j("あい", 3, new byte[]{0x00});
             fail();
@@ -515,6 +584,7 @@ public class BinaryExporterTest {
 
     /**
      * Test of dumpHollerithUtf16LE method, of class BinaryExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpHollerithUtf16LE() throws Exception {
diff --git a/src/test/java/jp/sfjp/mikutoga/bin/export/IllegalTextExportExceptionTest.java b/src/test/java/jp/sfjp/mikutoga/bin/export/IllegalTextExportExceptionTest.java
new file mode 100644 (file)
index 0000000..9299ad3
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.bin.export;
+
+import java.nio.charset.CharacterCodingException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class IllegalTextExportExceptionTest {
+
+    public IllegalTextExportExceptionTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testSomeMethod() {
+        System.out.println("constructor");
+
+        IllegalTextExportException ex;
+
+        ex = new IllegalTextExportException();
+        assertNull(ex.getCause());
+        assertNull(ex.getMessage());
+
+        ex = new IllegalTextExportException("msg");
+        assertNull(ex.getCause());
+        assertEquals("msg", ex.getMessage());
+
+        CharacterCodingException cex = new CharacterCodingException();
+        ex = new IllegalTextExportException(cex);
+        assertEquals(cex, ex.getCause());
+        assertEquals(cex.toString(), ex.getMessage());
+
+        ex = new IllegalTextExportException("msg", cex);
+        assertEquals(cex, ex.getCause());
+        assertEquals("msg", ex.getMessage());
+
+        return;
+    }
+
+}
@@ -1,7 +1,7 @@
 /*
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -44,6 +44,33 @@ public class TextExporterTest {
     }
 
     /**
+     * Test of constructor, of class TextExporter.
+     * @throws Exception
+     */
+    @Test
+    public void testCons() throws Exception {
+        System.out.println("constructor");
+
+        TextExporter exp;
+
+        try{
+            exp = new TextExporter((Charset)null);
+            fail();
+        }catch(NullPointerException e){
+            // GOOD
+        }
+
+        try{
+            exp = new TextExporter((CharsetEncoder)null);
+            fail();
+        }catch(NullPointerException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
      * Test of getEncoder method, of class TextExporter.
      */
     @Test
@@ -96,11 +123,19 @@ public class TextExporterTest {
             // GOOD
         }
 
+        try{
+            exporter.setCharBufSize(0);
+            fail();
+        }catch(IllegalArgumentException e){
+            // GOOD
+        }
+
         return;
     }
 
     /**
      * Test of dumpText method, of class TextExporter.
+     * @throws Exception
      */
     @Test
     public void testDumpText() throws Exception {
@@ -135,6 +170,7 @@ public class TextExporterTest {
 
     /**
      * Test of encodeToByteStream method, of class TextExporter.
+     * @throws Exception
      */
     @Test
     public void testEncodeToByteStream() throws Exception {
diff --git a/src/test/java/jp/sfjp/mikutoga/bin/parser/CommonParserTest.java b/src/test/java/jp/sfjp/mikutoga/bin/parser/CommonParserTest.java
new file mode 100644 (file)
index 0000000..597bfa6
--- /dev/null
@@ -0,0 +1,442 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.bin.parser;
+
+import java.nio.charset.Charset;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class CommonParserTest {
+
+    public CommonParserTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of getPosition method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testGetPosition() throws Exception{
+        System.out.println("getPosition");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(new byte[100]);
+        parser = new CommonParser(is);
+
+        assertEquals(0, parser.getPosition());
+
+        parser.parseByte();
+        assertEquals(1, parser.getPosition());
+
+        parser.parseLeInt();
+        assertEquals(5, parser.getPosition());
+
+        parser.skip(10);
+        assertEquals(15, parser.getPosition());
+
+        return;
+    }
+
+    /**
+     * Test of hasMore method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testHasMore() throws Exception {
+        System.out.println("hasMore");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x00, 0x01, 0x02);
+        parser = new CommonParser(is);
+
+        assertTrue(parser.hasMore());
+
+        assertEquals((byte)0x00, parser.parseByte());
+        assertTrue(parser.hasMore());
+
+        assertEquals((byte)0x01, parser.parseByte());
+        assertTrue(parser.hasMore());
+
+        assertEquals((byte)0x02, parser.parseByte());
+        assertFalse(parser.hasMore());
+
+        return;
+    }
+
+    /**
+     * Test of skip method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testSkip() throws Exception {
+        System.out.println("skip");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x00, 0x01, 0x02);
+        parser = new CommonParser(is);
+
+        assertEquals((byte)0x00, parser.parseByte());
+
+        parser.skip(1L);
+        assertEquals((byte)0x02, parser.parseByte());
+
+        try{
+            parser.skip(1L);
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseByteArray method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseByteArray_3args() throws Exception {
+        System.out.println("parseByteArray");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x01, 0x02, 0x03);
+        parser = new CommonParser(is);
+
+        byte[] dst = {
+            (byte)0xf1, (byte)0xf2, (byte)0xf3, (byte)0xf4, (byte)0xf5
+        };
+
+        parser.parseByteArray(dst, 1, 2);
+
+        assertEquals((byte)0xf1, dst[0]);
+        assertEquals((byte)0x01, dst[1]);
+        assertEquals((byte)0x02, dst[2]);
+        assertEquals((byte)0xf4, dst[3]);
+        assertEquals((byte)0xf5, dst[4]);
+
+        return;
+    }
+
+    /**
+     * Test of parseByteArray method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseByteArray_byteArr() throws Exception {
+        System.out.println("parseByteArray");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x01, 0x02, 0x03);
+        parser = new CommonParser(is);
+
+        byte[] dst = {
+            (byte)0xf1, (byte)0xf2
+        };
+
+        parser.parseByteArray(dst);
+
+        assertEquals((byte)0x01, dst[0]);
+        assertEquals((byte)0x02, dst[1]);
+
+        return;
+    }
+
+    /**
+     * Test of parseByte method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseByte() throws Exception {
+        System.out.println("parseByte");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x01, 0x02, 0x03);
+        parser = new CommonParser(is);
+
+        assertEquals((byte)0x01, parser.parseByte());
+        assertEquals((byte)0x02, parser.parseByte());
+        assertEquals((byte)0x03, parser.parseByte());
+
+        try{
+            parser.parseByte();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseUByteAsInt method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseUByteAsInt() throws Exception {
+        System.out.println("parseUByteAsInt");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x00, 0x01, 0xff);
+        parser = new CommonParser(is);
+
+        assertEquals(0x00, parser.parseUByteAsInt());
+        assertEquals(0x01, parser.parseUByteAsInt());
+        assertEquals(0xff, parser.parseUByteAsInt());
+
+        try{
+            parser.parseUByteAsInt();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseBoolean method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseBoolean() throws Exception {
+        System.out.println("parseBoolean");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0x00, 0x01, 0x02, 0xff);
+        parser = new CommonParser(is);
+
+        assertFalse(parser.parseBoolean());
+        assertTrue(parser.parseBoolean());
+        assertTrue(parser.parseBoolean());
+        assertTrue(parser.parseBoolean());
+
+        try{
+            parser.parseBoolean();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseLeShort method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseLeShort() throws Exception {
+        System.out.println("parseLeShort");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0xfe, 0xff, 0x01, 0x00, 0x80);
+        parser = new CommonParser(is);
+
+        assertEquals((short)-2, parser.parseLeShort());
+        assertEquals((short)1, parser.parseLeShort());
+
+        try{
+            parser.parseLeShort();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseLeUShortAsInt method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseLeUShortAsInt() throws Exception {
+        System.out.println("parseLeUShortAsInt");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(0xfe, 0xff, 0x01, 0x00, 0x80);
+        parser = new CommonParser(is);
+
+        assertEquals(0xfffe, parser.parseLeUShortAsInt());
+        assertEquals(1, parser.parseLeUShortAsInt());
+
+        try{
+            parser.parseLeUShortAsInt();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseLeInt method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseLeInt() throws Exception {
+        System.out.println("parseLeInt");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(
+                0xfe, 0xff, 0xff, 0xff,
+                0x78, 0x56, 0x34, 0x12,
+                0x7f );
+        parser = new CommonParser(is);
+
+        assertEquals(-2, parser.parseLeInt());
+        assertEquals(0x12345678, parser.parseLeInt());
+
+        try{
+            parser.parseLeInt();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseLeFloat method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseLeFloat() throws Exception {
+        System.out.println("parseLeFloat");
+
+        CommonParser parser;
+        DummyInputStream is;
+
+        is = new DummyInputStream(
+                0x00, 0x00, 0xc0, 0xbf,
+                0x78, 0x56, 0x34, 0x12,
+                0x7f );
+        parser = new CommonParser(is);
+
+        assertEquals(-1.5f, parser.parseLeFloat(), 0.0);
+        assertEquals(
+                Float.intBitsToFloat(0x12345678), parser.parseLeFloat(),
+                0.0 );
+
+        try{
+            parser.parseLeFloat();
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        return;
+    }
+
+    /**
+     * Test of parseString method, of class CommonParser.
+     * @throws Exception
+     */
+    @Test
+    public void testParseString() throws Exception {
+        System.out.println("parseString");
+
+        CommonParser parser;
+        DummyInputStream is;
+        TextDecoder decoder;
+
+        decoder = new TextDecoder(Charset.forName("Shift_JIS"));
+
+        is = new DummyInputStream(0x82, 0xa0, 0x82, 0xa2, 0x46);
+        parser = new CommonParser(is);
+
+        assertEquals("あ", parser.parseString(decoder, 2));
+        assertEquals("い", parser.parseString(decoder, 2));
+
+        try{
+            parser.parseString(decoder, 2);
+            fail();
+        }catch(MmdEofException e){
+            // GOOD
+        }
+
+        is = new DummyInputStream(0x82, 0xa0, 0x82, 0xa2);
+        parser = new CommonParser(is);
+
+        assertEquals("あい", parser.parseString(decoder, 4));
+
+        is = new DummyInputStream(0x82, 0xa0, 0x82, 0xff);
+        parser = new CommonParser(is);
+
+        try{
+            parser.parseString(decoder, 4);
+            fail();
+        }catch(MmdFormatException e){
+//          assertEquals("unmapped character(position:2)", e.getMessage());
+            // GOOD
+        }
+
+        is = new DummyInputStream(0x82, 0xa0, 0x82);
+        parser = new CommonParser(is);
+
+        try{
+            parser.parseString(decoder, 3);
+            fail();
+        }catch(MmdFormatException e){
+//          assertEquals("illegal character encoding(position:1)", e.getMessage());
+            // GOOD
+        }
+
+        is = new DummyInputStream(0x41, 0x42, 0x43);
+        parser = new CommonParser(is);
+
+        assertEquals("A", parser.parseString(decoder, 1));
+        assertEquals("BC", parser.parseString(decoder, 2));
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/bin/parser/MmdEofExceptionTest.java b/src/test/java/jp/sfjp/mikutoga/bin/parser/MmdEofExceptionTest.java
new file mode 100644 (file)
index 0000000..fb16c03
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.bin.parser;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class MmdEofExceptionTest {
+
+    public MmdEofExceptionTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testSomeMethod() {
+
+        MmdFormatException ex;
+
+        ex = new MmdEofException();
+        assertNull(ex.getMessage());
+
+        ex = new MmdEofException("ERROR");
+        assertEquals("ERROR", ex.getMessage());
+
+        ex = new MmdEofException(99);
+        assertEquals("(position:99)", ex.getMessage());
+
+        ex = new MmdEofException("ERROR", 99);
+        assertEquals("ERROR(position:99)", ex.getMessage());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/bin/parser/MmdFormatExceptionTest.java b/src/test/java/jp/sfjp/mikutoga/bin/parser/MmdFormatExceptionTest.java
new file mode 100644 (file)
index 0000000..2ea7b82
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.bin.parser;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class MmdFormatExceptionTest {
+
+    public MmdFormatExceptionTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of getMessage method, of class MmdFormatException.
+     */
+    @Test
+    public void testGetMessage() {
+        System.out.println("getMessage");
+
+        MmdFormatException ex;
+
+        ex = new MmdFormatException();
+        assertNull(ex.getMessage());
+
+        ex = new MmdFormatException("ERROR");
+        assertEquals("ERROR", ex.getMessage());
+
+        ex = new MmdFormatException(99);
+        assertEquals("(position:99)", ex.getMessage());
+
+        ex = new MmdFormatException("ERROR", 99);
+        assertEquals("ERROR(position:99)", ex.getMessage());
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class MmdFormatException.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        MmdFormatException ex;
+
+        ex = new MmdFormatException();
+        assertNull(ex.getMessage());
+        assertEquals(MmdFormatException.class.getName(), ex.toString());
+
+        ex = new MmdFormatException("ERROR", 99);
+        assertEquals(MmdFormatException.class.getName()
+                + ": ERROR(position:99)",
+                ex.toString() );
+
+        return;
+    }
+
+    /**
+     * Test of getPosition method, of class MmdFormatException.
+     */
+    @Test
+    public void testGetPosition() {
+        System.out.println("getPosition");
+
+        MmdFormatException ex;
+
+        ex = new MmdFormatException();
+        assertTrue(ex.getPosition() < 0);
+
+        ex = new MmdFormatException("ERROR");
+        assertTrue(ex.getPosition() < 0);
+
+        ex = new MmdFormatException(99);
+        assertEquals(99, ex.getPosition());
+
+        ex = new MmdFormatException("ERROR", 99);
+        assertEquals(99, ex.getPosition());
+
+        return;
+    }
+
+    /**
+     * Test of hasPosition method, of class MmdFormatException.
+     */
+    @Test
+    public void testHasPosition() {
+        System.out.println("hasPosition");
+
+        MmdFormatException ex;
+
+        ex = new MmdFormatException();
+        assertFalse(ex.hasPosition());
+
+        ex = new MmdFormatException("ERROR");
+        assertFalse(ex.hasPosition());
+
+        ex = new MmdFormatException(99);
+        assertTrue(ex.hasPosition());
+
+        ex = new MmdFormatException("ERROR", 99);
+        assertTrue(ex.hasPosition());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/bin/parser/ParseStageTest.java b/src/test/java/jp/sfjp/mikutoga/bin/parser/ParseStageTest.java
new file mode 100644 (file)
index 0000000..5bae2ca
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.bin.parser;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class ParseStageTest {
+
+    public ParseStageTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of getNo method, of class ParseStage.
+     */
+    @Test
+    public void testGetNo() {
+        System.out.println("getNo");
+
+        ParseStage p1 = new ParseStage();
+        ParseStage p2 = new ParseStage();
+        ParseStage p3 = new ParseStage();
+
+        assertEquals(1, p2.getNo() - p1.getNo());
+        assertEquals(1, p3.getNo() - p2.getNo());
+
+        return;
+    }
+
+}
@@ -1,8 +1,10 @@
 /*
  */
 
-package jp.sourceforge.mikutoga.parser;
+package jp.sfjp.mikutoga.bin.parser;
 
+import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.List;
@@ -91,15 +93,6 @@ public class TextDecoderTest {
     }
 
     /**
-     * Test of prepareBuffer method, of class TextDecoder.
-     */
-    @Test
-    public void testPrepareBuffer() {
-        System.out.println("prepareBuffer");
-        return;
-    }
-
-    /**
      * Test of setChopMode, getChopMode method, of class TextDecoder.
      * @throws Exception
      */
@@ -138,9 +131,11 @@ public class TextDecoderTest {
         assertDecoded("41:00:42", "A", decoder);
         assertDecoded("00:41:42", "", decoder);
         assertDecoded("41:00:88", "A", decoder);
+        assertDecoded("", "", decoder);
 
         decoder.setZeroChopMode(false);
         assertDecoded("41:00:42", "A\u0000B", decoder);
+        assertDecoded("", "", decoder);
 
         return;
     }
@@ -278,19 +273,25 @@ public class TextDecoderTest {
                                 TextDecoder decoder)
             throws Exception{
         byte[] bdata = byteArray(bin);
-        assertDecoded(bin, desired, decoder, bdata.length);
+        ByteBuffer bBuf = ByteBuffer.wrap(bdata);
+        assertDecoded(bBuf, desired, decoder);
         return;
     }
 
     public void assertDecoded(String bin, String desired,
                                 TextDecoder decoder, int len)
             throws Exception{
-        byte[] bdata;
-
-        bdata = byteArray(bin);
+        byte[] bdata = byteArray(bin);
+        ByteBuffer bBuf = ByteBuffer.wrap(bdata, 0, len);
+        assertDecoded(bBuf, desired, decoder);
+        return;
+    }
 
+    public void assertDecoded(ByteBuffer bBuf, String desired,
+                                TextDecoder decoder)
+            throws Exception{
         String result;
-        result = decoder.decode(0, bdata, 0, len);
+        result = decoder.decode(bBuf);
 
         assertEquals(desired, result);
 
@@ -300,14 +301,13 @@ public class TextDecoderTest {
     public void assertFormatError(String bin,
                                     TextDecoder decoder, int len)
             throws Exception{
-        byte[] bdata;
-
-        bdata = byteArray(bin);
+        byte[] bdata = byteArray(bin);
+        ByteBuffer bBuf = ByteBuffer.wrap(bdata, 0, len);
 
         try{
-            decoder.decode(0, bdata, 0, len);
+            decoder.decode(bBuf);
             fail();
-        }catch(MmdFormatException e){
+        }catch(CharacterCodingException e){
             // OK
         }
 
diff --git a/src/test/java/jp/sfjp/mikutoga/corelib/I18nTextTest.java b/src/test/java/jp/sfjp/mikutoga/corelib/I18nTextTest.java
new file mode 100644 (file)
index 0000000..51caa82
--- /dev/null
@@ -0,0 +1,417 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.corelib;
+
+import java.util.List;
+import java.util.Locale;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public class I18nTextTest {
+
+    public I18nTextTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of setPrimaryText method, of class I18nText.
+     */
+    @Test
+    public void testSetPrimaryText() {
+        System.out.println("setPrimaryText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setPrimaryText("pri");
+        assertEquals("pri", text.getPrimaryText());
+
+        text.setPrimaryText(null);
+        assertNull(text.getPrimaryText());
+
+        return;
+    }
+
+    /**
+     * Test of setGlobalText method, of class I18nText.
+     */
+    @Test
+    public void testSetGlobalText() {
+        System.out.println("setGlobalText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setGlobalText("glo");
+
+        assertEquals("glo", text.getGlobalText());
+
+        text.setGlobalText(null);
+        assertNull(text.getGlobalText());
+
+        return;
+    }
+
+    /**
+     * Test of setI18nText method, of class I18nText.
+     */
+    @Test
+    public void testSetI18nText_Locale_CharSequence() {
+        System.out.println("setI18nText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setI18nText(Locale.JAPANESE, "pri");
+        assertEquals("pri", text.getPrimaryText());
+
+        text.setI18nText(Locale.JAPANESE, null);
+        assertNull(text.getPrimaryText());
+
+        return;
+    }
+
+    /**
+     * Test of setI18nText method, of class I18nText.
+     */
+    @Test
+    public void testSetI18nText_String_CharSequence() {
+        System.out.println("setI18nText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setI18nText("ja", "pri");
+        assertEquals("pri", text.getPrimaryText());
+
+        text.setI18nText("ja", null);
+        assertNull(text.getPrimaryText());
+
+        return;
+    }
+
+    /**
+     * Test of getPrimaryText method, of class I18nText.
+     */
+    @Test
+    public void testGetPrimaryText() {
+        System.out.println("getPrimaryText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertNull(text.getPrimaryText());
+
+        text.setPrimaryText("pri");
+        assertEquals("pri", text.getPrimaryText());
+
+        return;
+    }
+
+    /**
+     * Test of getGlobalText method, of class I18nText.
+     */
+    @Test
+    public void testGetGlobalText() {
+        System.out.println("getGlobalText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertNull(text.getGlobalText());
+
+        text.setGlobalText("glo");
+        assertEquals("glo", text.getGlobalText());
+
+        return;
+    }
+
+    /**
+     * Test of getI18nText method, of class I18nText.
+     */
+    @Test
+    public void testGetI18nText_Locale() {
+        System.out.println("getI18nText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setPrimaryText("pri");
+
+        assertEquals("pri", text.getI18nText(Locale.JAPANESE));
+        assertNull(text.getI18nText(Locale.ENGLISH));
+
+        return;
+    }
+
+    /**
+     * Test of getI18nText method, of class I18nText.
+     */
+    @Test
+    public void testGetI18nText_String() {
+        System.out.println("getI18nText");
+
+        I18nText text;
+
+        text = new I18nText();
+        text.setPrimaryText("pri");
+
+        assertEquals("pri", text.getI18nText("ja"));
+        assertNull(text.getI18nText("en"));
+
+        return;
+    }
+
+    /**
+     * Test of getText method, of class I18nText.
+     */
+    @Test
+    public void testGetText() {
+        System.out.println("getText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertEquals("", text.getText());
+
+        text.setPrimaryText("pri");
+        assertEquals("pri", text.getText());
+
+        return;
+    }
+
+    /**
+     * Test of getLocalizedText method, of class I18nText.
+     */
+    @Test
+    public void testGetLocalizedText() {
+        System.out.println("getLocalizedText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertEquals("", text.getLocalizedText());
+
+        text = new I18nText();
+        text.setPrimaryText("pri");
+        assertEquals("pri", text.getLocalizedText());
+
+        text = new I18nText();
+        text.setGlobalText("glo");
+        assertEquals("glo", text.getLocalizedText());
+
+        text = new I18nText();
+        text.setI18nText(Locale.CHINESE, "chi");
+        assertEquals("chi", text.getLocalizedText());
+
+        // default locale...
+
+        return;
+    }
+
+    /**
+     * Test of clearI18nText method, of class I18nText.
+     */
+    @Test
+    public void testClearI18nText() {
+        System.out.println("clearI18nText");
+
+        I18nText text;
+
+        text = new I18nText();
+
+        text.setPrimaryText("pri");
+        text.setGlobalText("glo");
+
+        assertNotNull(text.getPrimaryText());
+        assertNotNull(text.getGlobalText());
+
+        text.clearI18nText();
+
+        assertNull(text.getPrimaryText());
+        assertNull(text.getGlobalText());
+
+        return;
+    }
+
+    /**
+     * Test of lang639CodeList method, of class I18nText.
+     */
+    @Test
+    public void testLang639CodeList() {
+        System.out.println("lang639CodeList");
+
+        I18nText text;
+        List<String> list;
+
+        text = new I18nText();
+
+        list = text.lang639CodeList();
+        assertTrue(list.isEmpty());
+
+        text.setI18nText(Locale.CHINA, "chi");
+        text.setPrimaryText("pri");
+        text.setGlobalText("glo");
+
+        list = text.lang639CodeList();
+
+        assertEquals(3, list.size());
+        assertEquals("ja", list.get(0));
+        assertEquals("en", list.get(1));
+        assertEquals("zh", list.get(2));
+
+        return;
+    }
+
+    /**
+     * Test of hasPrimaryText method, of class I18nText.
+     */
+    @Test
+    public void testHasPrimaryText() {
+        System.out.println("hasPrimaryText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertFalse(text.hasPrimaryText());
+
+        text.setPrimaryText("pri");
+        assertTrue(text.hasPrimaryText());
+
+        text.setPrimaryText(null);
+        assertFalse(text.hasPrimaryText());
+
+        text.setGlobalText("glo");
+        assertFalse(text.hasPrimaryText());
+
+        return;
+    }
+
+    /**
+     * Test of hasGlobalText method, of class I18nText.
+     */
+    @Test
+    public void testHasGlobalText() {
+        System.out.println("hasGlobalText");
+
+        I18nText text;
+
+        text = new I18nText();
+        assertFalse(text.hasGlobalText());
+
+        text.setGlobalText("glo");
+        assertTrue(text.hasGlobalText());
+
+        text.setGlobalText(null);
+        assertFalse(text.hasGlobalText());
+
+        text.setPrimaryText("pri");
+        assertFalse(text.hasGlobalText());
+
+        return;
+    }
+
+    /**
+     * Test of charAt method, of class I18nText.
+     */
+    @Test
+    public void testCharAt() {
+        System.out.println("charAt");
+
+        I18nText text;
+
+        text = new I18nText();
+
+        text.setPrimaryText("pri");
+        text.setGlobalText("glo");
+        text.setI18nText(Locale.CHINA, "chi");
+
+        assertEquals('r', text.charAt(1));
+
+        return;
+    }
+
+    /**
+     * Test of length method, of class I18nText.
+     */
+    @Test
+    public void testLength() {
+        System.out.println("length");
+
+        I18nText text;
+
+        text = new I18nText();
+
+        text.setPrimaryText("pri");
+        text.setGlobalText("glob");
+        text.setI18nText(Locale.CHINA, "china");
+
+        assertEquals(3, text.length());
+
+        return;
+    }
+
+    /**
+     * Test of subSequence method, of class I18nText.
+     */
+    @Test
+    public void testSubSequence() {
+        System.out.println("subSequence");
+
+        I18nText text;
+
+        text = new I18nText();
+
+        text.setPrimaryText("pri");
+        text.setGlobalText("glo");
+        text.setI18nText(Locale.CHINA, "chi");
+
+        assertEquals("p", text.subSequence(0, 1));
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class I18nText.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        I18nText text;
+
+        text = new I18nText();
+
+        text.setPrimaryText("pri");
+        text.setGlobalText("glo");
+        text.setI18nText(Locale.CHINA, "chi");
+
+        assertEquals("pri", text.toString());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/math/EulerYXZTest.java b/src/test/java/jp/sfjp/mikutoga/math/EulerYXZTest.java
new file mode 100644 (file)
index 0000000..0a123e2
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.math;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class EulerYXZTest {
+
+    public EulerYXZTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of constructor, of class EulerYXZ.
+     */
+    @Test
+    public void testCons() {
+        System.out.println("constructor");
+
+        EulerYXZ euler;
+
+        euler = new EulerYXZ();
+        assertEquals(0.0, euler.getXRot(), 0.0);
+        assertEquals(0.0, euler.getYRot(), 0.0);
+        assertEquals(0.0, euler.getZRot(), 0.0);
+
+        euler = new EulerYXZ(1.0, 2.0, 3.0);
+        assertEquals(1.0, euler.getXRot(), 0.0);
+        assertEquals(2.0, euler.getYRot(), 0.0);
+        assertEquals(3.0, euler.getZRot(), 0.0);
+
+        euler.setXRot(4.0);
+        assertEquals(4.0, euler.getXRot(), 0.0);
+        assertEquals(2.0, euler.getYRot(), 0.0);
+        assertEquals(3.0, euler.getZRot(), 0.0);
+
+        euler.setYRot(5.0);
+        assertEquals(4.0, euler.getXRot(), 0.0);
+        assertEquals(5.0, euler.getYRot(), 0.0);
+        assertEquals(3.0, euler.getZRot(), 0.0);
+
+        euler.setZRot(6.0);
+        assertEquals(4.0, euler.getXRot(), 0.0);
+        assertEquals(5.0, euler.getYRot(), 0.0);
+        assertEquals(6.0, euler.getZRot(), 0.0);
+
+        euler.setRot(10.0, 11.0, 12.0);
+        assertEquals(10.0, euler.getXRot(), 0.0);
+        assertEquals(11.0, euler.getYRot(), 0.0);
+        assertEquals(12.0, euler.getZRot(), 0.0);
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class EulerYXZ.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        EulerYXZ euler;
+
+        euler = new EulerYXZ(1.0, 2.0, 3.0);
+        assertEquals("x=1.0 y=2.0 z=3.0", euler.toString());
+
+        euler = new EulerYXZ(-0.0, Double.MIN_VALUE, Double.MAX_VALUE);
+        assertEquals("x=-0.0 y=4.9E-324 z=1.7976931348623157E308", euler.toString());
+
+        euler = new EulerYXZ(0.5, 0.25, StrictMath.PI);
+        assertEquals("x=0.5 y=0.25 z=3.141592653589793", euler.toString());
+
+        return;
+    }
+
+    /**
+     * Test of toDegString method, of class EulerYXZ.
+     */
+    @Test
+    public void testToDegString() {
+        System.out.println("toDegString");
+
+        EulerYXZ euler;
+
+        euler = new EulerYXZ(1.0, 2.0, 3.0);
+        assertEquals("x=57.29577951308232 y=114.59155902616465 z=171.88733853924697", euler.toDegString());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/math/MkPos2DTest.java b/src/test/java/jp/sfjp/mikutoga/math/MkPos2DTest.java
new file mode 100644 (file)
index 0000000..6d5ab13
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.math;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class MkPos2DTest {
+
+    public MkPos2DTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of constructor, of class MkPos2D.
+     */
+    @Test
+    public void testCons() {
+        System.out.println("constructor");
+
+        MkPos2D pos;
+
+        pos = new MkPos2D();
+        assertTrue(pos.isOriginPoint());
+        assertEquals(0.0, pos.getXpos(), 0.0);
+        assertEquals(0.0, pos.getYpos(), 0.0);
+
+        pos.setXpos(1.0);
+        assertFalse(pos.isOriginPoint());
+        assertEquals(1.0, pos.getXpos(), 0.0);
+        assertEquals(0.0, pos.getYpos(), 0.0);
+
+        pos.setYpos(2.0);
+        assertEquals(1.0, pos.getXpos(), 0.0);
+        assertEquals(2.0, pos.getYpos(), 0.0);
+
+        pos.setPosition(3.0, 4.0);
+        assertEquals(3.0, pos.getXpos(), 0.0);
+        assertEquals(4.0, pos.getYpos(), 0.0);
+
+        pos = new MkPos2D(5.0, 6.0);
+        assertEquals(5.0, pos.getXpos(), 0.0);
+        assertEquals(6.0, pos.getYpos(), 0.0);
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class MkPos2D.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        MkPos2D pos;
+
+        pos = new MkPos2D();
+        assertEquals("pos=[0.0, 0.0]", pos.toString());
+
+        pos = new MkPos2D(-0.0, StrictMath.PI);
+        assertEquals("pos=[-0.0, 3.141592653589793]", pos.toString());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/math/MkPos3DTest.java b/src/test/java/jp/sfjp/mikutoga/math/MkPos3DTest.java
new file mode 100644 (file)
index 0000000..92ac94b
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.math;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class MkPos3DTest {
+
+    public MkPos3DTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of constructor, of class MkPos3D.
+     */
+    @Test
+    public void testCons() {
+        System.out.println("constructor");
+
+        MkPos3D pos;
+
+        pos = new MkPos3D();
+        assertTrue(pos.isOriginPoint());
+        assertEquals(0.0, pos.getXpos(), 0.0);
+        assertEquals(0.0, pos.getYpos(), 0.0);
+        assertEquals(0.0, pos.getZpos(), 0.0);
+
+        pos.setXpos(1.0);
+        assertFalse(pos.isOriginPoint());
+        assertEquals(1.0, pos.getXpos(), 0.0);
+        assertEquals(0.0, pos.getYpos(), 0.0);
+        assertEquals(0.0, pos.getZpos(), 0.0);
+
+        pos.setYpos(2.0);
+        assertEquals(1.0, pos.getXpos(), 0.0);
+        assertEquals(2.0, pos.getYpos(), 0.0);
+        assertEquals(0.0, pos.getZpos(), 0.0);
+
+        pos.setZpos(3.0);
+        assertEquals(1.0, pos.getXpos(), 0.0);
+        assertEquals(2.0, pos.getYpos(), 0.0);
+        assertEquals(3.0, pos.getZpos(), 0.0);
+
+        pos.setPosition(4.0, 5.0, 6.0);
+        assertEquals(4.0, pos.getXpos(), 0.0);
+        assertEquals(5.0, pos.getYpos(), 0.0);
+        assertEquals(6.0, pos.getZpos(), 0.0);
+
+        pos = new MkPos3D(7.0, 8.0, 9.0);
+        assertEquals(7.0, pos.getXpos(), 0.0);
+        assertEquals(8.0, pos.getYpos(), 0.0);
+        assertEquals(9.0, pos.getZpos(), 0.0);
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class MkPos3D.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        MkPos3D pos;
+
+        pos = new MkPos3D();
+        assertEquals("x=0.0 y=0.0 z=0.0", pos.toString());
+
+        pos = new MkPos3D(-0.0, StrictMath.PI, Double.MAX_VALUE);
+        assertEquals("x=-0.0 y=3.141592653589793 z=1.7976931348623157E308", pos.toString());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/math/MkQuatTest.java b/src/test/java/jp/sfjp/mikutoga/math/MkQuatTest.java
new file mode 100644 (file)
index 0000000..6db9786
--- /dev/null
@@ -0,0 +1,513 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.math;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class MkQuatTest {
+
+    private static final double RAD_90DEG = StrictMath.PI / 2.0;
+    private static final double RAD_60DEG = StrictMath.PI / 3.0;
+    private static final double RAD_45DEG = StrictMath.PI / 4.0;
+    private static final double RAD_30DEG = StrictMath.PI / 6.0;
+    private static final double RAD_15DEG = StrictMath.PI / 12.0;
+    private static final double EPSILON = StrictMath.ulp(1.0);
+
+    public MkQuatTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    private void assert0UlpEquals(double expected, double x){
+        assertUlpEquals(expected, x, 0);
+        return;
+    }
+
+    private void assertUlpEquals(double expected, double x, int ulpNum){
+        double ulp = StrictMath.ulp(expected);
+        double delta = ulp * ulpNum;
+
+        assertEquals(expected, x, delta);
+
+        return;
+    }
+
+    /**
+     * Test of constructor, of class MkQuat.
+     */
+    @Test
+    public void testCons() {
+        System.out.println("constructor");
+
+        MkQuat qq;
+
+        qq = new MkQuat();
+        assert0UlpEquals(0.0, qq.getQ1());
+        assert0UlpEquals(0.0, qq.getQ2());
+        assert0UlpEquals(0.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        qq.setQ1(2.0);
+        assert0UlpEquals(2.0, qq.getQ1());
+        assert0UlpEquals(0.0, qq.getQ2());
+        assert0UlpEquals(0.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        qq.setQ2(3.0);
+        assert0UlpEquals(2.0, qq.getQ1());
+        assert0UlpEquals(3.0, qq.getQ2());
+        assert0UlpEquals(0.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        qq.setQ3(4.0);
+        assert0UlpEquals(2.0, qq.getQ1());
+        assert0UlpEquals(3.0, qq.getQ2());
+        assert0UlpEquals(4.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        qq.setQW(5.0);
+        assert0UlpEquals(2.0, qq.getQ1());
+        assert0UlpEquals(3.0, qq.getQ2());
+        assert0UlpEquals(4.0, qq.getQ3());
+        assert0UlpEquals(5.0, qq.getQW());
+
+        qq.setQ123W(6.0, 7.0, 8.0, 9.0);
+        assert0UlpEquals(6.0, qq.getQ1());
+        assert0UlpEquals(7.0, qq.getQ2());
+        assert0UlpEquals(8.0, qq.getQ3());
+        assert0UlpEquals(9.0, qq.getQW());
+
+        qq = new MkQuat(0.1, 0.2, 0.3, 0.4);
+        assert0UlpEquals(0.1, qq.getQ1());
+        assert0UlpEquals(0.2, qq.getQ2());
+        assert0UlpEquals(0.3, qq.getQ3());
+        assert0UlpEquals(0.4, qq.getQW());
+
+        MkQuat qqx = new MkQuat(1.0, 2.0, 3.0, 4.0);
+        qq = new MkQuat(qqx);
+        assert0UlpEquals(1.0, qq.getQ1());
+        assert0UlpEquals(2.0, qq.getQ2());
+        assert0UlpEquals(3.0, qq.getQ3());
+        assert0UlpEquals(4.0, qq.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of mul method, of class MkQuat.
+     */
+    @Test
+    public void testMul() {
+        System.out.println("mul");
+
+        MkQuat qqa;
+        MkQuat qqb;
+        MkQuat result;
+
+        result = new MkQuat();
+
+        qqa = new MkQuat(1.0, 2.0, 3.0, 4.0);
+        qqb = new MkQuat(5.0, 6.0, 7.0, 8.0);
+        MkQuat.mul(qqa, qqb, result);
+        assert0UlpEquals(24.0, result.getQ1());
+        assert0UlpEquals(48.0, result.getQ2());
+        assert0UlpEquals(48.0, result.getQ3());
+        assert0UlpEquals(-6.0, result.getQW());
+
+        qqa = new MkQuat(1.0, 2.0, 3.0, 4.0);
+        qqb = new MkQuat(6.0, 7.0, 8.0, 9.0);
+        MkQuat.mul(qqa, qqb, result);
+        assert0UlpEquals(28.0, result.getQ1());
+        assert0UlpEquals(56.0, result.getQ2());
+        assert0UlpEquals(54.0, result.getQ3());
+        assert0UlpEquals(-8.0, result.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of conjugate method, of class MkQuat.
+     */
+    @Test
+    public void testConjugate() {
+        System.out.println("conjugate");
+
+        MkQuat qq;
+        MkQuat result;
+
+        qq = new MkQuat(1.0, 2.0, 3.0, 4.0);
+        result = new MkQuat();
+        MkQuat.conjugate(qq, result);
+        assert0UlpEquals(-1.0, result.getQ1());
+        assert0UlpEquals(-2.0, result.getQ2());
+        assert0UlpEquals(-3.0, result.getQ3());
+        assert0UlpEquals(4.0, result.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of normalize method, of class MkQuat.
+     */
+    @Test
+    public void testNormalize() {
+        System.out.println("normalize");
+
+        MkQuat qq;
+        MkQuat result;
+
+        qq = new MkQuat();
+        result = new MkQuat();
+        MkQuat.normalize(qq, result);
+        assert0UlpEquals(0.0, result.getQ1());
+        assert0UlpEquals(0.0, result.getQ2());
+        assert0UlpEquals(0.0, result.getQ3());
+        assert0UlpEquals(1.0, result.getQW());
+
+        qq = new MkQuat(2.0, 2.0, 2.0, 2.0);
+        MkQuat.normalize(qq, result);
+        assertUlpEquals(0.5, result.getQ1(), 0);
+        assertUlpEquals(0.5, result.getQ2(), 0);
+        assertUlpEquals(0.5, result.getQ3(), 0);
+        assertUlpEquals(0.5, result.getQW(), 0);
+
+        return;
+    }
+
+    /**
+     * Test of inverse method, of class MkQuat.
+     */
+    @Test
+    public void testInverse() {
+        System.out.println("inverse");
+
+        MkQuat qq;
+        MkQuat result;
+
+        qq = new MkQuat();
+        result = new MkQuat();
+        MkQuat.inverse(qq, result);
+        assert0UlpEquals(0.0, result.getQ1());
+        assert0UlpEquals(0.0, result.getQ2());
+        assert0UlpEquals(0.0, result.getQ3());
+        assert0UlpEquals(1.0, result.getQW());
+
+        qq = new MkQuat(2.0, 2.0, 2.0, 2.0);
+        MkQuat.inverse(qq, result);
+        assertUlpEquals(-0.125, result.getQ1(), 0);
+        assertUlpEquals(-0.125, result.getQ2(), 0);
+        assertUlpEquals(-0.125, result.getQ3(), 0);
+        assertUlpEquals(0.125, result.getQW(), 0);
+
+        return;
+    }
+
+    /**
+     * Test of abs method, of class MkQuat.
+     */
+    @Test
+    public void testAbs() {
+        System.out.println("abs");
+
+        MkQuat qq;
+
+        qq = new MkQuat();
+        assert0UlpEquals(1.0, qq.abs());
+
+        qq = new MkQuat(0.0, 0.0, 0.0, 0.0);
+        assert0UlpEquals(0.0, qq.abs());
+
+        qq = new MkQuat(1.0, 2.0, 0.0, 2.0);
+        assertUlpEquals(3.0, qq.abs(), 0);
+
+        qq = new MkQuat(2.0, 2.0, 2.0, 2.0);
+        assertUlpEquals(4.0, qq.abs(), 0);
+
+        return;
+    }
+
+    /**
+     * Test of setPos3D method, of class MkQuat.
+     */
+    @Test
+    public void testReadPos3D_3args() {
+        System.out.println("readPos3D");
+
+        MkQuat qq;
+
+        qq = new MkQuat(9, 9, 9, 9);
+        qq.setPos3D(1.0, 2.0, 3.0);
+        assert0UlpEquals(1.0, qq.getQ1());
+        assert0UlpEquals(2.0, qq.getQ2());
+        assert0UlpEquals(3.0, qq.getQ3());
+        assert0UlpEquals(0.0, qq.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of setPos3D method, of class MkQuat.
+     */
+    @Test
+    public void testReadPos3D_MkPos3D() {
+        System.out.println("readPos3D");
+
+        MkQuat qq;
+        MkPos3D pos;
+
+        qq = new MkQuat(9, 9, 9, 9);
+        pos = new MkPos3D(1.0, 2.0, 3.0);
+        qq.setPos3D(pos);
+        assert0UlpEquals(1.0, qq.getQ1());
+        assert0UlpEquals(2.0, qq.getQ2());
+        assert0UlpEquals(3.0, qq.getQ3());
+        assert0UlpEquals(0.0, qq.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of setEulerYXZ method, of class MkQuat.
+     */
+    @Test
+    public void testReadEulerYXZ_3args() {
+        System.out.println("readEulerYXZ");
+
+        MkQuat qq;
+
+        qq = new MkQuat(9, 9, 9, 9);
+        qq.setEulerYXZ(0.0, 0.0, 0.0);
+        assert0UlpEquals(0.0, qq.getQ1());
+        assert0UlpEquals(0.0, qq.getQ2());
+        assert0UlpEquals(0.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of setEulerYXZ method, of class MkQuat.
+     */
+    @Test
+    public void testReadEulerYXZ_EulerYXZ() {
+        System.out.println("readEulerYXZ");
+
+        MkQuat qq;
+        EulerYXZ yxz;
+
+        qq = new MkQuat(9, 9, 9, 9);
+        yxz = new EulerYXZ();
+        qq.setEulerYXZ(yxz);
+        assert0UlpEquals(0.0, qq.getQ1());
+        assert0UlpEquals(0.0, qq.getQ2());
+        assert0UlpEquals(0.0, qq.getQ3());
+        assert0UlpEquals(1.0, qq.getQW());
+
+        return;
+    }
+
+    /**
+     * Test of toEulerYXZ method, of class MkQuat.
+     */
+    @Test
+    public void testToEulerYXZ_EulerYXZ_double() {
+        System.out.println("toEulerYXZ");
+
+        EulerYXZ eu;
+        MkQuat qq;
+
+        qq = new MkQuat();
+
+        qq.setEulerYXZ(1.0, 2.0, 3.0);
+        eu = new EulerYXZ();
+        qq.toEulerYXZ(eu, 0.0);
+        assertUlpEquals(1.0, eu.getXRot(), 1);
+        assertUlpEquals(2.0, eu.getYRot(), 2);
+        assertUlpEquals(3.0, eu.getZRot(), 0);
+
+        qq.setEulerYXZ(RAD_90DEG, 0.0, 0.0);
+        qq.toEulerYXZ(eu, 0.0);
+        assert0UlpEquals(RAD_90DEG, eu.getXRot());
+        assert0UlpEquals(0.0, eu.getYRot());
+        assert0UlpEquals(0.0, eu.getZRot());
+
+        qq.setEulerYXZ(RAD_90DEG, RAD_30DEG, 0.0);
+        qq.toEulerYXZ(eu, 0.0);
+        assert0UlpEquals(RAD_90DEG, eu.getXRot());
+        assert0UlpEquals(0.0, eu.getYRot());
+        assertUlpEquals(-RAD_30DEG, eu.getZRot(), 1);
+
+        qq.toEulerYXZ(eu, RAD_15DEG);
+        assert0UlpEquals(RAD_90DEG, eu.getXRot());
+        assert0UlpEquals(RAD_15DEG, eu.getYRot());
+        assertUlpEquals(-RAD_15DEG, eu.getZRot(), 2);
+
+        qq.setEulerYXZ(RAD_90DEG, RAD_45DEG, 0.0);
+        qq.toEulerYXZ(eu, 0.0);
+        assert0UlpEquals(RAD_90DEG, eu.getXRot());
+        assert0UlpEquals(0.0, eu.getYRot());
+        assert0UlpEquals(-RAD_45DEG, eu.getZRot());
+
+        qq.setEulerYXZ(RAD_90DEG, RAD_45DEG, RAD_45DEG);
+        qq.toEulerYXZ(eu, 0.0);
+        assertEquals(RAD_90DEG, eu.getXRot(), 1E-7);
+        assert0UlpEquals(0.0, eu.getYRot());
+        assertEquals(0.0, eu.getZRot(), EPSILON);
+
+        qq.setEulerYXZ(RAD_90DEG, RAD_30DEG, RAD_60DEG);
+        qq.toEulerYXZ(eu, 0.0);
+        assert0UlpEquals(RAD_90DEG, eu.getXRot());
+        assert0UlpEquals(0.0, eu.getYRot());
+        assert0UlpEquals(RAD_30DEG, eu.getZRot());
+
+        qq.setEulerYXZ(RAD_30DEG, RAD_45DEG, RAD_45DEG);
+        qq.toEulerYXZ(eu, 0.0);
+        assertUlpEquals(RAD_30DEG, eu.getXRot(), 1);
+        assertUlpEquals(RAD_45DEG, eu.getYRot(), 1);
+        assertUlpEquals(RAD_45DEG, eu.getZRot(), 1);
+
+        return;
+    }
+
+    /**
+     * Test of toEulerYXZ method, of class MkQuat.
+     */
+    @Test
+    public void testToEulerYXZ_EulerYXZ() {
+        System.out.println("toEulerYXZ");
+
+        EulerYXZ eu;
+        MkQuat qq;
+
+        qq = new MkQuat();
+
+        qq.setEulerYXZ(1.0, 2.0, 3.0);
+        eu = new EulerYXZ();
+        qq.toEulerYXZ(eu);
+        assertUlpEquals(1.0, eu.getXRot(), 1);
+        assertUlpEquals(2.0, eu.getYRot(), 2);
+        assertUlpEquals(3.0, eu.getZRot(), 0);
+
+        qq.setEulerYXZ(StrictMath.PI, 0.0, 0.0);
+        qq.toEulerYXZ(eu);
+        assertEquals(0.0, eu.getXRot(), EPSILON);
+        assert0UlpEquals(StrictMath.PI, eu.getYRot());
+        assert0UlpEquals(StrictMath.PI, eu.getZRot());
+
+        return;
+    }
+
+    /**
+     * Test of rotatePos method, of class MkQuat.
+     */
+    @Test
+    public void testRotatePos() {
+        System.out.println("rotatePos");
+
+        MkPos3D pos;
+        MkPos3D result;
+        MkQuat qq;
+
+        qq = new MkQuat();
+
+        pos = new MkPos3D(1.0, 1.0, 1.0);
+        result = new MkPos3D();
+
+        qq.setEulerYXZ(0.0, RAD_90DEG, 0.0);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(1.0, result.getXpos(), 0);
+        assertUlpEquals(1.0, result.getYpos(), 0);
+        assertUlpEquals(-1.0, result.getZpos(), 2);
+
+        qq.setEulerYXZ(RAD_90DEG, 0.0, 0.0);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(1.0, result.getXpos(), 0);
+        assertUlpEquals(-1.0, result.getYpos(), 2);
+        assertUlpEquals(1.0, result.getZpos(), 0);
+
+        qq.setEulerYXZ(0.0, 0.0, RAD_90DEG);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(-1.0, result.getXpos(), 2);
+        assertUlpEquals(1.0, result.getYpos(), 0);
+        assertUlpEquals(1.0, result.getZpos(), 0);
+
+        qq.setEulerYXZ(RAD_90DEG, RAD_90DEG, 0.0);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(1.0, result.getXpos(), 2);
+        assertUlpEquals(-1.0, result.getYpos(), 1);
+        assertUlpEquals(-1.0, result.getZpos(), 1);
+
+        qq.setEulerYXZ(0.0, RAD_90DEG, RAD_90DEG);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(1.0, result.getXpos(), 1);
+        assertUlpEquals(1.0, result.getYpos(), 1);
+        assertUlpEquals(1.0, result.getZpos(), 0);
+
+        qq.setEulerYXZ(RAD_90DEG, 0.0, RAD_90DEG);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(-1.0, result.getXpos(), 1);
+        assertUlpEquals(-1.0, result.getYpos(), 1);
+        assertUlpEquals(1.0, result.getZpos(), 2);
+
+        pos = new MkPos3D(1.0, 2.0, 3.0);
+
+        qq.setEulerYXZ(0.0, RAD_90DEG, 0.0);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(3.0, result.getXpos(), 0);
+        assertUlpEquals(2.0, result.getYpos(), 0);
+        assertUlpEquals(-1.0, result.getZpos(), 3);
+
+        qq.setEulerYXZ(RAD_90DEG, 0.0, 0.0);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(1.0, result.getXpos(), 0);
+        assertUlpEquals(-3.0, result.getYpos(), 0);
+        assertUlpEquals(2.0, result.getZpos(), 2);
+
+        qq.setEulerYXZ(0.0, 0.0, RAD_90DEG);
+        qq.rotatePos(pos, result);
+        assertUlpEquals(-2.0, result.getXpos(), 0);
+        assertUlpEquals(1.0, result.getYpos(), 2);
+        assertUlpEquals(3.0, result.getZpos(), 0);
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class MkQuat.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        MkQuat qq;
+
+        qq = new MkQuat(-0.0, Double.MIN_NORMAL, Double.MAX_EXPONENT, StrictMath.PI);
+        assertEquals("q1=-0.0 q2=2.2250738585072014E-308 q3=1023.0 w=3.141592653589793", qq.toString());
+
+        return;
+    }
+
+}
diff --git a/src/test/java/jp/sfjp/mikutoga/math/MkVec3DTest.java b/src/test/java/jp/sfjp/mikutoga/math/MkVec3DTest.java
new file mode 100644 (file)
index 0000000..9b2a5b9
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ */
+
+package jp.sfjp.mikutoga.math;
+
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ */
+public strictfp class MkVec3DTest {
+
+    public MkVec3DTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() {
+    }
+
+    @AfterClass
+    public static void tearDownClass() {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of constructor, of class MkVec3D.
+     */
+    @Test
+    public void testCons() {
+        System.out.println("constructor");
+
+        MkVec3D vec;
+
+        vec = new MkVec3D();
+        assertEquals(0.0, vec.getXVal(), 0.0);
+        assertEquals(0.0, vec.getYVal(), 0.0);
+        assertEquals(0.0, vec.getZVal(), 0.0);
+
+        vec.setXVal(1.0);
+        assertEquals(1.0, vec.getXVal(), 0.0);
+        assertEquals(0.0, vec.getYVal(), 0.0);
+        assertEquals(0.0, vec.getZVal(), 0.0);
+
+        vec.setYVal(2.0);
+        assertEquals(1.0, vec.getXVal(), 0.0);
+        assertEquals(2.0, vec.getYVal(), 0.0);
+        assertEquals(0.0, vec.getZVal(), 0.0);
+
+        vec.setZVal(3.0);
+        assertEquals(1.0, vec.getXVal(), 0.0);
+        assertEquals(2.0, vec.getYVal(), 0.0);
+        assertEquals(3.0, vec.getZVal(), 0.0);
+
+        vec.setVector(4.0, 5.0, 6.0);
+        assertEquals(4.0, vec.getXVal(), 0.0);
+        assertEquals(5.0, vec.getYVal(), 0.0);
+        assertEquals(6.0, vec.getZVal(), 0.0);
+
+        vec = new MkVec3D(7.0, 8.0, 9.0);
+        assertEquals(7.0, vec.getXVal(), 0.0);
+        assertEquals(8.0, vec.getYVal(), 0.0);
+        assertEquals(9.0, vec.getZVal(), 0.0);
+
+        return;
+    }
+
+    /**
+     * Test of toString method, of class MkVec3D.
+     */
+    @Test
+    public void testToString() {
+        System.out.println("toString");
+
+        MkVec3D vec;
+
+        vec = new MkVec3D();
+        assertEquals("vec=[0.0, 0.0, 0.0]", vec.toString());
+
+        vec = new MkVec3D(-0.0, StrictMath.PI, Double.MAX_VALUE);
+        assertEquals("vec=[-0.0, 3.141592653589793, 1.7976931348623157E308]", vec.toString());
+
+        return;
+    }
+
+}
index 45f1df0..caaa1ba 100644 (file)
@@ -7,7 +7,7 @@
 
 package sample.pmd;
 
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 import jp.sourceforge.mikutoga.pmd.parser.PmdBasicHandler;
 import jp.sourceforge.mikutoga.pmd.parser.PmdBoneHandler;
 import jp.sourceforge.mikutoga.pmd.parser.PmdEngHandler;
index f5cb697..1945da6 100644 (file)
@@ -13,7 +13,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 import jp.sourceforge.mikutoga.pmd.parser.PmdParser;
 
 /**
index f896152..73bf7be 100644 (file)
@@ -7,12 +7,12 @@
 
 package sample.vmd;
 
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
-import jp.sourceforge.mikutoga.parser.ParseStage;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.ParseStage;
 import jp.sourceforge.mikutoga.vmd.VmdConst;
-import jp.sourceforge.mikutoga.vmd.parser.VmdLightingHandler;
-import jp.sourceforge.mikutoga.vmd.parser.VmdCameraHandler;
 import jp.sourceforge.mikutoga.vmd.parser.VmdBasicHandler;
+import jp.sourceforge.mikutoga.vmd.parser.VmdCameraHandler;
+import jp.sourceforge.mikutoga.vmd.parser.VmdLightingHandler;
 
 /**
  * サンプルのハンドラ。
index ce3beed..565e18f 100644 (file)
@@ -13,7 +13,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import jp.sourceforge.mikutoga.parser.MmdFormatException;
+import jp.sfjp.mikutoga.bin.parser.MmdFormatException;
 import jp.sourceforge.mikutoga.vmd.parser.VmdParser;
 
 /**