public boolean evaluateFunction ( ScriptInfo info , Object [ ] args , ExecutionContext context ) throws ServiceException { /** * This code below is optimized for speed, not clarity. Do not modify the * code below when making new IdocScript functions. It is needed to prepare * the necessary variables for the evaluation and return of the custom * IdocScript functions. Only customize the switch statement below. */ int config [ ] = ( int [ ] ) info . m_entry ; String functionCalled = info . m_key ; int functionIndex = config [ 0 ] ; int nargs = args . length - 1 ; int allowedParams = config [ 1 ] ; if ( allowedParams >= 0 && allowedParams != nargs ) { String msg = LocaleUtils . encodeMessage ( "csScriptEvalNotEnoughArgs" , null , functionCalled , "" + allowedParams ) ; throw new IllegalArgumentException ( msg ) ; } UserData userData = ( UserData ) context . getCachedObject ( "UserData" ) ; if ( userData == null ) { String msg = LocaleUtils . encodeMessage ( "csUserDataNotAvailable" , null , functionCalled ) ; throw new ServiceException ( msg ) ; } if ( functionIndex > m_functionTable . length ) { SystemUtils . trace ( "twine" , "Unknown function with index" + functionIndex ) ; return false ; } try { args [ nargs ] = runFunctionMethod ( functionIndex , args , context ) ; } catch ( Exception e ) { String msg = e . getMessage ( ) ; if ( e instanceof InvocationTargetException ) { msg = ( ( InvocationTargetException ) e ) . getTargetException ( ) . getMessage ( ) ; } msg = "Unable to execute function '" + functionCalled + "()': " + msg ; SystemUtils . err ( e , msg ) ; SystemUtils . trace ( "twine" , msg ) ; throw new ServiceException ( e ) ; } // Handled function. return true ; }
This is where the custom IdocScript function is evaluated .