Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.runtime.metaclass
Class ClosureMetaClass

    java.lang.Object
      groovy.lang.MetaClassImpl
          org.codehaus.groovy.runtime.metaclass.ClosureMetaClass

All Implemented Interfaces:
  MetaClass, MetaObjectProtocol, MutableMetaClass

    public final class ClosureMetaClass

extends MetaClassImpl

A Metaclass for closures generated by the Groovy compiler. These classes have special characteristics this MetaClass uses. One of these is that a generated Closure has only additional doCall methods, all other methods are in the Closure class as well. To use this fact this MetaClass uses a MetaClass for Closure as static field And delegates calls to this MetaClass if needed. This allows a lean implementation for this MetaClass. Multiple generated closures will then use the same MetaClass for Closure. For static dispatching this class uses the MetaClass of Class, again all isntances of this class will share that MetaClass. The Class MetaClass is initialized lazy, because most operations do not need this MetaClass.

The Closure and Class MetaClasses are not replaceable.

This MetaClass is for internal usage only!

Since:
  1.1
Author:
  Jochen Theodorou

Nested Class Summary

Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl
`MetaClassImpl.Index`

Field Summary

Fields inherited from class groovy.lang.MetaClassImpl
`EMPTY_CLASS_ARRAY, isGroovyObject, isMap, LOG, METHOD_MISSING, PROPERTY_MISSING, registry, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass`

Constructor Summary
`ClosureMetaClass(MetaClassRegistry registry, Class theClass)`

Method Summary
`void` | `addMetaBeanProperty(MetaBeanProperty mp)` Adds a new MetaBeanProperty to this MetaClass
`void` | `addMetaMethod(MetaMethod method)` adds a MetaMethod to this class.
`void` | `addNewInstanceMethod(Method method)` adds a new instance method to this MetaClass.
`void` | `addNewStaticMethod(Method method)` adds a new static method to this MetaClass.
`Object` | `getAttribute(Class sender, Object object, String attribute, boolean useSuper, boolean fromInsideClass)` Looks up the given attribute (field) on the given object
`List` | `getMetaMethods()` Retrieves a list of MetaMethod instances held by this class
`MetaProperty` | `getMetaProperty(String name)` Returns a MetaProperty for the given name or null if it doesn't exist
`List` | `getMethods()` Retrieves a list of MetaMethods held by the class
`MetaMethod` | `getMethodWithoutCaching(Class sender, String methodName, Class[] arguments, boolean isCallToSuper)`
`List` | `getProperties()` Get all the properties defined for this type
`Object` | `getProperty(Class sender, Object object, String name, boolean useSuper, boolean fromInsideClass)` Retrieves a property on the given receiver for the specified arguments.
`MetaMethod` | `getStaticMetaMethod(String name, Class[] argTypes)`
`MetaMethod` | `getStaticMetaMethod(String name, Object[] args)` Retreives a static MetaMethod for the given name and argument values, using the types of the arguments to establish the chosen MetaMethod
`void` | `initialize()` complete the initlialisation process.
`Object` | `invokeMethod(Class sender, Object object, String methodName, Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)` Invokes the given method on the object.
`Object` | `invokeStaticMethod(Object object, String methodName, Object[] arguments)` Invokes a static method on the given Object with the given name and arguments.
`protected boolean` | `isInitialized()`
`MetaMethod` | `pickMethod(String name, Class[] argTypes)` Selects a method by name and argument classes.
`Constructor` | `retrieveConstructor(Class[] arguments)`
`MetaMethod` | `retrieveStaticMethod(String methodName, Class[] arguments)`
`void` | `setAttribute(Class sender, Object object, String attribute, Object newValue, boolean useSuper, boolean fromInsideClass)` Sets the given attribute (field) on the given object
`void` | `setProperties(Object bean, Map map)` Sets a number of bean properties from the given Map where the keys are the String names of properties and the values are the values of the properties to set
`void` | `setProperty(Class sender, Object object, String name, Object newValue, boolean useSuper, boolean fromInsideClass)` Sets the property value on an object

