package com.eactive.eai.rms.onl.tracking.vo;

import java.util.HashMap;
import java.util.List;

public class TransformLayoutVo {
	HashMap<String, String> vo = new HashMap<String, String>();
	
	private String fieldType;
	private String id;
	private String desc;
	private String type;
	private String len;
	private String scale;
	private String count;
	
	private String text;
	private String level;
	
	public static final String LAYOUT_FIELD_TYPE = "fieldType";
	public static final String LAYOUT_ID         = "id";
	public static final String LAYOUT_DESC       = "desc";
	public static final String LAYOUT_TYPE       = "type";
	public static final String LAYOUT_LEN        = "len";
	public static final String LAYOUT_SCALE      = "scale";
	public static final String LAYOUT_COUNT      = "count";

	public String getFieldType() {
		return fieldType;
	}
	public void setFieldType(String fieldType) {
		this.fieldType = fieldType;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public String getLen() {
		return len;
	}
	public void setLen(String len) {
		this.len = len;
	}
	public String getScale() {
		return scale;
	}
	public void setScale(String scale) {
		this.scale = scale;
	}
	public String getCount() {
		return count;
	}
	public void setCount(String count) {
		this.count = count;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	public String getLevel() {
		return level;
	}
	public void setLevel(String level) {
		this.level = level;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer();
		
		sb.append("[TransformLayoutVo] ");
		sb.append(LAYOUT_FIELD_TYPE).append("=[").append(fieldType).append("], ");
		sb.append(LAYOUT_ID).append("=[").append(id).append("], ");
		sb.append(LAYOUT_DESC).append("=[").append(desc).append("], ");
		sb.append(LAYOUT_TYPE).append("=[").append(type).append("], ");
		sb.append(LAYOUT_LEN).append("=[").append(len).append("], ");
		sb.append(LAYOUT_SCALE).append("=[").append(scale).append("], ");
		sb.append(LAYOUT_COUNT).append("=[").append(count).append("], ");
		
		return sb.toString();
	}
	
	public String toXML(List<TransformLayoutVo> list) {
		StringBuffer sb = new StringBuffer();
		
		//int grid_cnt = 0;
		for(TransformLayoutVo vo : list) {
			sb.append("<").append(fieldType).append(" ")
			  .append( LAYOUT_ID    ).append("=\"").append( id    ).append("\" ")
			  .append( LAYOUT_DESC  ).append("=\"").append( desc  ).append("\" ")
			  .append( LAYOUT_TYPE  ).append("=\"").append( type  ).append("\" ")
			  .append( LAYOUT_LEN   ).append("=\"").append( len   ).append("\" ")
			  .append( LAYOUT_SCALE ).append("=\"").append( scale ).append("\" ")
			  .append( LAYOUT_COUNT ).append("=\"").append( count ).append("\" ");
			  
			if("Format".equals(vo.getFieldType())) {
			  sb.append(">");
			} else if("Fld".equals(vo.getFieldType()) || "Column".equals(vo.getFieldType()) ) {
			  sb.append("/>");
			}
		}
		return null;
	}
}
