public Object apply(String source,int lineNo,int columnNo,Object funcBody,Vector namesVec,Vector argsVec) throws BSFException {
  if (namesVec.size() != argsVec.size())   throw new BSFException("number of params/names mismatch");
  if (!(funcBody instanceof String))   throw new BSFException("apply: functino body must be a string");
  String[] names=new String[namesVec.size()];
  namesVec.copyInto(names);
  Object[] args=new Object[argsVec.size()];
  argsVec.copyInto(args);
  try {
    if (!installedApplyMethod) {
      interpreter.eval(bsfApplyMethod);
      installedApplyMethod=true;
    }
    bsh.This global=(bsh.This)interpreter.get("global");
    Object value=global.invokeMethod("_bsfApply",new Object[]{names,args,(String)funcBody});
    return Primitive.unwrap(value);
  }
 catch (  InterpreterError e) {
    throw new BSFException("BeanShell interpreter internal error: " + e + sourceInfo(source,lineNo,columnNo));
  }
catch (  TargetError e2) {
    throw new BSFException("The application script threw an exception: " + e2.getTarget() + sourceInfo(source,lineNo,columnNo));
  }
catch (  EvalError e3) {
    throw new BSFException("BeanShell script error: " + e3 + sourceInfo(source,lineNo,columnNo));
  }
}

public Object apply ( String source , int lineNo , int columnNo , Object funcBody , Vector namesVec , Vector argsVec ) throws BSFException { if ( namesVec . size ( ) != argsVec . size ( ) ) throw new BSFException ( "number of params/names mismatch" ) ; if ( ! ( funcBody instanceof String ) ) throw new BSFException ( "apply: functino body must be a string" ) ; String [ ] names = new String [ namesVec . size ( ) ] ; namesVec . copyInto ( names ) ; Object [ ] args = new Object [ argsVec . size ( ) ] ; argsVec . copyInto ( args ) ; try { if ( ! installedApplyMethod ) { interpreter . eval ( bsfApplyMethod ) ; installedApplyMethod = true ; } bsh . This global = ( bsh . This ) interpreter . get ( "global" ) ; Object value = global . invokeMethod ( "_bsfApply" , new Object [ ] { names , args , ( String ) funcBody } ) ; return Primitive . unwrap ( value ) ; } catch ( InterpreterError e ) { throw new BSFException ( "BeanShell interpreter internal error: " + e + sourceInfo ( source , lineNo , columnNo ) ) ; } catch ( TargetError e2 ) { throw new BSFException ( "The application script threw an exception: " + e2 . getTarget ( ) + sourceInfo ( source , lineNo , columnNo ) ) ; } catch ( EvalError e3 ) { throw new BSFException ( "BeanShell script error: " + e3 + sourceInfo ( source , lineNo , columnNo ) ) ; } }
this is an implementation of the bsf apply ( ) method . it exectutes the funcbody text in an " anonymous " method call with arguments .
