//***********************************************************************************************
//*  FUW00107SF01DBean.java                 All Rights reserved.Copyright (c) K-Opticom   
//***********************************************************************************************
/*
履歴：
	NO	日付			更新者								    
	01	2013.03.07		Webクライアント定義ツール 2.0.39		
*/
 
/**
 * <DL>
 * <DT>名前
 * <p>
 * <DT>説明: 
 * <DD>データの初期化.
 * <DD> generated by Web Client tool V01/L01.
 * </DL>
*/
package eo.web.webview.FUW00107SF;
 
import java.io.Serializable;
import com.fujitsu.futurity.web.x33.beans.X33VViewBaseBean;
import com.fujitsu.futurity.web.x33.beans.X33VListedBeanInterface;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeList;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeBooleanBean;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeStringBean;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeLongBean;
import com.fujitsu.futurity.web.x33.beans.X33VLoadModelException;
import com.fujitsu.futurity.web.x33.beans.X33VDataTypeBeanInterface;
import com.fujitsu.futurity.web.x31.X31CBaseBean;
import com.fujitsu.futurity.web.x31.X31CWebComponent;
 
import javax.faces.model.SelectItem;
import java.util.ArrayList;
// 例外処理用にインポートする
import com.fujitsu.futurity.web.x33.X33SException;
 
