/*************************************************************************************************
 * 프로그램명 : MDocPreview.java 프로그램설명 : 집계문서 입력 양식 미리보기 작성자 : 강원중 작성일 : 2003.12.03 변경일 : 2004.09.16
 **************************************************************************************************/

package kr.co.kihyun.moumi.doc;

import java.util.*;
import kr.co.kihyun.beans.tosys.etc1.TotsysEtc;
import kr.co.kihyun.lang.MInteger;
import kr.co.kihyun.moumi.doc.table.InsertMTable;
import kr.co.kihyun.moumi.doc.table.item.MItem;

public class MDocPreview extends InsertMTable {

	public void convert(String form, String itemName, String itemSize, String itemExpr, String itemType,
			String itemDesc, String defItemSize) throws NumberFormatException {
		convert(form, itemName, itemSize, itemExpr, itemType, itemDesc, defItemSize);
	}

	public void convert(String form, String itemName, String itemSize, String itemExpr, String itemType,
			String itemDesc, int defItemSize) {

		StringTokenizer stkItemName = new StringTokenizer(itemName, (MItem.LIST_DELIM));
		StringTokenizer stkItemSize = new StringTokenizer(itemSize, (MItem.LIST_DELIM));
		StringTokenizer stkItemExpr = new StringTokenizer(itemExpr, (MItem.LIST_DELIM));
		StringTokenizer stkItemType = new StringTokenizer(itemType, (MItem.LIST_DELIM));
		StringTokenizer stkItemDesc = new StringTokenizer(itemDesc, (MItem.LIST_DELIM));

		int itemCount = stkItemName.countTokens();

		int[] itemNumList = new int[itemCount];
		String[] itemNameList = new String[itemCount];
		int[] itemSizeList = new int[itemCount];
		String[] itemExprList = new String[itemCount];
		int[] itemTypeList = new int[itemCount];
		String[] itemDescList = new String[itemCount];

		String tmp = null;
int itemCount2 = stkItemDesc.countTokens();




String[] tmpArr=TotsysEtc.getDeliToArr(itemDesc,"!@!");


		for (int i = 0; i < itemCount; i++) {
			//tmp = stkItemDesc.nextToken();
            tmp=tmpArr[i];

			itemDescList[i] = tmp.substring(tmp.indexOf(":") + 1, tmp.length()).trim();
			itemNumList[i] = Integer.parseInt(tmp.substring(0, tmp.indexOf(":")).trim());
			tmp = stkItemName.nextToken();
			itemNameList[i] = tmp.substring(tmp.indexOf(":") + 1, tmp.length()).trim();
			tmp = stkItemExpr.nextToken();
			itemExprList[i] = tmp.substring(tmp.indexOf(":") + 1, tmp.length()).trim();
			tmp = stkItemType.nextToken();
			itemTypeList[i] = MItem.getTypeNum(tmp.substring(tmp.indexOf(":") + 1, tmp.length()).trim());
			tmp = stkItemSize.nextToken();
			itemSizeList[i] = MInteger.parseInt(tmp.substring(tmp.indexOf(":") + 1, tmp.length()).trim());
            
		}

		convert(form, itemNumList, itemNameList, itemSizeList, itemExprList, itemTypeList, itemDescList, defItemSize);
	}
}
