OSDN Git Service

パッケージ変更。テスト整備。
[mikutoga/TogaGem.git] / src / main / java / jp / sfjp / mikutoga / bin / export / TextExporter.java
@@ -5,7 +5,7 @@
  * Copyright(c) 2011 MikuToga Partners
  */
 
  * Copyright(c) 2011 MikuToga Partners
  */
 
-package jp.sourceforge.mikutoga.binio;
+package jp.sfjp.mikutoga.bin.export;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -49,9 +49,13 @@ public class TextExporter {
 
         if(encoder == null) throw new NullPointerException();
         this.encoder = encoder;
 
         if(encoder == null) throw new NullPointerException();
         this.encoder = encoder;
+        this.encoder.reset();
         this.encoder.onMalformedInput(CodingErrorAction.REPORT);
         this.encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
 
         this.encoder.onMalformedInput(CodingErrorAction.REPORT);
         this.encoder.onUnmappableCharacter(CodingErrorAction.REPORT);
 
+        this.cbuf.clear();
+        this.bbuf.clear();
+
         return;
     }
 
         return;
     }
 
@@ -80,8 +84,10 @@ public class TextExporter {
     public void setCharBufSize(int newSize)
             throws IllegalArgumentException {
         if(newSize <= 0) throw new IllegalArgumentException();
     public void setCharBufSize(int newSize)
             throws IllegalArgumentException {
         if(newSize <= 0) throw new IllegalArgumentException();
+
         this.cbuf = CharBuffer.allocate(newSize);
         this.cbuf.clear();
         this.cbuf = CharBuffer.allocate(newSize);
         this.cbuf.clear();
+
         return;
     }
 
         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();
         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();
         this.barray = new byte[newSize];
         this.bbuf = ByteBuffer.wrap(this.barray);
         this.bbuf.clear();
+
         return;
     }
 
         return;
     }
 
@@ -185,7 +193,8 @@ public class TextExporter {
 
     /**
      * 入力バッファに文字を埋める。
 
     /**
      * 入力バッファに文字を埋める。
-     * <p>入力バッファが一杯になるか入力文字列がなくなるまでバッファが埋められる。
+     * <p>入力バッファが一杯になるか
+     * 入力文字列がなくなるまでバッファが埋められる。
      */
     private void loadCharBuffer(){
         while(this.cbuf.hasRemaining() && hasMoreInput()){
      */
     private void loadCharBuffer(){
         while(this.cbuf.hasRemaining() && hasMoreInput()){