/**
 * WAS에서 전달받는 XML용 Result Object result.xml 참조
 * 
 * getType() : success|select|valueobject|rowset|xml
 */
function Result(p_type, p_requestUri, p_requestEvent) {

	this.type = p_type;
	this.getType = function() {
		return this.type;
	};
	this.setType = function(p_type) {
		this.type = p_type;
	};

	this.requestUri = p_requestUri;
	this.getRequestUri = function() {
		return this.requestUri;
	};
	this.setRequestUri = function(p_requestUri) {
		this.requestUri = p_requestUri;
	};

	this.requestEvent = p_requestEvent;
	this.getRequestEvent = function() {
		return this.requestEvent;
	};
	this.setRequestEvent = function(p_requestEvent) {
		this.requestEvent = p_requestEvent;
	};

	this.requestParameter = "";
	this.getRequestParameter = function() {
		return this.requestParameter;
	};
	this.setRequestParameter = function(p_requestParameter) {
		this.requestParameter = p_requestParameter;
	};

	this.success = false;
	this.getSuccess = function() {
		return this.success;
	};
	this.setSuccess = function(p_success) {
		this.success = p_success;
	};

	this.message = "";
	this.getMessage = function() {
		return this.message;
	};
	this.setMessage = function(p_message) {
		this.message = p_message;
	};

	this.detailMessage = "";
	this.getDetailMessage = function() {
		return this.detailMessage;
	};
	this.setDetailMessage = function(p_detailMessage) {
		this.detailMessage = p_detailMessage;
	};

	this.select_vo = null;
	this.getSelect = function() {
		return this.select_vo;
	};
	this.setSelect = function(p_select_vo) {
		this.select_vo = p_select_vo;
	};
	
	this.vo = null;
	this.getValueObject = function() {
		return this.vo;
	};
	this.setValueObject = function(p_vo) {
		this.vo = p_vo;
	};

	this.rowset = null;
	this.getRowSet = function() {
		return this.rowset;
	};
	this.setRowSet = function(p_rowset) {
		this.rowset = p_rowset;
	};

	this.xml = "";
	this.getXml = function() {
		return this.xml;
	};
	this.setXml = function(p_xml) {
		this.xml = p_xml;
	};

	this.toString = function() {
		var msg = "Result Object : \n\n" + "type=" + this.type + "\n"
				+ "requestUri=" + this.requestUri + "\n" + "requestEvent="
				+ this.requestEvent + "\n" + "success=" + this.success + "\n"
				+ "message=" + this.message + "\n" + "requestParameter="
				+ this.requestParameter + "\n";
		if (this.type == "xml") {
			msg += +"xml=" + this.xml + "\n";
		}
		return msg;
	};
}

function ValueObject() {

	this.keyArray = new Array();
	this.valueArray = new Array();

	this.getSize = function() {
		return this.keyArray.length;
	};

	this.getKeyArray = function() {
		return this.keyArray;
	};
	this.getValueArray = function() {
		return this.valueArray;
	};

	this.set = function(p_key, p_value) {
		this.keyArray[this.keyArray.length] = p_key;
		this.valueArray[this.valueArray.length] = p_value;
	};

	this.getValue = function(p_index) {
		return this.valueArray[p_index];
	};

	this.getKey = function(p_index) {
		return this.keyArray[p_index];
	};

	this.get = function(p_key) {
		for (var i = 0; i < this.getSize(); i++) {
			if (this.getKey(i).toLowerCase() == p_key.toLowerCase()) {
				return this.getValue(i);
			}
		}
		return "";
	};
}

function RowSet() {

	this.rowArray = new Array();

	this.getRowSize = function() {
		return this.rowArray.length;
	}

	this.getColSize = function() {
		if (this.rowArray.length == 0)
			return 0;
		else
			return this.rowArray[0].getSize();
	}

	this.setRow = function(p_row) {
		this.rowArray[this.rowArray.length] = p_row;
	}

	this.getRow = function(p_rowIndex) {
		return this.rowArray[p_rowIndex];
	}

	this.getColName = function(p_col_index) {
		if (this.rowArray.length == 0)
			return null;
		else
			return this.rowArray[0].getName(p_col_index);
	}

	this.getColValue = function(p_row_index, p_col_index) {
		if (this.rowArray.length == 0)
			return "";
		else {
			if (p_row_index < this.getRowSize())
				return this.rowArray[p_row_index].getValue(p_col_index);
			else
				return null;
		}
	}
}

function Row() {

	this.nameArray = new Array();
	this.valueArray = new Array();

	this.getSize = function() {
		return this.nameArray.length;
	};

	this.getNameArray = function() {
		return this.nameArray;
	};
	this.getValueArray = function() {
		return this.valueArray;
	};

	this.set = function(p_name, p_value) {
		this.nameArray[this.nameArray.length] = p_name;
		this.valueArray[this.valueArray.length] = p_value;
	};

	this.getValue = function(p_index) {
		return this.valueArray[p_index];
	};

	this.getName = function(p_index) {
		return this.nameArray[p_index];
	};

	this.get = function(p_name) {
		for (var i = 0; i < this.getSize(); i++) {
			if (this.getName(i) == p_name) {
				return this.getValue(i);
			}
		}
		return null;
	};

	this.toString = function() {
		var msg = "Row Object : \n\n";
		for (var i = 0; i < this.getSize(); i++) {
			msg += i + " : " + this.getName(i) + "=" + this.getValue(i) + "\n";
		}
		return msg;
	};
}