
/// <class name="cParameterObject">
///	<summary>This class provides user to set some properties and methods through which user can set multiple value to single keu\y and can perform different operations on it.</summary>
/// </class>
function cParameterObject()
{
		
		// ///////////////////////////////////////// 
		// PROPERTIES for cParameterObject class.
		///&& oArrColumns: to give column name to the values.
		this.oArrColumns=oJSFW.fnObjectInitializer('Array',"",[]);
		///&& strSortOrder: to give facility of selecting order of sorting default it will be "Ascending".
		this.blnArrIsAscending=oJSFW.fnObjectInitializer('Array',"",["true","false"]);
		// //////////////////////////////////
		// METHODS cParameterObject class.

		//To add key and it's value specified.
		this.fnAdd=cParameterObject_fnAdd;
		//To Remove Particular key 
		this.fnRemove=cParameterObject_fnRemove;
		//To Remove all the keys
		this.fnClear=cParameterObject_fnClear;
		//To get length of the specified key
		this.fnGetLength=cParameterObject_fnGetLength;
		//Returns all the keys
		this.fnGetAllKeys=cParameterObject_fnGetAllKeys;
		//Returns all the values of the given key
		this.fnGetValuesOfKey=cParameterObject_fnGetValuesOfKey;
		//Returns true whether the given key is exist and false when the given key is not exists
		this.fnIsExists=cParameterObject_fnIsExists;
		//Returns the position of given key
		this.fnGetPositionOfKey= cParameterObject_fnGetPositionOfKey;
		//To sort the values according to given column name
		this.fnSingleSort=cParameterObject_fnSingleSort;
		//To get the value of column from the keys
		this.fnGetValue=cParameterObject_fnGetValue;
		//To set the value of column from the keys
		this.fnSetValue=cParameterObject_fnSetValue;
		
		// ///////////////////////////////////////// 
		// Variables for cParameterObject.
		// ////////////////////////////////////////
		///--Array of keys
		var oArrKey=oJSFW.fnObjectInitializer('Array',"",[]);
		///--Values of keys
		var oArrValueOfKey=oJSFW.fnObjectInitializer('Array',"",[]);
		///--Number of keys
		var nKeyValues;
		///--Array Of Column names
		var oArrColumns=oJSFW.fnObjectInitializer('Array',"",[]);
		///--Array for Sort order
		var blnArrIsAscending=oJSFW.fnObjectInitializer('Array',"",[]);
		/// <memberMethod name="fnAdd">
		///	<param name="strKey">This parameter contains the key </param>
		///	<param name="oArrValue">This parameter contains the array of values for key specified</param>
		/// <summary>function to Add key and array of values of that keys.</summary>
		/// </memberMethod>
		function cParameterObject_fnAdd(strKey,oArrValue)
		{
				
				var blnKeyExistFlag=true;
				try
				{
					if(strKey=="")
					{
						oJSFW.fnThrowACTLError('Not a Valid Key' + strKey + ' !');
					}	
					///--Check whether key is duplicated or not
					var nIndex=oArrKey.fnIndexOf(strKey);
					
					///--To check whether the key is already  exist or not
					if(nIndex > -1)
					{
						blnKeyExistFlag=false;
					}
					else
					{	
						blnKeyExistFlag=true;
					}
				
					if(blnKeyExistFlag==true)
					{
						///--It will push the given key in to the array of keys
						nKeyValues=oArrKey.push(strKey);
						///--It will push the given values in to the array of Values
						oArrValueOfKey[nKeyValues-1] = oArrValue;
					}
					else
					{
						oJSFW.fnThrowACTLError("Key " + strKey + "  is already Exist!");
						
					}
							
					return nKeyValues;
				}
				catch(ex)
				{
					oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
				}
		}
		/// <memberMethod name="fnGetValue">
		///	<param name="strKey">This parameter contains the key </param>
		///	<param name="strColName">This parameter contains the column name which value user wants to get</param>
		/// <summary>Returns the value of the specified column name of specified key.</summary>
		/// </memberMethod>
		function cParameterObject_fnGetValue(strKey,strColName)
		{
			
			try
			{
				var nKeyPos=oArrKey.fnIndexOf(strKey);
				var nColNamePos=this.oArrColumns.fnIndexOf(strColName);
				///--Check for the position of key
				if(nKeyPos==-1)
				{
					oJSFW.fnThrowACTLError("Key " + strKey + " Not Found!");
				}
				///--Check for the position of column name
				if(nColNamePos==-1)
				{
					oJSFW.fnThrowACTLError("Column Name " + strColName + " Not Found!");
					
				}
				///--Return the value if it is exist
				if(nKeyPos > -1 && nColNamePos > -1)
				{
					return oArrValueOfKey[nKeyPos][nColNamePos];
				}
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
			
		}
		/// <memberMethod name="fnSetValue">
		///	<param name="strKey">This parameter contains the key </param>
		///	<param name="strColName">This parameter contains the column name which value user wants to set</param>
		///	<param name="strValue">This parameter contains the value which value user wants to set</param>
		/// <summary>This function will set the value for given column name of given key and it will replace the previous value to new value.</summary>
		/// </memberMethod>
		function cParameterObject_fnSetValue(strKey,strColName,strValue)
		{
			try
			{
				var nKeyPos=oArrKey.fnIndexOf(strKey);
				var nColNamePos=this.oArrColumns.fnIndexOf(strColName);
				///--Check for the position of key
				if(nKeyPos==-1)
				{
					oJSFW.fnThrowACTLError("Key Not Found!");
				}
				///--Check for the position of column name
				if(nColNamePos==-1)
				{
					oJSFW.fnThrowACTLError("Column Name Not Found!");
					
				}
				if(nKeyPos > -1 && nColNamePos > -1)
				{
					oArrValueOfKey[nKeyPos][nColNamePos]=strValue;
				}
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnSingleSort">
		///	<param name="strColumnName">This parameter contains the column name on which sorting is going to be performed </param>
		///	<param name="strSortOrder">This parameter contains the order in which the the sorting has to be done</param>
		/// <summary>function to sort the kay-values according to the given column name in the given order.</summary>
		/// </memberMethod>
		function cParameterObject_fnSingleSort(strColumnName,strSortOrder)
		{
			try
			{
				var nKeyPos=this.oArrColumns.fnIndexOf(strColumnName);
				if(oArrKey=="")
				{
					oJSFW.fnThrowACTLError("The set of keys is empty");
				}
				if(nKeyPos==-1)
				{
					oJSFW.fnThrowACTLError("Column Name not found");
				}
				///--Assign the array of column name on which the sorting will be performed
				this.oArrColumns=oJSFW.fnObjectInitializer('Array','',[strColumnName]);
				oArrColumns=this.oArrColumns;
				///--It will check the order of the sorting operation
				this.blnArrIsAscending=oJSFW.fnObjectInitializer('Array','',[strSortOrder]);
				blnArrIsAscending=this.blnArrIsAscending;
				if(blnArrIsAscending=="")
				{
					oJSFW.fnThrowACTLError("Sort Order can not be blank!");
				}
				cParameterObject_fnSort();
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <method name="fnSort">
		/// <summary>function to sort the kay-values according to the given column name.</summary>
		/// </method>
		function cParameterObject_fnSort()
		{
			
			try
			{
			///--It will find the position of the column from the given array of columns
				var nPos=0;
				var nOuterCtr;
				var nInnerCtr;
				for(nOuterCtr=0;nOuterCtr<oArrKey.length-1;nOuterCtr++)
					{
						for(nInnerCtr=0;nInnerCtr<oArrKey.length-1;nInnerCtr++)
						{
							///--If the sort ordr is set to desc then it will perform sorting in "Desc" order
							
							if(blnArrIsAscending[0]==false)
							{
								if(oArrValueOfKey[nInnerCtr][nPos] < oArrValueOfKey[nInnerCtr+1][nPos])
								{
									strTemp=oArrValueOfKey[nInnerCtr];
									oArrValueOfKey[nInnerCtr]=oArrValueOfKey[nInnerCtr+1];
									oArrValueOfKey[nInnerCtr+1]=strTemp;
									strTemp=oArrKey[nInnerCtr];
									oArrKey[nInnerCtr]=oArrKey[nInnerCtr+1];
									oArrKey[nInnerCtr+1]=strTemp;
								}
							}
							///--If the sort ordr is set to Asc then it will perform sorting in "Asc" order
							else if(blnArrIsAscending[0]==true)
							{
								if(oArrValueOfKey[nInnerCtr][nPos] > oArrValueOfKey[nInnerCtr+1][nPos])
								{
									strTemp=oArrValueOfKey[nInnerCtr];
									oArrValueOfKey[nInnerCtr]=oArrValueOfKey[nInnerCtr+1];
									oArrValueOfKey[nInnerCtr+1]=strTemp;
									strTemp=oArrKey[nInnerCtr];
									oArrKey[nInnerCtr]=oArrKey[nInnerCtr+1];
									oArrKey[nInnerCtr+1]=strTemp;
								}
							}
						}
					}
				
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}	
		
		}
		
		/// <memberMethod name="fnIsExists">
		///	<param name="strKey">It contains the key</param>
		/// <summary>function to check whether the given key is exist or not.</summary>
		/// </memberMethod>
		function cParameterObject_fnIsExists(strKey)
		{
			var blnKeyExistFlag=false;
			try
			{
				
				if(strKey=="" || strKey==null)
				{
					oJSFW.fnThrowACTLError("Not a Valid Key!");
				}
				else
				{
						///--Check whether the key is exist or not
						var nIndex=oArrKey.fnIndexOf(strKey);
						if(nIndex > -1)
						{
							blnKeyExistFlag=true;
							
						}
						else
						{
							blnKeyExistFlag=false;
						}
					
				}
				return blnKeyExistFlag;
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnRemove">
		///	<param name="strKey">Contains the key going to be remove</param>
		/// <summary>function to Remove the given key from the array of keys.</summary>
		/// </memberMethod>
		function cParameterObject_fnRemove(strKey)
		{
			var blnKeyExistFlag=false;
			try
			{
				if(strKey=="" || strKey==null)
				{
					oJSFW.fnThrowACTLError("Not a Valid Key!");
				}	
				for(nCtr=0;nCtr<oArrKey.length;nCtr++)
				{
					///--For removing the given key from the array of keys
					if(oArrKey[nCtr]==strKey)
					{
						blnKeyExistFlag=true;
						var strRemovedKey=oArrKey.splice(nCtr,1);
						var m=oArrValueOfKey.splice(nCtr,1);
						return nCtr;
					}
					else
					{
						blnKeyExistFlag=false;
					}
					
				}
				if(blnKeyExistFlag==false)
				{
					oJSFW.fnThrowACTLError("Key Not Found!");
				}
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnClear">
		/// <summary>function to Clear all the keys.</summary>
		/// </memberMethod>
		function cParameterObject_fnClear()
		{
			try
			{
				///--It will clear all the values of key 
				oArrKey=oJSFW.fnObjectInitializer('Array',"",[]);;
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
			
		}
		/// <memberMethod name="fnGetLength">
		/// <summary>Returns the length of the array of keys.</summary>
		/// </memberMethod>
		function cParameterObject_fnGetLength()
		{
			try
			{
				///--It will give the length of the key
				var nLength=oArrKey.length;
				return nLength;
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnGetAllKeys">
		/// <summary>Returns the array of all the keys.</summary>
		/// </memberMethod>
		function cParameterObject_fnGetAllKeys()
		{
			try
			{
				return oArrKey;
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnGetValuesOfKey">
		///	<param name="strKey">This Parameter contains the key whose values are return by this function</param>
		/// <summary>Returns the array of values of the given key.</summary>
		/// </memberMethod>
		function cParameterObject_fnGetValuesOfKey(strKey)
		{
			var blnKeyExistFlag=false;
			try
			{
				if(strKey=="" || strKey==null)
				{
					oJSFW.fnThrowACTLError("Not a Valid Key!");
				}
				else
				{	
					for(nCtr=0;nCtr<oArrKey.length;nCtr++)
					{
						///It will check whether the key is exist or not if exist then it will return the value of that key
						if(oArrKey[nCtr]==strKey)
						{
							blnKeyExistFlag=true;
							return oArrValueOfKey[nCtr];
						}
						else
						{
							blnKeyExistFlag=false;
						}
							
					}	
					if(blnKeyExistFlag==false)
					{
						oJSFW.fnThrowACTLError("Key Not Found!","cParameterObject.fnGetPositionOfKey");
					}
				}
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
		}
		/// <memberMethod name="fnGetPositionOfKey">
		///	<param name="strKey">This Parameter contains the key whose position is returned by this function</param>
		/// <summary>Returns the position of given key.</summary>
		/// </memberMethod>
		function cParameterObject_fnGetPositionOfKey(strKey)
		{
			try
			{
				if(strKey=="" || strKey==null)
				{
					oJSFW.fnThrowACTLError("Not a Valid Key!");
				}
				else
				{	
					//It will give the position of the key from the array of key
					var nPosOfKey=oArrKey.fnIndexOf(strKey);
					return nPosOfKey;
				}
			}
			catch(ex)
			{
				oJSFW.fnThrowACTLException(ex.message, oJSFW.fnGetTypeNameFromFunctionCode(String(arguments.callee)), ex);
			}
			
		}
		
		
}