/*
 * MosP - Mind Open Source Project    http://www.mosp.jp/
 * Copyright (C) MIND Co., Ltd.       http://www.e-mind.co.jp/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package jp.mosp.kintai.system.vo;

import java.util.Iterator;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import jp.mosp.common.CommonConst;
import jp.mosp.common.MosPVo;
import jp.mosp.kintai.common.dto.MKaisyaDto;

/**
 * @author yoshida
 *
 */
public class KaisyaMasterListVo extends MosPVo {
	
	private static final long	serialVersionUID	= -912308350054852945L;
	
	// 定数
	/**
	 * 
	 */
	public static final int		SEARCH_OFF			= 0;
	/**
	 * 
	 */
	public static final int		SEARCH_ON			= 1;
	
	// パラメータ名
	/**
	 * 
	 */
	public static final String	PRM_TXT_JCODE		= "txtJCode";
	/**
	 * 
	 */
	public static final String	PRM_TXT_KAIMEI		= "txtKaiMei";
	
	// フィールド
	private String[]			aryJCode;
	private String[]			aryKaimei;
	private String				txtJCode;
	private String				txtKaiMei;
	
	// フィールド名及び制限
	/**
	 * 
	 */
	public String				NAM_JCODE;
	/**
	 * 
	 */
	public String				NAM_KAIMEI;
	/**
	 * 
	 */
	public int					LEN_JCODE;
	/**
	 * 
	 */
	public int					LEN_KAIMEI;
	
	// ソートキー
	/**
	 * 
	 */
	public final String			KEY_JCODE			= "keyJCode";
	/**
	 * 
	 */
	public final String			KEY_KAIMEI			= "keyKaimei";
	
	// モード(0：検索なし、1：検索あり)
	private int					searchmode;
	

	/**
	 * コンストラクタ
	 */
	public KaisyaMasterListVo() {
		super();
		setViewPath(getClassName());
		aryJCode = new String[0];
		aryKaimei = new String[0];
		txtJCode = "";
		txtKaiMei = "";
		setFormerKey(KEY_JCODE);
	}
	
	@Override
	protected void setSubTitle() {
		subTitle = CommonConst.TTL_COMPANY_MASTER;
		aryMenu = new String[][]{ { CMD_MENU_SYSTEM2, CommonConst.NAM_TO_MENU } };
	}
	
	@Override
	protected void setFieldsName() {
		NAM_JCODE = CommonConst.NAM_OFFICE + CommonConst.NAM_COMMON_CODE;
		NAM_KAIMEI = CommonConst.NAM_COMMON_MEISYO;
		LEN_JCODE = 10;
		LEN_KAIMEI = 50;
	}
	
	@Override
	public void setParams(HttpServletRequest request) {
		txtJCode = request.getParameter(PRM_TXT_JCODE);
		txtKaiMei = request.getParameter(PRM_TXT_KAIMEI);
	}
	
	@Override
	public void setFields(List<?> listJigyousyo) {
		// リストの設定
		list = listJigyousyo;
		// データ総数の取得
		count = listJigyousyo.size();
		// 配列の初期化
		aryJCode = new String[count];
		aryKaimei = new String[count];
		// データの設定
		int i = 0;
		Iterator<?> it = listJigyousyo.iterator();
		while (it.hasNext()) {
			MKaisyaDto dto = (MKaisyaDto)it.next();
			aryJCode[i] = escapeHTML(dto.getId());
			aryKaimei[i] = escapeHTML(dto.getKaiMei());
			i++;
		}
	}
	
	/**
	 * @return aryJCode
	 */
	public String[] getAryJCode() {
		return aryJCode.clone();
	}
	
	/**
	 * @return aryKaimei
	 */
	public String[] getAryKaimei() {
		return aryKaimei.clone();
	}
	
	/**
	 * @return txtJCode
	 */
	public String getTxtJCode() {
		return txtJCode;
	}
	
	/**
	 * @return txtKaiMei
	 */
	public String getTxtKaiMei() {
		return txtKaiMei;
	}
	
	/**
	 * @return searchmode
	 */
	public int getSearchmode() {
		return searchmode;
	}
	
	/**
	 * @param aryJCode セットする aryJCode
	 */
	public void setAryJCode(String[] aryJCode) {
		this.aryJCode = aryJCode.clone();
	}
	
	/**
	 * @param aryKaimei セットする aryKaimei
	 */
	public void setAryKaimei(String[] aryKaimei) {
		this.aryKaimei = aryKaimei.clone();
	}
	
	/**
	 * @param txtJCode セットする txtJCode
	 */
	public void setTxtJCode(String txtJCode) {
		this.txtJCode = txtJCode;
	}
	
	/**
	 * @param txtKaiMei セットする txtKaiMei
	 */
	public void setTxtKaiMei(String txtKaiMei) {
		this.txtKaiMei = txtKaiMei;
	}
	
	/**
	 * @param searchmode セットする searchmode
	 */
	public void setSearchmode(int searchmode) {
		this.searchmode = searchmode;
	}
	
}
