/**
 *
 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either 
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public 
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 **/
package lucee.runtime.util;

import lucee.runtime.PageContext;
import lucee.runtime.type.Collection.Key;
import lucee.runtime.type.Null;

public class CallerUtil {
	public static Object get(PageContext pc,Object coll, Key[] keys, Object defaultValue) {
		if(coll==null) return defaultValue;
		int to=keys.length-1;
		for(int i=0;i<=to;i++){
			coll=((VariableUtilImpl)pc.getVariableUtil()).getCollection(pc, coll, keys[i], Null.NULL);
			if(coll==Null.NULL || (coll==null && i<to)) return defaultValue;
		}
		return coll;
	}
}
@@ -815,16 +815,56 @@
 ontext;%0A
+import lucee.runtime.exp.PageException;%0A
 import l
@@ -955,16 +955,184 @@
 erUtil %7B
+%0A%0A%09public final static int TYPE_DATA=1;%0A%09public final static int TYPE_UDF_ARGS=2;%0A%09public final static int TYPE_UDF_NAMED_ARGS=3;%0A%09public final static int TYPE_BIF=4;%0A%09
 %0A%09public
@@ -1485,9 +1485,819 @@
 oll;%0A%09%7D%0A
+%09%0A%09// TODO work in progress%0A%09public static Object get(PageContext pc,Object coll, int%5B%5D types, Key%5B%5D keys,Object%5B%5D%5B%5D args, Object defaultValue) throws PageException %7B%0A%09%09if(coll==null) return defaultValue;%0A%09%09int to=keys.length-1;%0A%09%09VariableUtilImpl vu = (VariableUtilImpl)pc.getVariableUtil();%0A%09%09for(int i=0;i%3C=to;i++)%7B%0A%09%09%09switch(types%5Bi%5D) %7B%0A%09%09%09case TYPE_DATA:%0A%09%09%09%09coll=vu.getCollection(pc, coll, keys%5Bi%5D, Null.NULL);%0A%09%09%09break;%0A%09%09%09case TYPE_UDF_ARGS:%0A%09%09%09%09coll=vu.callFunctionWithoutNamedValues(pc, coll, keys%5Bi%5D, args%5Bi%5D, Null.NULL);%0A%09%09%09break;%0A%09%09%09case TYPE_UDF_NAMED_ARGS:%0A%09%09%09%09coll=vu.callFunctionWithNamedValues(pc, coll, keys%5Bi%5D, args%5Bi%5D, Null.NULL);%0A%09%09%09break;%0A%09%09%09case TYPE_BIF:%0A%09%09%09%09coll=null;//TODO%0A%09%09%09break;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09if(coll==Null.NULL %7C%7C (coll==null && i%3Cto)) return defaultValue;%0A%09%09%7D%0A%09%09return coll;%0A%09%7D%0A
 %7D

add get method that allows to involve functions