import railo.transformer.library.function.FunctionLibFunction;
public class IsDefined implements FunctionEvaluator{
public void evaluate(BIF bif, FunctionLibFunction flf) throws TemplateException {
Argument arg = bif.getArguments()[0];
Expression value = arg.getValue();
if(value instanceof LitString) {
String str=((LitString)value).getString();
StringList sl = VariableInterpreter.parse(str,false);
if(sl!=null){
// scope
str=sl.next();
int scope = VariableInterpreter.scopeString2Int(str);
if(scope==Scope.SCOPE_UNDEFINED)sl.reset();
// keys
String[] arr=sl.toArray();
ArrayUtil.trim(arr);
// update first arg
arg.setValue(LitDouble.toExprDouble(scope),"number");
// add second argument
if(arr.length==1){
Expression expr = new CollectionKey(arr[0]);//LitString.toExprString(str);
arg=new Argument(expr,Collection.Key.class.getName());
bif.addArgument(arg);
}
else {
CollectionKeyArray expr=new CollectionKeyArray(arr);
//LiteralStringArray expr = new LiteralStringArray(arr);
arg=new Argument(expr,Collection.Key[].class.getName());
bif.addArgument(arg);
}
}