X-Git-Url: http://git.osdn.net/view?p=mikutoga%2FTogaGem.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fjp%2Fsourceforge%2Fmikutoga%2Fparser%2FTextDecoder.java;h=1a8044a993470df319d4000293c1d1bc5ed0dc32;hp=879cb932d3a628acb1f47e86c766e85887f60d00;hb=892da73921247c4e9a7f607228aaa8e54567f09a;hpb=0ba5d64a08128cc679109f464ef896a4564fd7a0 diff --git a/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java b/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java index 879cb93..1a8044a 100644 --- a/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java +++ b/src/main/java/jp/sourceforge/mikutoga/parser/TextDecoder.java @@ -133,7 +133,7 @@ public class TextDecoder { /** * バイト列を読み込み文字列へデコーディングする。 - * @param source 入力ソース + * @param is 入力ストリーム * @param byteSize 読み込みバイトサイズ * @return 内部に保持されるデコード結果。 * 次回呼び出しまでに結果の適切なコピーがなされなければならない。 @@ -142,11 +142,15 @@ public class TextDecoder { * もしくは未定義文字 * @throws IOException 入力エラー */ - public CharBuffer parseString(MmdSource source, int byteSize) + public CharBuffer parseString(MmdInputStream is, int byteSize) throws MmdEofException, MmdFormatException, IOException{ prepareBuffer(byteSize); - source.parseByteArray(this.byteArray, 0, byteSize); + int readSize = is.read(this.byteArray, 0, byteSize); + if(readSize != byteSize){ + throw new MmdEofException(is.getPosition()); + } + this.byteBuffer.rewind().limit(byteSize); chopZeroTermed(); @@ -158,10 +162,10 @@ public class TextDecoder { if(decResult.isError()){ if(decResult.isUnmappable()){ throw new MmdFormatException("unmapped character", - source.getPosition() ); + is.getPosition() ); }else{ throw new MmdFormatException("illegal character encoding", - source.getPosition() ); + is.getPosition() ); } }else if(decResult.isOverflow()){ assert false;