Methods inherited from class groovy.lang.MetaClassImpl
`checkInitalised, clearInvocationCaches, dropMethodCache, dropStaticMethodCache, getAttribute, getAttribute, getClassNode, getMetaMethod, getMethodWithCaching, getProperty, getTheClass, hasProperty, invokeConstructor, invokeConstructorAt, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isModified, respondsTo, respondsTo, retrieveMethod, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setProperty, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ClosureMetaClass

    public ClosureMetaClass(MetaClassRegistry registry,
                            Class theClass)

Method Detail

### getMetaProperty

    public MetaProperty getMetaProperty(String name)

  Description copied from interface: `MetaObjectProtocol`
  Returns a MetaProperty for the given name or null if it doesn't exist

  Specified by:
    `getMetaProperty` in interface `MetaObjectProtocol`
  Overrides:
    `getMetaProperty` in class `MetaClassImpl`
  Parameters:
    `name` - The name of the MetaProperty
  Returns:
    A MetaProperty or null
  See Also:
    `MetaObjectProtocol.getMetaProperty(String)`

### invokeMethod

    public Object invokeMethod(Class sender,
                               Object object,
                               String methodName,
                               Object[] originalArguments,
                               boolean isCallToSuper,
                               boolean fromInsideClass)

  Description copied from class: `MetaClassImpl`
  Invokes the given method on the object.

  Specified by:
    `invokeMethod` in interface `MetaClass`
  Overrides:
    `invokeMethod` in class `MetaClassImpl`
  Parameters:
    `sender` - The java.lang.Class instance that invoked the method
    `object` - The object which the method was invoked on
    `methodName` - The name of the method
    `originalArguments` - The arguments to the method
    `isCallToSuper` - Whether the method is a call to a super class method
    `fromInsideClass` - Whether the call was invoked from the inside or the outside of the class
  Returns:
    The return value of the method

### initialize

    public void initialize()

  Description copied from interface: `MetaClass`
  complete the initlialisation process. After this method is called no methods should be added to the meta class. Invocation of methods or access to fields/proeprties is forbidden unless this method is called. This method should contain any initialisation code, taking a longer time to complete. An example is the creation of the Reflector. It is suggested to synchronize this method.

  Specified by:
    `initialize` in interface `MetaClass`
  Overrides:
    `initialize` in class `MetaClassImpl`

### getMethods

    public List getMethods()

  Description copied from interface: `MetaClass`
  Retrieves a list of MetaMethods held by the class

  Specified by:
    `getMethods` in interface `MetaClass`
  Specified by:
    `getMethods` in interface `MetaObjectProtocol`
  Overrides:
    `getMethods` in class `MetaClassImpl`
  Returns:
    A list of MetaMethods
  See Also:
    `MetaMethod`

### getMetaMethods

    public List getMetaMethods()

  Description copied from interface: `MetaClass`
  Retrieves a list of MetaMethod instances held by this class

  Specified by:
    `getMetaMethods` in interface `MetaClass`
  Overrides:
    `getMetaMethods` in class `MetaClassImpl`
  Returns:
    A list of MetaMethod instances

### getProperties

    public List getProperties()

  Description copied from class: `MetaClassImpl`
  Get all the properties defined for this type

  Specified by:
    `getProperties` in interface `MetaClass`
  Specified by:
    `getProperties` in interface `MetaObjectProtocol`
  Overrides:
    `getProperties` in class `MetaClassImpl`
  Returns:
    a list of MetaProperty objects
  See Also:
    `MetaProperty`

### pickMethod

    public MetaMethod pickMethod(String name,
                                 Class[] argTypes)

  Description copied from interface: `MetaClass`
  Selects a method by name and argument classes. This method does not search for an exact match, it searches for a compatible method. For this the method selection mechanism is used as provided bye the implementation of this MetaClass. pickMethod may or may not used during the method selection process when invoking a method thereis no warranty for that.

  Specified by:
    `pickMethod` in interface `MetaClass`
  Overrides:
    `pickMethod` in class `MetaClassImpl`
  Parameters:
    `name` - the name of the method to pick
    `argTypes` - the method arguments
  Returns:
    a matching MetaMethod or null

### retrieveStaticMethod

    public MetaMethod retrieveStaticMethod(String methodName,
                                           Class[] arguments)

### isInitialized

    protected boolean isInitialized()

  Overrides:
    `isInitialized` in class `MetaClassImpl`

### getStaticMetaMethod

    public MetaMethod getStaticMetaMethod(String name,
                                          Object[] args)

  Description copied from interface: `MetaObjectProtocol`
  Retreives a static MetaMethod for the given name and argument values, using the types of the arguments to establish the chosen MetaMethod

  Specified by:
    `getStaticMetaMethod` in interface `MetaObjectProtocol`
  Overrides:
    `getStaticMetaMethod` in class `MetaClassImpl`
  Parameters:
    `name` - The name of the MetaMethod
    `args` - The argument types
  Returns:
    A MetaMethod or null if it doesn't exist
  See Also:
    `MetaObjectProtocol.getStaticMetaMethod(String, Object[])`

### getStaticMetaMethod

    public MetaMethod getStaticMetaMethod(String name,
                                          Class[] argTypes)

### getProperty

    public Object getProperty(Class sender,
                              Object object,
                              String name,
                              boolean useSuper,
                              boolean fromInsideClass)

  Description copied from interface: `MetaClass`

  Retrieves a property on the given receiver for the specified arguments. The sender is the class that is requesting the property from the object. The MetaClass will attempt to establish the method to invoke based on the name and arguments provided.

  The isCallToSuper and fromInsideClass help the Groovy runtime perform optimisations on the call to go directly to the super class if necessary

  Specified by:
    `getProperty` in interface `MetaClass`
  Overrides:
    `getProperty` in class `MetaClassImpl`
  Parameters:
    `sender` - The java.lang.Class instance that requested the property
    `object` - The Object which the property is being retrieved from
    `name` - The name of the property
    `useSuper` - Whether the call is to a super class property
    `fromInsideClass` - ??
  Returns:
    the given property's value on the object

### getAttribute

    public Object getAttribute(Class sender,
                               Object object,
                               String attribute,
                               boolean useSuper,
                               boolean fromInsideClass)

  Description copied from class: `MetaClassImpl`
  Looks up the given attribute (field) on the given object

  Overrides:
    `getAttribute` in class `MetaClassImpl`

### setAttribute

    public void setAttribute(Class sender,
                             Object object,
                             String attribute,
                             Object newValue,
                             boolean useSuper,
                             boolean fromInsideClass)

  Description copied from class: `MetaClassImpl`
  Sets the given attribute (field) on the given object

  Specified by:
    `setAttribute` in interface `MetaClass`
  Overrides:
    `setAttribute` in class `MetaClassImpl`
  Parameters:
    `sender` - The class of the object that requested the attribute
    `object` - The instance
    `attribute` - The name of the attribute
    `newValue` - The value of the attribute
    `useSuper` - Whether to look-up on the super class or not
    `fromInsideClass` - Whether the call happened from the inside or the outside of a class

### invokeStaticMethod

    public Object invokeStaticMethod(Object object,
                                     String methodName,
                                     Object[] arguments)

  Description copied from interface: `MetaObjectProtocol`

  Invokes a static method on the given Object with the given name and arguments.

  The Object can either be an instance of the class that this MetaObjectProtocol instance applies to or the java.lang.Class instance itself. If a method cannot be invoked a MissingMethodException is will be thrown

  Specified by:
    `invokeStaticMethod` in interface `MetaObjectProtocol`
  Overrides:
    `invokeStaticMethod` in class `MetaClassImpl`
  Parameters:
    `object` - An instance of the class returned by the getTheClass() method or the class itself
    `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
  See Also:
    `MissingMethodException`

