Logo Search packages:      
Sourcecode: gant version File versions

Object org::codehaus::gant::GantMetaClass::invokeMethod ( final Object  object,
final String  methodName,
final Object[]  arguments 
) [inline]

Invokes a method on the given object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.

See also:
groovy.lang.MissingMethodException
Parameters:
object The instance on which the method is invoked.
methodName The name of the method.
arguments The arguments to the method.
Returns:
The return value of the method which is null if the return type is void.

Definition at line 111 of file GantMetaClass.java.

References binding, methodsInvoked, and processArgument().

Referenced by invokeMethod().

                                                                                                          {
    Object returnObject = null ;
    if ( methodName.equals ( "depends" ) ) {
      for ( Object argument : arguments ) {
        if ( argument instanceof List ) {
          for ( Object item : (List<?>) argument ) { returnObject = processArgument ( item ) ; }
        }
        else { returnObject = processArgument ( argument ) ; }
      }
    }
    else {
      try {
        returnObject = super.invokeMethod ( object , methodName , arguments ) ;
        try {
          final Closure closure = (Closure) binding.getVariable ( methodName ) ;
          if ( closure != null ) { methodsInvoked.add ( closure ) ; }
        }
        catch ( final MissingPropertyException mpe ) { }
      }
      catch ( final MissingMethodException mme ) {
        try { returnObject = ( (GantBuilder) ( binding.getVariable ( "ant" ) ) ).invokeMethod ( methodName , arguments ) ; }
        catch ( final BuildException be ) { throw mme ; }
      }
    }
    return returnObject ;
  }


Generated by  Doxygen 1.6.0   Back to index