public static Object callWithNamedValues ( PageContext pc , Object coll , Collection . Key methodName , Struct args , short type , String strType ) throws PageException { Map < Key , FunctionLibFunction > members = getMembers ( pc , type ) ; FunctionLibFunction member = members . get ( methodName ) ; if ( member != null ) { List < FunctionLibFunctionArg > _args = member . getArg ( ) ; FunctionLibFunctionArg arg ; if ( args . size ( ) < _args . size ( ) ) { Object val ; ArrayList < Ref > refs = new ArrayList < Ref > ( ) ; arg = _args . get ( 0 ) ; refs . add ( new Casting ( arg . getTypeAsString ( ) , arg . getType ( ) , new LFunctionValue ( new LString ( arg . getName ( ) ) , coll ) ) ) ; for ( int y = 1 ; y < _args . size ( ) ; y ++ ) { arg = _args . get ( y ) ; // match by name val = args . get ( arg . getName ( ) , null ) ; // match by alias if ( val == null ) { String alias = arg . getAlias ( ) ; if ( ! StringUtil . isEmpty ( alias , true ) ) { String [ ] aliases = lucee . runtime . type . util . ListUtil . trimItems ( lucee . runtime . type . util . ListUtil . listToStringArray ( alias , ' ' ) ) ; for ( int x = 0 ; x < aliases . length ; x ++ ) { val = args . get ( aliases [ x ] , null ) ; if ( val != null ) break ; } } } if ( val == null ) { if ( arg . getRequired ( ) ) { String [ ] names = member . getMemberNames ( ) ; String n = ArrayUtil . isEmpty ( names ) ? "" : names [ 0 ] ; throw new ExpressionException ( "missing required argument [" + arg . getName ( ) + "] for member function call [" + n + "]" ) ; } } else { refs . add ( new Casting ( arg . getTypeAsString ( ) , arg . getType ( ) , new LFunctionValue ( new LString ( arg . getName ( ) ) , val ) ) ) ; // refs.add(new LFunctionValue(new LString(arg.getName()),new // Casting(pc,arg.getTypeAsString(),arg.getType(),val))); } } return new BIFCall ( coll , member , refs . toArray ( new Ref [ refs . size ( ) ] ) ) . getValue ( pc ) ; } } throw new ExpressionException ( "No matching function member [" + methodName + "] for call with named arguments found, available function members are [" + lucee . runtime . type . util . ListUtil . sort ( CollectionUtil . getKeyList ( members . keySet ( ) . iterator ( ) , "," ) , "textnocase" , "asc" , "," ) + "]" ) ; }
used in extension image