/*
 * MosP - Mind Open Source Project         http://www.mosp.jp/
 * Copyright (C) 1987-2009 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.common;

public class ExportInfoUtility {

	/**
	 * 恖帠忣曬庢摼梡攝楍
	 */
	protected String[] aryKihonItem;

	/**
	 * 嬑懹忣曬崁栚梡攝楍
	 */
	protected String[] aryKintaiItem;

	/**
	 * 弌嬑曤忣曬崁栚梡攝楍
	 */
	protected String[] arySyukkinItem;

	/**
	 * 桳媼媥壣忣曬崁栚梡攝楍
	 */
	protected String[] aryYukyuItem;

	/**
	 * 僄僋僗億乕僩忣曬崁栚愝掕
	 * @param strFLID			懳徾僥乕僽儖僐乕僪
	 * @param aryKihonItem		恖帠忣曬庢摼梡攝楍
	 * @param aryKintaiItem		嬑懹忣曬崁栚梡攝楍
	 * @param arySyukkinItem	弌嬑曤忣曬崁栚梡攝楍
	 * @param aryYukyuItem		桳媼媥壣忣曬崁栚梡攝楍
	 * @return	String[][]		僄僋僗億乕僩忣曬崁栚攝楍
	 */
	public static String[][] getColumnDataItem(
			String strFLID,
			String[] aryKihonItem,
			String[] aryKintaiItem,
			String[] arySyukkinItem,
			String[] aryYukyuItem
	) {
		int ItemLength = aryKihonItem.length;
		if (strFLID.equals(CommonConst.CODE_TABLE_M_KINTAI)) {
			ItemLength += aryKintaiItem.length;
		}
		if (strFLID.equals(CommonConst.CODE_TABLE_M_SYUKKINBO)) {
			ItemLength += arySyukkinItem.length;
		}
		if (strFLID.equals(CommonConst.CODE_TABLE_M_YUKYU)) {
			ItemLength += aryYukyuItem.length;
		}
		int i = 0;
		String[][] aryItem = new String[ItemLength][2];
		// 恖帠忣曬庢摼梡攝楍
		for (i = 0; i < aryKihonItem.length; i++) {
			aryItem[i][0] = aryKihonItem[i];
			aryItem[i][1] = getSplitInfo(aryKihonItem[i], 3);
		}
		// 嬑懹忣曬崁栚梡攝楍
		int j = i;
		if (strFLID.equals(CommonConst.CODE_TABLE_M_KINTAI)) {
			for (i = 0; i < aryKintaiItem.length; i++) {
				aryItem[j+i][0] = aryKintaiItem[i];
				aryItem[j+i][1] = getSplitInfo(aryKintaiItem[i], 3);
			}
		}
		// 弌嬑曤忣曬崁栚梡攝楍
		if (strFLID.equals(CommonConst.CODE_TABLE_M_SYUKKINBO)) {
			for (i = 0; i < arySyukkinItem.length; i++) {
				aryItem[j+i][0] = arySyukkinItem[i];
				aryItem[j+i][1] = getSplitInfo(arySyukkinItem[i], 3);
			}
		}
		// 桳媼媥壣忣曬崁栚梡攝楍
		if (strFLID.equals(CommonConst.CODE_TABLE_M_YUKYU)) {
			for (i = 0; i < aryYukyuItem.length; i++) {
				aryItem[j+i][0] = aryYukyuItem[i];
				aryItem[j+i][1] = getSplitInfo(aryYukyuItem[i], 3);
			}
		}
		return aryItem;
	}

	/**
	 * 僼傿乕儖僪柤徧撪偺僨乕僞暘夝庢摼
	 *  0 : 僼傽僀儖ID
	 *  1 : 娗棟斣崋
	 *  2 : 僼傿乕儖僪ID
	 *  3 : 僼傿乕儖僪柤徧
	 */
	protected static String getSplitInfo(String str, int i) {
		//丂娗棟斣崋庢摼
		if  (str.length()!= 0)  {
			String[] array;
			array = str.split(CommonConst.STR_CSV_SEPARATOR);
			return array[i];
		}
		return "";
	}

}
