/*
 * The MIT License
 *
 * Copyright 2013 Dra0211.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package kinugasa.contents.text;

import java.io.Serializable;
import kinugasa.contents.resource.IllegalFormatException;

/**
 * Kinugasa : Reader: 文字列を解析し、あるクラスインスタンスを構築する機能を提供します.
 * <br>
 * @param <T> ある行の解析結果として期待される型を指定します。<br>
 *
 * @version 1.0.0<br>
 * @author Dra0211<br>
 */
public interface Reader<T> extends Serializable {

	/**
	 * テキストファイルの行lineを解析し、T型のインスタンスとして返します.
	 * コメントおよび空行の場合はnullを返します.<br>
	 * 例として型パラメータにString[]を指定したCSVファイル用パーサの簡単な実装は以下のようになります.<br>
	 * return line.split(",");<br>
	 * 
	 * @param line 解析する行.<br>
	 * 
	 * @return lineから構築されたインスタンス.この行がコメントまたは空行で、読み込み対象でない場合はnullを返す.<Br>
	 *
	 * @throws IllegalFormatException 行の定義が不正な場合に投げる.<br>
	 */
	public T parse(String line) throws IllegalFormatException;
}