/* シリアライズ警告 */
@SuppressWarnings("serial")
public class FUW00107SF01DBean 
    implements X33VDataTypeBeanInterface, X33VListedBeanInterface, Serializable {
    
    //プロパティの初期化
	protected String ymd_update;
	protected String ymd_value = "";
    protected Boolean ymd_enabled = false;
	protected String ymd_state = "";
	protected X33VDataTypeList year_list = null;			
	protected X33VDataTypeList mon_list = null;			
	protected X33VDataTypeList day_list = null;			
 
    protected int index;
 
	// コンストラクタ生成
	public FUW00107SF01DBean(){
	
		// コンストラクタの宣言部生成
		year_list = new X33VDataTypeList();
		mon_list = new X33VDataTypeList();
		day_list = new X33VDataTypeList();
	}
 
    /**
     *  Getter/Setterメソッド
     */
	public String getYmd_update() {
		return this.ymd_update ;
	}
 
	public void setYmd_update(String param) {
		this.ymd_update = param ;
	}
 
	public String getYmd_value() {
		return this.ymd_value ;
	}
 
	public void setYmd_value(String param) {
		this.ymd_value = param ;
	}
 
    public Boolean getYmd_enabled() {
		return this.ymd_enabled ;
	}
 
	public void setYmd_enabled(Boolean param) {
		this.ymd_enabled = param ;
	}
 
 	public String getYmd_state() {
		return this.ymd_state ;
	}
 
	public void setYmd_state(String param) {
		this.ymd_state = param ;
	}
 
 
    public X33VDataTypeList getYear_list() {
        return this.year_list ;
    }
 
    public void setYear_list(X33VDataTypeList param) {
        this.year_list = param ;
    }
 
    public ArrayList<SelectItem> getJsflist_year (){
        ArrayList ary = new ArrayList<SelectItem>();
        for(int i=0; i< year_list.size(); i++){
            String itemValue = (String)((X33VDataTypeStringBean) year_list.get(i)).getValue();
            SelectItem item = new SelectItem(new Integer(i).toString(), itemValue);
            ary.add(item);
		}
        return ary;
    }
 
 
    public X33VDataTypeList getMon_list() {
        return this.mon_list ;
    }
 
    public void setMon_list(X33VDataTypeList param) {
        this.mon_list = param ;
    }
 
    public ArrayList<SelectItem> getJsflist_mon (){
        ArrayList ary = new ArrayList<SelectItem>();
        for(int i=0; i< mon_list.size(); i++){
            String itemValue = (String)((X33VDataTypeStringBean) mon_list.get(i)).getValue();
            SelectItem item = new SelectItem(new Integer(i).toString(), itemValue);
            ary.add(item);
		}
        return ary;
    }
 
 
    public X33VDataTypeList getDay_list() {
        return this.day_list ;
    }
 
    public void setDay_list(X33VDataTypeList param) {
        this.day_list = param ;
    }
 
    public ArrayList<SelectItem> getJsflist_day (){
        ArrayList ary = new ArrayList<SelectItem>();
        for(int i=0; i< day_list.size(); i++){
            String itemValue = (String)((X33VDataTypeStringBean) day_list.get(i)).getValue();
            SelectItem item = new SelectItem(new Integer(i).toString(), itemValue);
            ary.add(item);
		}
        return ary;
    }
 
    public int getIndex() {
        return this.index ;
    }
 
    public void setIndex(int index) {
        this.index = index;
    }
 
    /**
     * 項目名とサブキーからデータを取得します
     *
     * @param key 項目名
     * @param subkey サブキー
     * @return Object データ
     */
    public Object loadModelData(String key, String subkey) {
 
        // key,subkeyがnullの場合、nullを返す
        if(key == null || subkey == null){
            return null;
        }
 
        int separaterPoint = key.indexOf("/");       
 
        //項目ごとに処理を入れる。
        //データタイプがStringの項目"選択年月日"(項目ＩＤ:ymd)
        if(key.equals("選択年月日")){
            if(subkey.equalsIgnoreCase("value")){
                return getYmd_value();
            }
            else if(subkey.equalsIgnoreCase("enable")){ //subkeyが"enable"の場合、ymd_enableのgetterの戻り値を返す。
                return getYmd_enabled(); 
            }
            else if(subkey.equalsIgnoreCase("state")){ //subkeyが"state"の場合、ステータスを返す。
                return getYmd_state();                
            }
        }
 
        // 配列項目 "年"(String型。項目ID:year)
        else if(key.equals("年")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.valueOf(year_list.size());
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= year_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            } 
            return ((X33VDataTypeStringBean)year_list.get(tmpIndex)).loadModelData(subkey);
        }
 
        // 配列項目 "月"(String型。項目ID:mon)
        else if(key.equals("月")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.valueOf(mon_list.size());
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= mon_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            } 
            return ((X33VDataTypeStringBean)mon_list.get(tmpIndex)).loadModelData(subkey);
        }
 
        // 配列項目 "日"(String型。項目ID:day)
        else if(key.equals("日")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.valueOf(day_list.size());
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= day_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            } 
            return ((X33VDataTypeStringBean)day_list.get(tmpIndex)).loadModelData(subkey);
        }
 
        // 条件に合致するプロパティが存在しない場合は、nullを返す。
        return null;
    }
 
    /**
     * 項目名とサブキーからデータを設定します（X31CBaseBeanの同名メソッドの実装）
     *
     * @param gamenId 画面ID(予備)
     * @param key 項目名
     * @param subkey サブキー
     * @param in_value データ
     */
    public void storeModelData(String gamenId, String key, String subkey, Object in_value) {
         storeModelData(key, subkey, in_value);
    }
 
	 /**
     * 項目名とサブキーからデータを取得します
     *
     * @param key 項目名
     * @param subkey サブキー
     * @param in_value データ
     */
    public void storeModelData(String key, String subkey, Object in_value) {
         storeModelData(key, subkey, in_value, false);
    }
 
    /**
     * 項目名とサブキーからデータを取得します
     *
     * @param key 項目名
     * @param subkey サブキー
     * @param in_value データ
     * @param isSetAsString Long型項目ValueプロパティへString型値の設定を行う場合true
     */
    public void storeModelData(String key, String subkey, Object in_value, boolean isSetAsString) { 
 
        // key,subkeyがnullの場合、処理を中止
        if(key == null || subkey == null){
            return;
        }
 
        int separaterPoint = key.indexOf("/");
 
        // 項目ごとに処理を入れる。
        //データタイプがStringの項目"選択年月日"(項目ＩＤ:ymd)
        if(key.equals("選択年月日")){
            if(subkey.equalsIgnoreCase("value")){
                setYmd_value((String)in_value);
            }
            else if(subkey.equalsIgnoreCase("enable")){ //subkeyが"enable"の場合、ymd_enabledのsetterを実行する。
                setYmd_enabled((Boolean)in_value); 
            }
            else if(subkey.equalsIgnoreCase("state")){ //subkeyが"state"の場合、ステータスを返す。
                setYmd_state((String)in_value);
            }
        }  
 
        // 配列項目 "年"(String型。項目ID:year)
        else if(key.equals("年")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);//("year/0"から最初の"/"より後を取得)。
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                tmpIndexInt = null;
            }
            if(tmpIndexInt != null) { // インデックス値が数値文字列の場合
                int tmpIndex = tmpIndexInt.intValue();
                if(tmpIndex >= 0 && tmpIndex < year_list.size()) { // インデックス値がリスト個数-1以下の場合
                    ((X33VDataTypeStringBean)year_list.get(tmpIndex)).storeModelData(subkey,in_value);
					//キャスト部分は、項目定義型にあわせてX33VDataTypeStringBean, X33VDataTypeLongBean, X33VDataTypeBooleanBeanのうち1つを指定。
					//X33VDataTypeLongBeanではsubkeyと入力値およびisSetAsStringフラグを引数に指定
                }
            }
        }
 
        // 配列項目 "月"(String型。項目ID:mon)
        else if(key.equals("月")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);//("mon/0"から最初の"/"より後を取得)。
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                tmpIndexInt = null;
            }
            if(tmpIndexInt != null) { // インデックス値が数値文字列の場合
                int tmpIndex = tmpIndexInt.intValue();
                if(tmpIndex >= 0 && tmpIndex < mon_list.size()) { // インデックス値がリスト個数-1以下の場合
                    ((X33VDataTypeStringBean)mon_list.get(tmpIndex)).storeModelData(subkey,in_value);
					//キャスト部分は、項目定義型にあわせてX33VDataTypeStringBean, X33VDataTypeLongBean, X33VDataTypeBooleanBeanのうち1つを指定。
					//X33VDataTypeLongBeanではsubkeyと入力値およびisSetAsStringフラグを引数に指定
                }
            }
        }
 
        // 配列項目 "日"(String型。項目ID:day)
        else if(key.equals("日")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1);//("day/0"から最初の"/"より後を取得)。
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                tmpIndexInt = null;
            }
            if(tmpIndexInt != null) { // インデックス値が数値文字列の場合
                int tmpIndex = tmpIndexInt.intValue();
                if(tmpIndex >= 0 && tmpIndex < day_list.size()) { // インデックス値がリスト個数-1以下の場合
                    ((X33VDataTypeStringBean)day_list.get(tmpIndex)).storeModelData(subkey,in_value);
					//キャスト部分は、項目定義型にあわせてX33VDataTypeStringBean, X33VDataTypeLongBean, X33VDataTypeBooleanBeanのうち1つを指定。
					//X33VDataTypeLongBeanではsubkeyと入力値およびisSetAsStringフラグを引数に指定
                }
            }
        }
 
    }
 
    /**
      * データタイプビーンの項目名のリストを返す。
      * @return ArrayList 項目名のリスト
      */
    public static ArrayList<String> listKoumokuIds() {
        ArrayList<String> koumokuList = new ArrayList<String>();
        koumokuList.add("選択年月日") ;
        koumokuList.add("年") ;
        koumokuList.add("月") ;
        koumokuList.add("日") ;
        return koumokuList;
    }
 
    /**
     * 項目名とサブキーからデータの型情報を取得します
     *
     * @param key 項目名
     * @param subkey サブキー
     * @return Class データの型情報
     */
    public Class<?> typeModelData(String key, String subkey) {
 
        // key,subkeyがnullの場合、nullを返す
        if(key == null || subkey == null){
            return null;
        }
        
        int separaterPoint = key.indexOf("/");
        
        //項目ごとに処理を入れる。
        //データタイプがStringの項目"選択年月日"(項目ＩＤ:ymd)
        if(key.equals("選択年月日")){
            if(subkey.equalsIgnoreCase("value")){
                return String.class;
            }
            else if(subkey.equalsIgnoreCase("enable")){
                return Boolean.class;
            }
            else if(subkey.equalsIgnoreCase("state")){ //subkeyが"state"の場合、ステータスを返す。
                return String.class;
            }
        }
 
        // 配列項目 "年"(String型。項目ID:year)
        else if(key.equals("年")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1); //("年/0"から最初の"/"より後を取得)。
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.class;
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= year_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            }
            return ((X33VDataTypeStringBean)year_list.get(tmpIndex)).typeModelData(subkey);
        }
 
        // 配列項目 "月"(String型。項目ID:mon)
        else if(key.equals("月")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1); //("月/0"から最初の"/"より後を取得)。
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.class;
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= mon_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            }
            return ((X33VDataTypeStringBean)mon_list.get(tmpIndex)).typeModelData(subkey);
        }
 
        // 配列項目 "日"(String型。項目ID:day)
        else if(key.equals("日")) {
            // keyの次の要素を取得
            key = key.substring(separaterPoint + 1); //("日/0"から最初の"/"より後を取得)。
            // インデックス値の代わりに"*"が指定されていたら、リストの要素数を返す。
            if(key.equals("*")) {
                return Integer.class;
            }
            // 次はリスト中のインデックスを見る
            Integer tmpIndexInt = null;
            try{
                tmpIndexInt = Integer.valueOf(key);
            }
            // インデックス値が数値文字列でない場合は、ここでnullを返す。
            catch(NumberFormatException e){
                return null;
            }
            if(tmpIndexInt == null) {
                return null;
            }
            int tmpIndex = tmpIndexInt.intValue();
            if(tmpIndex < 0 || tmpIndex >= day_list.size()) { // インデックス値がリスト個数-1を超える場合、ここでnullを返す。
                return null;
            }
            return ((X33VDataTypeStringBean)day_list.get(tmpIndex)).typeModelData(subkey);
        }
 
        // 条件に合致するプロパティが存在しない場合は、nullを返す。
        return null;
    }
    
    /**
     * リスト項目のインスタンスを生成します。
     * @param key 項目名
     * @return int 追加された要素のインデックス番号
     */
    public int addListDataInstance (String key) throws X33SException{
 
        // nullの場合、-1で返す。
        if(key == null){
            return -1;
        }
 
        //各繰り返し項目の固定要素数指定への処理を行う。
        // 配列項目 "年"(String型。項目ID:year)
        else if( key.equals("年") ) {
            if( year_list == null ) { // リストがnullの場合、新しい空のインスタンスを生成する
                year_list = new X33VDataTypeList();
            }
            X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();// データタイプビーン型で指定したデータタイプビーンのインスタンスを生成する。
                                                                          // なお、データタイプビーンの項目初期値設定は、各データビーン内部で定義
            year_list.add(tmpBean);
            return year_list.size() -1;
        }
 
        // 配列項目 "月"(String型。項目ID:mon)
        else if( key.equals("月") ) {
            if( mon_list == null ) { // リストがnullの場合、新しい空のインスタンスを生成する
                mon_list = new X33VDataTypeList();
            }
            X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();// データタイプビーン型で指定したデータタイプビーンのインスタンスを生成する。
                                                                          // なお、データタイプビーンの項目初期値設定は、各データビーン内部で定義
            mon_list.add(tmpBean);
            return mon_list.size() -1;
        }
 
        // 配列項目 "日"(String型。項目ID:day)
        else if( key.equals("日") ) {
            if( day_list == null ) { // リストがnullの場合、新しい空のインスタンスを生成する
                day_list = new X33VDataTypeList();
            }
            X33VDataTypeStringBean tmpBean = new X33VDataTypeStringBean();// データタイプビーン型で指定したデータタイプビーンのインスタンスを生成する。
                                                                          // なお、データタイプビーンの項目初期値設定は、各データビーン内部で定義
            day_list.add(tmpBean);
            return day_list.size() -1;
        }
 
        return -1; //該当する項目がない場合、-1を返す
	}
 
    /**
     * リスト項目のインスタンスを削除します。
     * @param key 項目名
     * @param index 削除対象のインデックス番号
     */
    public void removeElementFromListData (String key, int index) throws X33SException{
 
        if(key != null){
 
            // 配列項目 "年"(String型。項目ID:year)
            if(key.equals("年")) {
                if(index >= 0 && index < year_list.size()) { // 指定のインデックスが現在のリストの範囲内なら、そのインデックスの内容を削除する
                    year_list.remove(index);
                }
            }
 
            // 配列項目 "月"(String型。項目ID:mon)
            else if(key.equals("月")) {
                if(index >= 0 && index < mon_list.size()) { // 指定のインデックスが現在のリストの範囲内なら、そのインデックスの内容を削除する
                    mon_list.remove(index);
                }
            }
 
            // 配列項目 "日"(String型。項目ID:day)
            else if(key.equals("日")) {
                if(index >= 0 && index < day_list.size()) { // 指定のインデックスが現在のリストの範囲内なら、そのインデックスの内容を削除する
                    day_list.remove(index);
                }
            }
 
        }
    }
    /**
     * リスト項目の要素をクリアします。
     * @param key 項目名
     */
    public void clearListDataInstance (String key) throws X33SException{
 
        if(key !=null){
 
            // 配列項目 "年"(String型。項目ID:year)
            if(key.equals("年")) {
                year_list.clear();
            }
            // 配列項目 "月"(String型。項目ID:mon)
            else if(key.equals("月")) {
                mon_list.clear();
            }
            // 配列項目 "日"(String型。項目ID:day)
            else if(key.equals("日")) {
                day_list.clear();
            }
        }
    }
 
}