### setProperty

    public void setProperty(Class sender,
                            Object object,
                            String name,
                            Object newValue,
                            boolean useSuper,
                            boolean fromInsideClass)

  Description copied from class: `MetaClassImpl`
  Sets the property value on an object

  Specified by:
    `setProperty` in interface `MetaClass`
  Overrides:
    `setProperty` in class `MetaClassImpl`
  Parameters:
    `sender` - The java.lang.Class instance that is mutating the property
    `object` - The Object which the property is being set on
    `name` - The name of the property
    `newValue` - The new value of the property to set
    `useSuper` - Whether the call is to a super class property
    `fromInsideClass` - ??

### getMethodWithoutCaching

    public MetaMethod getMethodWithoutCaching(Class sender,
                                              String methodName,
                                              Class[] arguments,
                                              boolean isCallToSuper)

  Overrides:
    `getMethodWithoutCaching` in class `MetaClassImpl`

### setProperties

    public void setProperties(Object bean,
                              Map map)

  Description copied from class: `MetaClassImpl`
  Sets a number of bean properties from the given Map where the keys are the String names of properties and the values are the values of the properties to set

  Overrides:
    `setProperties` in class `MetaClassImpl`

### addMetaBeanProperty

    public void addMetaBeanProperty(MetaBeanProperty mp)

  Description copied from class: `MetaClassImpl`
  Adds a new MetaBeanProperty to this MetaClass

  Specified by:
    `addMetaBeanProperty` in interface `MutableMetaClass`
  Overrides:
    `addMetaBeanProperty` in class `MetaClassImpl`
  Parameters:
    `mp` - The MetaBeanProperty

### addMetaMethod

    public void addMetaMethod(MetaMethod method)

  Description copied from class: `MetaClassImpl`
  adds a MetaMethod to this class. WARNING: this method will not do the neccessary steps for multimethod logic and using this method doesn't mean, that a method added here is replacing another method from a parent class completely. These steps are usually done by initalize, which means if you need these steps, you have to add the method before running initialize the first time.

  Specified by:
    `addMetaMethod` in interface `MutableMetaClass`
  Overrides:
    `addMetaMethod` in class `MetaClassImpl`
  Parameters:
    `method` - the MetaMethod
  See Also:
    `MetaClassImpl.initialize()`

### addNewInstanceMethod

    public void addNewInstanceMethod(Method method)

  Description copied from interface: `MutableMetaClass`
  adds a new instance method to this MetaClass. Instance methods are able to overwrite the original methods of the class. Calling this method should not be done after initlise was called.

  Specified by:
    `addNewInstanceMethod` in interface `MutableMetaClass`
  Overrides:
    `addNewInstanceMethod` in class `MetaClassImpl`
  Parameters:
    `method` - the method to be added

### addNewStaticMethod

    public void addNewStaticMethod(Method method)

  Description copied from interface: `MutableMetaClass`
  adds a new static method to this MetaClass. This is only possible as long as initilise was not called.

  Specified by:
    `addNewStaticMethod` in interface `MutableMetaClass`
  Overrides:
    `addNewStaticMethod` in class `MetaClassImpl`
  Parameters:
    `method` - the method to be added

### retrieveConstructor

    public Constructor retrieveConstructor(Class[] arguments)

  Overrides:
    `retrieveConstructor` in class `MetaClassImpl`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright © 2003-2008 The Codehaus. All rights reserved.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD