/**
 * @(#)file    SheetData.java
 * @(#)author  [개발자명]
 * @(#)version 1.0
 * @(#)date    May 10, 2007
 * @(#)since   JDK 1.4.2
 *
 * Copyright (c) www.hwenc.co.kr, Inc.
 * All rights reserved.
 * This software is the proprietary information of Hanwha E&C, Inc.
 */
package kr.co.udapsoft.common.sheet;

import java.util.Hashtable;

import kr.co.hsnc.common.sql.RowSet;
import kr.co.hsnc.common.util.ValueObject;

public class SheetData {

	private ValueObject attr = null;
	
	private Hashtable rowsets = null;
	
	private int rowsets_size = -100;
	
	public SheetTR sheetTR = null;

	public SheetData() {
		this.attr = new ValueObject();
		this.rowsets = new Hashtable();
	}

	/**
	 * 속성 세팅
	 * @param key
	 * @param value
	 */
	public void setAttribute(String key, String value) {
		this.attr.set(key, value);
	}

	/**
	 * 속성 리턴
	 * @param key
	 * @return
	 */
	public String getAttribute(String key) {
		return this.attr.get(key);
	}

	/**
	 * 속성 전체 리턴
	 * @return
	 */
	public ValueObject getAttributes() {
		return this.attr;
	}
	
	/**
	 * RowSet의 Size를 리
	 * @return
	 */
	public int getRowSetSize() {
		return this.rowsets_size;
	}
	
	/**
	 * RowSet을 세팅
	 * 2개 이상의 RowSet을 세팅할때 RowSet.size()가 서로 같아야 한다. 
	 * @param rowSetKey
	 * @param rowSet
	 */
	public void setRowSet(String rowSetKey, RowSet rowSet) throws Exception {
		this.rowsets.put(rowSetKey, rowSet);
		if( this.rowsets_size == -100 ) {
			this.rowsets_size = rowSet.size();
		}
		else {
			if( this.rowsets_size  != rowSet.size() ) {
				throw new Exception("기존에 세팅된 RowSet의 Size와 현재 입력하려는 RowSet의 Size가 다릅니다.");
			}
		}
	}

	/**
	 * @param rowSetKey
	 * @return
	 */
	public RowSet getRowSet(String rowSetKey) {
		return (RowSet)this.rowsets.get(rowSetKey);
	}

	/**
	 * 세팅된 RowSet의 숫자를 리턴
	 * @return
	 */
	public int getRowSetCount() {
		return this.rowsets.size();
	}
}
