import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import jp.oarts.pirka.core.kernel.FieldMap;
import jp.oarts.pirka.core.res.PirkaFileDownloaderFromBytes;
import jp.oarts.pirka.core.util.check.PirkaChecker;
import jp.oarts.pirka.core.util.check.PirkaCheckerLength;
import jp.oarts.pirka.core.util.check.PirkaCheckerString;
import jp.oarts.pirka.core.util.check.PirkaCheckerStringChars;
import jp.oarts.pirka.core.win.PirkaWindow;




/**
 * Indexクラス
 *  @author
 */
public class Index extends  PirkaWindow {


	/**
	 * コンストラクタ
	 * 
	 */
	public Index() {

		///////////////////////////////////////////////////
		//  入力チェック
		///////////////////////////////////////////////////
		FieldMap field = getFieldMap();

		//　入力チェックをしないメソッド
		field.setAutoCheck("returnBtn", false);

		//　エラー発生時に項目とエラー時の表示名を教えるメソッド
		field.setOfficialFieldName("userName" , "userName項目");
		field.setOfficialFieldName("userID" , "userID項目");
		field.setOfficialFieldName("address" , "address項目");
		field.setOfficialFieldName("tel" , "tel項目");



		//　入力チェックの宣言
		addCheck("userName", PirkaChecker.required );
		addCheck("userName", new PirkaCheckerLength(PirkaCheckerLength.RANGE, 20, 20));
		addCheck("userName", new PirkaCheckerString(PirkaCheckerStringChars.WIDE , PirkaCheckerStringChars.HIGHT_ALPHABET , PirkaCheckerStringChars.NUM , PirkaCheckerStringChars.HALF_KANA ));
		addCheck("userID", PirkaChecker.required );
		addCheck("userID", new PirkaCheckerLength(PirkaCheckerLength.RANGE, 20, 20));
		addCheck("userID", new PirkaCheckerString(PirkaCheckerStringChars.WIDE , PirkaCheckerStringChars.HIGHT_ALPHABET , PirkaCheckerStringChars.NUM , PirkaCheckerStringChars.HALF_KANA ));
		addCheck("address", PirkaChecker.required );
		addCheck("address", new PirkaCheckerLength(PirkaCheckerLength.RANGE, 20, 20));
		addCheck("address", new PirkaCheckerString(PirkaCheckerStringChars.WIDE , PirkaCheckerStringChars.HIGHT_ALPHABET , PirkaCheckerStringChars.NUM , PirkaCheckerStringChars.HALF_KANA ));
		addCheck("tel", PirkaChecker.required );
		addCheck("tel", new PirkaCheckerLength(PirkaCheckerLength.RANGE, 20, 20));
		addCheck("tel", new PirkaCheckerString(PirkaCheckerStringChars.WIDE , PirkaCheckerStringChars.HIGHT_ALPHABET , PirkaCheckerStringChars.NUM , PirkaCheckerStringChars.HALF_KANA ));

		//　エラーの場合アクションメソッドを呼ばない
		addErrorCheckReturner();

		//　エラーが発生していてもアクションメソッドは呼び出す
		// addErrorChaeckBreak();



	}




	/**
	 * 描画前処理
	 */
	public void preDraw(){


		///////////////////////////////////////////////////
		//  描画内容を設定する
		///////////////////////////////////////////////////

		FieldMap field = getFieldMap();

		field.setValue("userName", "");
		field.setValue("userID", "");
		field.setValue("address", "");
		field.setValue("tel", "");




	}





	/**
	 * doitBtn
	 * @return 次画面クラス
	 */
	public PirkaWindow doitBtn(){
		System.out.println("---------doitBtn");


	



		///////////////////////////////////////////////////
		//  入力値を取得する。
		///////////////////////////////////////////////////
		FieldMap field = getFieldMap();

		String userName = (String)field.getValueString("userName");
		String userID = (String)field.getValueString("userID");
		String address = (String)field.getValueString("address");
		String tel = (String)field.getValueString("tel");



		return this;
	}



	/**
	 * returnBtn
	 * @return 次画面クラス
	 */
	public PirkaWindow returnBtn(){
		System.out.println("---------returnBtn");



		return this;
	}




}


