2 * binary parser interface
4 * License : The MIT License
5 * Copyright(c) 2013 MikuToga Partners
8 package jp.sfjp.mikutoga.bin.parser;
10 import java.io.IOException;
14 * <p>バイト列、各種プリミティブ型値およびエンコードされた文字列を読み込む。
15 * <p>long,double、およびビッグエンディアン形式のデータは未サポート。
17 public interface BinParser {
21 * @return 入力ソースの読み込み位置。単位はbyte。
26 * 入力ソースにまだデータが残っているか判定する。
27 * @return まだ読み込んでいないデータが残っていればtrue
28 * @throws IOException IOエラー
30 boolean hasMore() throws IOException;
34 * @param skipLength 読み飛ばすバイト数。
35 * @throws IOException IOエラー
36 * @throws MmdEofException 読み飛ばす途中でストリーム終端に達した。
37 * @see java.io.InputStream#skip(long)
39 void skip(long skipLength) throws IOException, MmdEofException;
44 * @param off 読み込み開始オフセット
45 * @param length 読み込みバイト数
46 * @throws NullPointerException 配列がnull
47 * @throws IndexOutOfBoundsException 引数が配列属性と矛盾
48 * @throws IOException IOエラー
49 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
50 * @see java.io.InputStream#read(byte[], int, int)
52 void parseByteArray(byte[] dst, int off, int length)
53 throws NullPointerException,
54 IndexOutOfBoundsException,
60 * <p>配列要素全ての読み込みが試みられる。
62 * @throws NullPointerException 配列がnull
63 * @throws IOException IOエラー
64 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
65 * @see java.io.InputStream#read(byte[])
67 void parseByteArray(byte[] dst)
68 throws NullPointerException, IOException, MmdEofException;
73 * @throws IOException IOエラー
74 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
76 byte parseByte() throws IOException, MmdEofException;
79 * 符号無し値としてbyte値を読み込み、int型に変換して返す。
80 * <p>符号は拡張されない。(0xffは0x000000ffとなる)
81 * @return 読み込まれた値のint値
82 * @throws IOException IOエラー
83 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
85 int parseUByteAsInt() throws IOException, MmdEofException;
88 * byte値を読み込み、boolean型に変換して返す。
89 * <p>0x00は偽、それ以外は真と解釈される。
90 * @return 読み込まれた値のboolean値
91 * @throws IOException IOエラー
92 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
94 boolean parseBoolean() throws IOException, MmdEofException;
98 * <p>short値はリトルエンディアンで格納されていると仮定される。
100 * @throws IOException IOエラー
101 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
103 short parseLeShort() throws IOException, MmdEofException;
106 * 符号無し値としてshort値を読み込み、int型に変換して返す。
107 * <p>符号は拡張されない。(0xffffは0x0000ffffとなる)
108 * <p>short値はリトルエンディアンで格納されていると仮定される。
109 * @return 読み込まれた値のint値
110 * @throws IOException IOエラー
111 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
113 int parseLeUShortAsInt() throws IOException, MmdEofException;
117 * <p>int値はリトルエンディアンで格納されていると仮定される。
119 * @throws IOException IOエラー
120 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
122 int parseLeInt() throws IOException, MmdEofException;
126 * <p>float値はリトルエンディアンで格納されていると仮定される。
127 * @return 読み込んだfloat値
128 * @throws IOException IOエラー
129 * @throws MmdEofException 読み込む途中でストリーム終端に達した。
131 float parseLeFloat() throws IOException, MmdEofException;
135 * @param decoder 文字デコーダ
136 * @param byteLen 読み込む固定バイト長
138 * @throws IOException 入力エラー
139 * @throws MmdEofException 固定長バイト列を読む前に末端に達した。
140 * @throws MmdFormatException 文字エンコーディングに関するエラー
142 String parseString(TextDecoder decoder, int byteLen)
143 throws IOException, MmdEofException, MmdFormatException;