1 define(['require','CONSTANT'], 
  2     function ( require, CONSTANT ) {
  3         /**
  4 		 * A Collection Framework class contains all basic classes like Stack, Queue, HashMap, ArrayList, Set
  5 		 * @name Collections
  6 		 * @class Collections
  7 		 * @example require('Collections')
  8 		 * @exports Collections
  9 		 * @version 1.0
 10 		 * @module Collections
 11 		 * @augments CONSTANT
 12 		 **/
 13 		var Collections = {
 14 			
 15 			 /**
 16 			 * Object types provided by Collections 
 17 			 * @name TYPE
 18 			 * @class TYPE
 19 			 * @example require('Collections').TYPE.STACK
 20 			 * @example require('Collections').TYPE.ARRAYLIST
 21 			 * @example require('Collections').TYPE.HASHMAP
 22 			 * @example require('Collections').TYPE.SET
 23 			 * @example require('Collections').TYPE.QUEUE
 24 			 * @example require('Collections').TYPE.TREE
 25 			 * @exports TYPE
 26 			 * @version 1.0
 27 			 * @module Collections
 28 			 * @memberOf Collections
 29 			 * @field
 30 			 **/
 31 			TYPE:{
 32 				/** @constant*/
 33 				STACK:"Stack",
 34 				ARRAYLIST:"ArrayList",
 35 				HASHMAP:"HashMap",
 36 				SET:"Set",
 37 				QUEUE:"Queue",
 38 				TREE:"Tree"
 39 			},
 40 	        /**
 41 			 * A Stack is a Collection that contains duplicate values. Last In First Out. 
 42 			 * @name Stack
 43 			 * @class Stack
 44 			 * @example require('Collections').Stack()
 45 			 * @exports Stack
 46 			 * @version 1.0
 47 			 * @module Collections
 48 			 * @memberOf Collections
 49 			 **/
 50 			Stack: 	function () {
 51 				var stac = [];
 52 				var stackObj = {
 53 					/**
 54 					 * @name pop
 55 					 * @memberOf Collections.Stack
 56 					 * @method 
 57 					 * @description removes the top item from teh stacks
 58 					 * @return {Object} item 
 59 					 * @function
 60 					 */
 61 					pop : function() {
 62 						return stac.pop();
 63 					},
 64 					/**
 65 					 * @name push
 66 					 * @memberOf Collections.Stack
 67 					 * @method 
 68 					 * @description removes the top item from teh stacks
 69 					 * @param {Object} item
 70 					 * @return {null}  
 71 					 * @function
 72 					 */
 73 					push : function(item) {
 74 						stac.push(item);
 75 					},
 76 					/**
 77 					 * @name isEmpty
 78 					 * @memberOf Collections.Stack
 79 					 * @method 
 80 					 * @description returns true if teh Stack is empty.
 81 					 * @return {boolean}  
 82 					 * @function
 83 					 */
 84 					isEmpty : function() {
 85 						return stac.length == 0;
 86 					},
 87 					/**
 88 					 * @name objType
 89 					 * @memberOf Collections.Stack
 90 					 * @method 
 91 					 * @description returns teh Object type as "Stack"
 92 					 * @return {String} ObjectType  
 93 					 * @function
 94 					 */
 95 					objType : function(){
 96 						return "Stack";
 97 					},
 98 					/**
 99 					 * @name getElements
100 					 * @memberOf Collections.Queue
101 					 * @method 
102 					 * @description returns teh Elemnts in the Queue
103 					 * @return {Object[]} itemArray  
104 					 * @function
105 					 */
106 					getElements : function(){
107 						return stac.clone();
108 					},
109 					/**
110 					 * @name toString
111 					 * @memberOf Collections.Stack
112 					 * @method 
113 					 * @description returns the JSON data of teh Object
114 					 * @return {String} ObjectType  
115 					 * @function
116 					 */
117 					toString : function(){
118 						return "["+stac.join()+"]";
119 					},
120 					/**
121 					 * @name clone
122 					 * @memberOf Collections.Stack
123 					 * @method 
124 					 * @description returns Collection.Stack a new Stack with the cloned object of the items.
125 					 * @return {Collections.Stack}
126 					 * @function
127 					 */
128 					clone:function(){
129 						var Collection = require('Collections');
130 						var cloneStack = Collection.Stack();
131 						var elements = stac;
132 						for(var i=0;i<elements.length; i++){
133 							if(elements[i].clone)
134 								cloneStack.push(elements[i].clone());
135 							else
136 								cloneStack.push(elements[i]);
137 						}
138 						return cloneStack;
139 					}
140 				};
141 				return stackObj;
142 			},
143 			/**
144 			 * An Queue is a Collection that contains duplicate values. First In First Out. 
145 			 * @name Queue
146 			 * @class Queue
147 			 * @example require('Collections').Queue()
148 			 * @exports Queue
149 			 * @version 1.0
150 			 * @module Queue
151 			 * @memberOf Collections
152 			 **/
153 			Queue : function(){
154 				var queue=[];
155 				var queueObj={
156 					/**
157 					 * @name add
158 					 * @memberOf Collections.Queue
159 					 * @method 
160 					 * @description insert an Item to the Queue, it adds to the last of the array, It allows duplicate values in the list.
161 					 * @param {Object} item
162 					 * @return {null} 
163 					 * @function
164 					 */
165 					add : function(item){
166 						queue.unshift(item);
167 					},
168 					/**
169 					 * @name remove
170 					 * @memberOf Collections.Queue
171 					 * @method 
172 					 * @description remove an item from Queue
173 					 * @return {Object} item 
174 					 * @function
175 					 */
176 					remove : function(){
177 						return queue.pop();
178 					},
179 					/**
180 					 * @name isEmpty
181 					 * @memberOf Collections.Queue
182 					 * @method 
183 					 * @description checks whether any item present in the queue.
184 					 * @return {boolean} isEmpty
185 					 * @function
186 					 */
187 					isEmpty : function(){
188 						return queue.length == 0;
189 					},
190 					/**
191 					 * @name size
192 					 * @memberOf Collections.Queue
193 					 * @method 
194 					 * @description returns the present size of teh queue.
195 					 * @return {integer} size
196 					 * @function
197 					 * @deprecated
198 					 */
199 					size : function(){
200 						return queue.length;
201 					},
202 					/**
203 					 * @name getElements
204 					 * @memberOf Collections.Queue
205 					 * @method 
206 					 * @description returns teh Elemnts in the Queue
207 					 * @return {Object[]} itemArray  
208 					 * @function
209 					 */
210 					getElements : function(){
211 						return queue.clone();
212 					},
213 					/**
214 					 * @name containsKey
215 					 * @memberOf Collections.Queue
216 					 * @method 
217 					 * @description checks whether the provided object exists in the Queue or not.
218 					 * @param {Object} item
219 					 * @return {boolean}
220 					 * @function
221 					 */
222 					contains : function(obj){
223 						for(var i=0; i< queue.length; i++){
224 							if(queue[i]==obj)
225 								return true;
226 						}
227 						return false;
228 					},
229 					/**
230 					 * @name objType
231 					 * @memberOf Collections.Queue
232 					 * @method 
233 					 * @description returns teh Object type as "Queue"
234 					 * @return {String} ObjectType  
235 					 * @function
236 					 */
237 					objType : function(){
238 						return "Queue";
239 					},
240 					/**
241 					 * @name toString
242 					 * @memberOf Collections.Queue
243 					 * @method 
244 					 * @description returns the JSON data of teh Object
245 					 * @return {String} ObjectType  
246 					 * @function
247 					 */
248 					toString : function(){
249 						return "["+queue.join()+"]";
250 					},
251 					/**
252 					 * @name clone
253 					 * @memberOf Collections.Queue
254 					 * @method 
255 					 * @description returns Collection.Queue a new Queue with the cloned object of the items.
256 					 * @return {Collections.Queue}
257 					 * @function
258 					 */
259 					clone:function(){
260 						var Collection = require('Collections');
261 						var cloneQueue = Collection.Queue();
262 						var elements = this.getElements();
263 						for(var i=elements.length-1; i>=0; i--){
264 							if(elements[i].clone)
265 								cloneQueue.add(elements[i].clone());
266 							else
267 								cloneQueue.add(elements[i]);
268 						}
269 						return cloneQueue;
270 					}
271 				};
272 				return queueObj;
273 			},
274 			/**
275 			 * An ArrayList is a Collection that contains duplicate values. 
276 			 * @name ArrayList
277 			 * @class ArrayList
278 			 * @example require('Collections').ArrayList()
279 			 * @exports ArrayList
280 			 * @version 1.0
281 			 * @module ArrayList
282 			 * @memberOf Collections
283 			 **/
284 			ArrayList : function() {
285 				var arr = [];
286 				var array = {
287 					/**
288 					 * @name add
289 					 * @memberOf Collections.ArrayList
290 					 * @method 
291 					 * @description insert an Item to the ArrayList, it adds to the last of the array, It allows duplicate values in the list.
292 					 * @param {Object} item
293 					 * @return {null} 
294 					 * @function
295 					 */
296 					add : function(item) {
297 						arr.push(item);
298 					},
299 					/**
300 					 * @name addAll
301 					 * @memberOf Collections.ArrayList
302 					 * @method 
303 					 * @description insert an array of Items to the ArrayList, it adds to the last of the array, It allows duplicate values in the list.
304 					 * @param {Object[]} itemArray
305 					 * @return {null} 
306 					 * @function
307 					 */
308 					addAll : function(items) {
309 						for(var i=0; i< items.length; i++)
310 							this.add(items[i]);
311 					},
312 					/**
313 					 * @name indexOf
314 					 * @memberOf Collections.ArrayList
315 					 * @method 
316 					 * @description returns teh index of teh item in the ArrayList, if item not found it returns -1.
317 					 * @param {Object} item
318 					 * @return {integer} 
319 					 * @function
320 					 */
321 					indexOf : function(item) {
322 						return arr.indexOf(item);
323 					},
324 					/**
325 					 * @name contains
326 					 * @memberOf Collections.ArrayList
327 					 * @method 
328 					 * @description returns whether the item present in the ArrayList.
329 					 * @param {Object} item
330 					 * @return {boolean} 
331 					 * @function
332 					 */
333 					contains:function(item){
334 						return arr.indexOf(item) != -1;
335 					},
336 					/**
337 					 * @name remove
338 					 * @memberOf Collections.ArrayList
339 					 * @method 
340 					 * @description remove an item from the array, then the remaining items will be shifted left, and their index will be reduced by 1.
341 					 * @param {Object} item
342 					 * @return {null} 
343 					 * @function
344 					 */
345 					remove : function(item) {
346 						if (arr.indexOf(item) >= 0)
347 							arr.splice(arr.indexOf(item), 1);
348 					},
349 					/**
350 					 * @name size
351 					 * @memberOf Collections.ArrayList
352 					 * @method 
353 					 * @description returns the number of the Elements present in the ArrayList.
354 					 * @return {integer} 
355 					 * @function
356 					 */
357 					size:function(){
358 						return arr.length;
359 					},
360 					/**
361 					 * @name get
362 					 * @memberOf Collections.ArrayList
363 					 * @method 
364 					 * @description returns the object at the prvided index.
365 					 * @param {integer} index
366 					 * @return {Object} item 
367 					 * @function
368 					 */
369 					get : function(index){
370 						return arr[index];
371 					},
372 					/**
373 					 * @name set
374 					 * @memberOf Collections.ArrayList
375 					 * @method 
376 					 * @description set an item at the specified location
377 					 * @param {integer} index
378 					 * @param {Object} Item
379 					 * @return {null}  
380 					 * @function
381 					 */
382 					set:function(index, item){
383 						if(index<0) throw "Index out of bound exception";
384 						arr[index]=item;
385 					},
386 					/**
387 					 * @name getElements
388 					 * @memberOf Collections.ArrayList
389 					 * @method 
390 					 * @description returns teh Elemnts in the ArrayList
391 					 * @return {Object[]} itemArray  
392 					 * @function
393 					 */
394 					getElements : function(){
395 						return arr.clone();
396 					},
397 					/**
398 					 * @name objType
399 					 * @memberOf Collections.ArrayList
400 					 * @method 
401 					 * @description returns teh Object type as "ArrayList"
402 					 * @return {String} ObjectType  
403 					 * @function
404 					 */
405 					objType:function(){
406 						return "ArrayList";
407 					},
408 					/**
409 					 * @name toString
410 					 * @memberOf Collections.ArrayList
411 					 * @method 
412 					 * @description returns the JSON data of teh Object
413 					 * @return {String} ObjectType  
414 					 * @function
415 					 */
416 					toString : function(){
417 						return "["+arr.join()+"]";
418 					},
419 					/**
420 					 * @name json
421 					 * @memberOf Collections.ArrayList
422 					 * @method 
423 					 * @description returns the JSON string
424 					 * @return {String} json  
425 					 * @function
426 					 */
427 					json :function(){
428 						var jsonArr=[];
429 						for(var i=0; i<arr.length; i++){
430 						  jsonArr.push(arr[i].json());
431 						}
432 						return JSON.stringify(jsonArr);
433 					},
434 					/**
435 					 * @name clone
436 					 * @memberOf Collections.ArrayList
437 					 * @method 
438 					 * @description returns Collection.ArrayList a new ArrayList with the cloned object of the items.
439 					 * @return {Collections.ArrayList}
440 					 * @function
441 					 */
442 					clone:function(){
443 						var Collection = require('Collections');
444 						var cloneList = Collection.ArrayList();
445 						var elements = this.getElements();
446 						for(var i=0; i<elements.length; i++){
447 							if(elements[i].clone)
448 								cloneList.add(elements[i].clone());
449 							else
450 								cloneList.add(elements[i]);
451 						}
452 						return cloneList;
453 					}
454 				};
455 				return array;
456 			},
457 			
458 			/**
459 			 * A HashMap is a Collection that cannot contain duplicate keys.It keeps key value pair in the Datastructure.
460 			 * @name HashMap
461 			 * @class HashMap
462 			 * @example require('Collections').HashMap()
463 			 * @exports HashMap
464 			 * @version 1.0
465 			 * @module HashMap
466 			 * @memberOf Collections
467 			 **/
468 			HashMap : function() {
469 				var keys =[];
470 				var hashMap = {
471 					/**
472 					 * @name put
473 					 * @memberOf Collections.HashMap
474 					 * @method 
475 					 * @description insert an Item to the Hashmap with teh provided key, if the key is already exists, then the value will be replaced.
476 					 * @param {Object} key
477 					 * @param {Object} value
478 					 * @return {Object[]} Object
479 					 * @function
480 					 */
481 					put : function(key, val) {
482 						if(key instanceof Array){
483 							var found = false;
484 							for(var i=0; i< keys.length; i++){
485 								if(ArrayCompare(keys[i], key)){
486 									this[keys[i]] = val;
487 									found = true;
488 									break;
489 								}
490 							}
491 							if(!found){
492 								keys.push(key);
493 								this[key] = val;	
494 							}
495 						}else{
496 							if(keys.indexOf(key) == -1)
497 								keys.push(key);
498 							this[key] = val;
499 						}
500 					},
501 					/**
502 					 * @name get
503 					 * @memberOf Collections.HashMap
504 					 * @method 
505 					 * @description returns the item associated with the key
506 					 * @param {Object} key
507 					 * @return {Object[]} Object
508 					 * @function
509 					 */
510 					get : function(key) {
511 						if(key instanceof Array){
512 							for(var i=0; i< keys.length; i++){
513 								if(ArrayCompare(keys[i],key)){
514 									return this[keys[i]];
515 								}
516 							}
517 						}else{
518 							return this[key];
519 						}
520 					},
521 					/**
522 					 * @name getKeys
523 					 * @memberOf Collections.HashMap
524 					 * @method 
525 					 * @description returns an Array of the key items
526 					 * @return {Object[]} keyArray
527 					 * @function
528 					 */
529 					getKeys:function(){
530 						return keys.clone();
531 					},
532 					/**
533 					 * @name remove
534 					 * @memberOf Collections.HashMap
535 					 * @method 
536 					 * @description remove the key and the value from the HashMap
537 					 * @param {Object} key
538 					 * @return {null}
539 					 * @function
540 					 */
541 					remove:function(key){
542 						var index = keys.indexOf(key);
543 						this.put(key,null);
544 						keys.splice(index,1);
545 					},
546 					/**
547 					 * @name containsKey
548 					 * @memberOf Collections.HashMap
549 					 * @method 
550 					 * @description checks whether the provided key exists in the HashMap or not.
551 					 * @param {Object} key
552 					 * @return {boolean}
553 					 * @function
554 					 */
555 					containsKey:function(key){
556 						return keys.indexOf(key) != -1;
557 					},
558 					/**
559 					 * @name objType
560 					 * @memberOf Collections.HashMap
561 					 * @method 
562 					 * @description returns the Object Type as HashMap
563 					 * @return {String}
564 					 * @function
565 					 * 
566 					 */
567 					objType:function(){
568 						return "HashMap";
569 					},
570 					clone:function(){
571 						throw "HashMap - Clone functionality not implemented";
572 					}
573 				};
574 				return hashMap;
575 			},
576 			
577 			/**
578 			 * A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set class adds and restricts the duplicate elements added. Two Set instances are equal if they contain the same elements
579 			 * @name Set
580 			 * @class Set
581 			 * @example require('Collections').Set()
582 			 * @exports Set
583 			 * @version 1.0
584 			 * @module Set
585 			 * @memberOf Collections
586 			 **/
587 			Set : function() {
588 
589 				var Collection = require('Collections');
590 				var elements =[];
591 				var set = {
592 					/**
593 					 * @name add
594 					 * @memberOf Collections.Set
595 					 * @method 
596 					 * @description Adds the specified element to this set if it is not already present.
597 					 * @param {Object} item
598 					 * @return null
599 					 * @function
600 					 * 
601 					 */
602 					add : function(item) {
603 						if(elements.indexOf(item) == -1)
604 							elements.push(item);
605 					},
606 					/**
607 					 * @name addAll
608 					 * @memberOf Collections.Set
609 					 * @method 
610 					 * @description Adds an array of elements to the Collection, and dicarded if teh item already present
611 					 * @param {Object[]} itemArray
612 					 * @return null
613 					 * @function
614 					 * 
615 					 */
616 					addAll : function(items) {
617 						if(!items || !items instanceof Array)
618 							return;
619 						for(var i=0; i< items.length; i++)
620 							this.add(items[i]);
621 					},
622 					/**
623 					 * @name getElements
624 					 * @memberOf Collections.Set
625 					 * @method 
626 					 * @description returns the elemnts in teh Set as an Array [] of elements
627 					 * @return {Object[]}
628 					 * @function
629 					 * 
630 					 */
631 					getElements:function(){
632 						return elements.clone();
633 					},
634 					/**
635 					 * @name contains
636 					 * @memberOf Collections.Set
637 					 * @method 
638 					 * @description returns true if teh provided item already present in the collection set.
639 					 * @param {Object} Item
640 					 * @return {boolean}
641 					 * @function
642 					 * 
643 					 */
644 					contains : function(item){
645 						return -1 != elements.indexOf(item);
646 					},
647 					/**
648 					 * @name size
649 					 * @memberOf Collections.Set
650 					 * @method 
651 					 * @description returns the size of the set.
652 					 * @return {Integer}
653 					 * @function
654 					 * 
655 					 */
656 					size:function(){
657 						return elements.length;
658 					},
659 					/**
660 					 * @name containsAll
661 					 * @memberOf Collections.Set
662 					 * @method 
663 					 * @description returns true if teh provided all items already present in the collection set.
664 					 * @param {Object[]} ItemArray
665 					 * @return {boolean}
666 					 * @function
667 					 * 
668 					 */
669 					containsAll : function(items){
670 						for(var i=0; i< items.length; i++)
671 							if(!this.contains(items[i]))
672 								return false;
673 						return true;
674 					},
675 					/**
676 					 * @name remove
677 					 * @memberOf Collections.Set
678 					 * @method 
679 					 * @description removes item from teh Collection.Set
680 					 * @param {Object} Item
681 					 * @return {null}
682 					 * @function
683 					 * 
684 					 */
685 					remove:function(item){
686 						var index = elements.indexOf(item);
687 						if(index!= -1)
688 							elements.splice(index,1);
689 					},
690 					/**
691 					 * @name minus
692 					 * @memberOf Collections.Set
693 					 * @method 
694 					 * @description removes item available in the itemSet from the currentSet
695 					 * @param {Collection.Set} ItemsSet
696 					 * @return {diffSet}
697 					 * @function
698 					 * 
699 					 */
700 					minus:function(itemsSet){
701 						var diff=Collection.Set();
702 						for(var i=0; i< elements.length; i++)
703 							if(!itemsSet.contains(elements[i]))
704 								diff.add(elements[i]);
705 						return diff;
706 					},
707 					/**
708 					 * @name intersect
709 					 * @memberOf Collections.Set
710 					 * @method 
711 					 * @description returns a set of items common to both teh sets.
712 					 * @param {Collection.Set} ItemsSet
713 					 * @return {intersectionSet}
714 					 * @function
715 					 * 
716 					 */
717 					intersect:function(itemsSet){
718 						var intSect=Collection.Set();
719 						for(var i=0; i< elements.length; i++)
720 							if(itemsSet.contains(elements[i]))
721 								intSect.add(elements[i]);
722 						return intSect;
723 					},
724 					/**
725 					 * @name objType
726 					 * @memberOf Collections.Set
727 					 * @method 
728 					 * @description returns the Object Type as "Set"
729 					 * @return {String}
730 					 * @function
731 					 * 
732 					 */
733 					objType:function(){
734 						return "Set";
735 					},
736 					/**
737 					 * @name toString
738 					 * @memberOf Collections.Set
739 					 * @method 
740 					 * @description returns JSON Notation of the items in teh set.
741 					 * @return {String}
742 					 * @function
743 					 * 
744 					 */
745 					toString : function(){
746 						return "["+elements.join()+"]";
747 					},
748 					/**
749 					 * @name clone
750 					 * @memberOf Collections.Set
751 					 * @method 
752 					 * @description returns Collection.Set a new set with the cloned object of the items.
753 					 * @return {Collections.Set}
754 					 * @function
755 					 */
756 					clone:function(){
757 						var cloneSet = Collection.Set();
758 						var elements = this.getElements();
759 						for(var i=0; i<elements.length; i++){
760 							if(elements[i].clone)
761 								cloneSet.add(elements[i].clone());
762 							else
763 								cloneSet.add(elements[i]);
764 						}
765 						return cloneSet;
766 					}
767 				};
768 				return set;
769 			},
770 			
771 			/**
772 			 * A Tree is a Collection that can contain multiple childrens for a node
773 			 * @name Tree
774 			 * @class Tree
775 			 * @example require('Collections').Tree()
776 			 * @exports Tree
777 			 * @version 1.0
778 			 * @module Tree
779 			 * @memberOf Collections
780 			 **/
781 			Tree: 	function (rootObj, type) {
782 				var Collection = require('Collections');
783 				var children = new Collection.ArrayList();
784 				var showChildren = true;
785 				var success = false;
786 				var root;
787 				var rootType;
788 				var rootFormula;
789 				var rootDesc;
790 				var label;
791 				var factName;
792 				if(rootObj)
793 					root = rootObj;
794 				if(type)
795 					rootType = type;
796 				else	
797 					rootType = CONSTANT.TreeNodeType.SINGLE_VAL;
798 					
799 				var treeObj = {
800 					/**
801 					 * @name getRootLabel
802 					 * @memberOf Collections.Tree
803 					 * @method 
804 					 * @description gets the root Label
805 					 * @return {String}
806 					 * @function
807 					 */
808 					getRootLabel:function(){
809 						return label;
810 					},
811 					/**
812 					 * @name setRootLabel
813 					 * @memberOf Collections.Tree
814 					 * @method 
815 					 * @description gets the root Labeling applied
816 					 * @param {String}
817 					 * @return {null}
818 					 * @function
819 					 */
820 					setRootLabel:function(lbl){
821 						label = lbl;
822 					},
823 					/**
824 					 * @name getDescription
825 					 * @memberOf Collections.Tree
826 					 * @method 
827 					 * @description gets the root Description
828 					 * @return {String}
829 					 * @function
830 					 */
831 					getRootDescription:function(){
832 						return rootDesc;
833 					},
834 					/**
835 					 * @name setDescription
836 					 * @memberOf Collections.Tree
837 					 * @method 
838 					 * @description gets the root Description applied
839 					 * @param {String}
840 					 * @return {null}
841 					 * @function
842 					 */
843 					setRootDescription:function(description){
844 						rootDesc = description;
845 					},
846 					/**
847 					 * @name getRootFormula
848 					 * @memberOf Collections.Tree
849 					 * @method 
850 					 * @description gets the root formula provided for explanation
851 					 * @return {String}
852 					 * @function
853 					 */
854 					getRootFormula:function(){
855 						return rootFormula;
856 					},
857 					/**
858 					 * @name setRootFormula
859 					 * @memberOf Collections.Tree
860 					 * @method 
861 					 * @description gets the root formula applied for explanation
862 					 * @param {String}
863 					 * @return {null}
864 					 * @function
865 					 */
866 					setRootFormula:function(formula){
867 						rootFormula = formula;
868 					},
869 					/**
870 					 * @name setRootFactName
871 					 * @memberOf Collections.Tree
872 					 * @method 
873 					 * @description gets the root fact name
874 					 * @param {String}
875 					 * @return {null}
876 					 * @function
877 					 */
878 					setRootFactName:function(fName){
879 						factName = fName;
880 					},
881 					/**
882 					 * @name getRootFactName
883 					 * @memberOf Collections.Tree
884 					 * @method 
885 					 * @description gets the root fact name
886 					 * @return {String}
887 					 * @function
888 					 */
889 					getRootFactName:function(){
890 						return factName;
891 					},
892 					/**
893 					 * @name getRoot
894 					 * @memberOf Collections.Tree
895 					 * @method 
896 					 * @description gets the root Node Object
897 					 * @return {null}
898 					 * @function
899 					 */
900 					getRoot : function() {
901 						return root;
902 					},
903 					/**
904 					 * @name setRoot
905 					 * @memberOf Collections.Tree
906 					 * @method 
907 					 * @description sets the root Node Object
908 					 * @param {Object}
909 					 * @return {null}
910 					 * @function
911 					 */
912 					setRoot : function(item) {
913 						root = item;
914 					},
915 					/**
916 					 * @name setRootType
917 					 * @memberOf Collections.Tree
918 					 * @method 
919 					 * @description sets the root type as Single Value or Multi Valued type.
920 					 * @param {CONSTANT.TreeNodeType}
921 					 * @return {null}
922 					 * @function
923 					 */
924 					setRootType:function(type){
925 						rootType = type;
926 					},
927 					/**
928 					 * @name getRootType
929 					 * @memberOf Collections.Tree
930 					 * @method 
931 					 * @description returns whether the root type is Single Value or Multi Valued type.
932 					 * @return {CONSTANT.TreeNodeType}
933 					 * @function
934 					 */
935 					getRootType:function(){
936 						return rootType;
937 					},
938 					/**
939 					 * @name hasChildren
940 					 * @memberOf Collections.Tree
941 					 * @method 
942 					 * @description Checks whether the Tree node have children or Not
943 					 * @return {boolean}
944 					 * @function
945 					 */
946 					hasChildren : function() {
947 						return children.size() != 0;
948 					},
949 					/**
950 					 * @name addChildren
951 					 * @memberOf Collections.Tree
952 					 * @method 
953 					 * @description Add a children to the provided Tree Node
954 					 * @param {Object} Item
955 					 * @return {null}
956 					 * @function
957 					 */
958 					addChildren:function(item){
959 						children.add(item);
960 						item.parent = this;
961 					},
962 					/**
963 					 * @name getChildren
964 					 * @memberOf Collections.Tree
965 					 * @method 
966 					 * @description returns an Collections.ArrayList of the childrens to the Node.
967 					 * @return {Collection.ArrayList} ChildrenList
968 					 * @function
969 					 */
970 					getChildren:function(){
971 						return children;
972 					},
973 					/**
974 					 * @name removeChildren
975 					 * @memberOf Collections.Tree
976 					 * @method 
977 					 * @description Remove the given children from a node
978 					 * @param {Collection.Set} Item
979 					 * @return {null}
980 					 * @function
981 					 */
982 					removeChildren:function(item){
983 						children.remove(item);
984 					},
985 					/**
986 					 * @name objType
987 					 * @memberOf Collections.Tree
988 					 * @method 
989 					 * @description returns teh Object Type as Tree
990 					 * @return {String}
991 					 * @function
992 					 */
993 					objType : function(){
994 						return "Tree";
995 					},
996 					/**
997 					 * @name isShowChildren
998 					 * @memberOf Collections.Tree
999 					 * @method 
1000 					 * @description returns whether the children can be shown in presentation layer
1001 					 * @return {null}
1002 					 * @function
1003 					 * 
1004 					 */
1005 					isShowChildren:function(){
1006 						return showChildren;
1007 					},
1008 					/**
1009 					 * @name setShowChildren
1010 					 * @memberOf Collections.Tree
1011 					 * @method 
1012 					 * @description set whether the children to be shown in presentation layer
1013 					 * @return {null}
1014 					 * @function
1015 					 * 
1016 					 */
1017 					setShowChildren : function(show){
1018 						showChildren = show;
1019 					},
1020 					
1021 					/**
1022 					 * @name isSuccessNode
1023 					 * @memberOf Collections.Tree
1024 					 * @method 
1025 					 * @description returns whether the children is success Node or Failure node
1026 					 * @return {null}
1027 					 * @function
1028 					 * 
1029 					 */
1030 					isNodeSuccess:function(){
1031 						return success;
1032 					},
1033 					/**
1034 					 * @name setNodeSuccess
1035 					 * @memberOf Collections.Tree
1036 					 * @method 
1037 					 * @description set whether the children is success Node or Failure node
1038 					 * @return {null}
1039 					 * @function
1040 					 * 
1041 					 */
1042 					setNodeSuccess : function(succes){
1043 						success = succes;
1044 					},
1045 					/**
1046 					 * @name clone
1047 					 * @memberOf Collections.Tree
1048 					 * @method 
1049 					 * @description returns Collection.Set a new set with the cloned object of the items.
1050 					 * @return {Collections.Tree}
1051 					 * @function
1052 					 * 
1053 					 */
1054 					clone:function(){
1055 						var cloneTree = new Collection.Tree();
1056 						if(root.clone)
1057 							cloneTree.setRoot(root.clone());
1058 						else
1059 							cloneTree.setRoot(root);
1060 						if(success)
1061 							cloneTree.setNodeSuccess(success);
1062 						var cloneChildren = children.clone();
1063 						for(var i=0; i< cloneChildren.size(); i++){
1064 							cloneTree.addChildren(cloneChildren.get(i));
1065 						}
1066 						return cloneTree;
1067 					},
1068 					/**
1069 					 * @name toString
1070 					 * @memberOf Collections.Tree
1071 					 * @method 
1072 					 * @description returns JSON Notation of the items in teh set.
1073 					 * @return {String}
1074 					 * @function
1075 					 * 
1076 					 */
1077 					toString:function(level){
1078 						var tab ="\t";
1079 						var margin="";
1080 						if(!level)
1081 							level = 0;
1082 						for(var i=0; i<level; i++){
1083 							margin = margin + tab;
1084 						}
1085 						var str = margin +label+" Node Success :"+success+" -- MULTI_VAL:"+(rootType == CONSTANT.TreeNodeType.MULTI_VAL).toString()+" SHOW-CHILD :"+showChildren+"  FACT :"+factName+"\n";
1086 						for(var i=0; i< children.size();i++){
1087 							str = str + "\n"+children.get(i).toString(level+1);
1088 						}
1089 						return str;
1090 					}
1091 				};
1092 				return treeObj;
1093 			},
1094 		};
1095 
1096 	return Collections;
1097 }); 
1098