package cn.hme.framework.helper.excel;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.gson.internal.LinkedTreeMap;

public class ExcelRowReader {

	Map<String, List<List<String>>> valuesMap;
	private int columnCount = 0;

	public ExcelRowReader() {
		valuesMap = new LinkedTreeMap<String, List<List<String>>>();
	}

	public Map<String, List<List<String>>> getValuesMap() {
		return valuesMap;
	}

	/*
	 * 业务逻辑实现方法
	 * 
	 * @see com.eprosun.util.excel.IRowReader#getRows(int, int, java.util.List)
	 */
	public void getRows(int row_num, String sheet_name, List<String> row_list) {
		List<String> list = new ArrayList<String>();
		if (row_num == 0) {
			// 第一行，获取表结构
			columnCount = row_list.size();
		}
		for (String v : row_list)
			list.add(v);
		for (int k = 0; k < columnCount - row_list.size(); k++)
			list.add(null);
		valuesMap.get(sheet_name).add(list);

	}

	public List<List<String>> getValues() {
		if (valuesMap.keySet().size() > 0)
			return valuesMap.values().iterator().next();
		return null;
	}

	public List<List<String>> getValues(String sheet_name) {
		if (valuesMap.containsKey(sheet_name))
			return valuesMap.get(sheet_name);
		return null;
	}

}
