Groovy Documentation

## groovy.lang
[Java] Class MetaClassImpl

    java.lang.Object
      groovy.lang.MetaClassImpl

All Implemented Interfaces:
  MetaClass, MutableMetaClass

    public class MetaClassImpl
    extends java.lang.Object

Allows methods to be dynamically added to existing classes at runtime

Authors:
  James Strachan
  Guillaume Laforge
  Jochen Theodorou
  Graeme Rocher
  Alex Tkachman
  Roshan Dawrani

Version:
  \$Revision\$

See Also:
  MetaClass

Nested Class Summary
`static class` | `MetaClassImpl.Index`

Field Summary
`protected static java.lang.String` | `INVOKE_METHOD_METHOD`
`protected static java.lang.String` | `METHOD_MISSING`
`protected static java.lang.String` | `PROPERTY_MISSING`
`protected static java.lang.String` | `STATIC_METHOD_MISSING`
`protected static java.lang.String` | `STATIC_PROPERTY_MISSING`
`protected MetaMethod` | `getPropertyMethod`
`protected MetaMethod` | `invokeMethodMethod`
`protected boolean` | `isGroovyObject`
`protected boolean` | `isMap`
`protected MetaMethodIndex` | `metaMethodIndex`
`protected MetaClassRegistry` | `registry`
`protected MetaMethod` | `setPropertyMethod`
`protected CachedClass` | `theCachedClass`
`protected java.lang.Class` | `theClass`

Constructor Summary
`MetaClassImpl(java.lang.Class theClass, MetaMethod[] add)`
`MetaClassImpl(java.lang.Class theClass)`
`MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass, MetaMethod[] add)`
`MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass)`

Method Summary
`void` | `addMetaBeanProperty(MetaBeanProperty mp)`
`void` | `addMetaMethod(MetaMethod method)` @return the matching method which should be found
`protected void` | `addMetaMethodToIndex(MetaMethod method, Header header)`
`void` | `addNewInstanceMethod(java.lang.reflect.Method method)`
`void` | `addNewStaticMethod(java.lang.reflect.Method method)`
`protected void` | `applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors)`
`protected void` | `checkIfGroovyObjectMethod(MetaMethod metaMethod)` Chooses the correct method to use from a list of methods which match by name.
`protected void` | `checkInitalised()` checks if the initialisation of the class id complete.
`protected java.lang.Object` | `chooseMethod(java.lang.String methodName, java.lang.Object methodOrList, java.lang.Class[] arguments)`
`protected void` | `clearInvocationCaches()`
`CallSite` | `createConstructorSite(CallSite site, java.lang.Object[] args)`
`CallSite` | `createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.Object[] args)`
`CallSite` | `createPogoCallSite(CallSite site, java.lang.Object[] args)`
`CallSite` | `createPojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args)`
`CallSite` | `createStaticSite(CallSite site, java.lang.Object[] args)`
`protected void` | `dropMethodCache(java.lang.String name)`
`protected void` | `dropStaticMethodCache(java.lang.String name)`
`protected static MetaMethod` | `findMethodInClassHierarchy(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass)`
`protected MetaMethod` | `findMixinMethod(java.lang.String methodName, java.lang.Class[] arguments)`
`protected static MetaMethod` | `findOwnMethod(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass, MetaMethod method)`
`protected MetaBeanProperty` | `findPropertyInClassHierarchy(java.lang.String propertyName, CachedClass theClass)`
`MetaMethod[]` | `getAdditionalMetaMethods()`
`java.lang.Object` | `getAttribute(java.lang.Class sender, java.lang.Object receiver, java.lang.String messageName, boolean useSuper)`
`java.lang.Object` | `getAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, boolean useSuper, boolean fromInsideClass)`
`java.lang.Object` | `getAttribute(java.lang.Object object, java.lang.String attribute)`
`ClassInfo` | `getClassInfo()`
`ClassNode` | `getClassNode()` return false: add method null: ignore method true: replace
`MetaProperty` | `getEffectiveGetMetaProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper)` todo these special cases should be special MetaClasses maybe
`MetaMethod` | `getMetaMethod(java.lang.String name, java.lang.Object[] argTypes)` @see MetaObjectProtocol#getMetaMethod(String, Object[])
`java.util.List` | `getMetaMethods()`
`MetaProperty` | `getMetaProperty(java.lang.String name)` @see MetaObjectProtocol#getMetaProperty(String)
`MetaMethod` | `getMethodWithCaching(java.lang.Class sender, java.lang.String methodName, java.lang.Object[] arguments, boolean isCallToSuper)`
`MetaMethod` | `getMethodWithoutCaching(java.lang.Class sender, java.lang.String methodName, java.lang.Class[] arguments, boolean isCallToSuper)`
`java.util.List` | `getMethods()`
`java.util.List` | `getProperties()`
`java.lang.Object` | `getProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper, boolean fromInsideClass)`
`java.lang.Object` | `getProperty(java.lang.Object object, java.lang.String property)`
`MetaClassRegistry` | `getRegistry()`
`MetaMethod` | `getStaticMetaMethod(java.lang.String name, java.lang.Object[] argTypes)` @see MetaObjectProtocol#getStaticMetaMethod(String, Object[])
`protected java.lang.Object` | `getSubclassMetaMethods(java.lang.String methodName)`
`protected java.util.LinkedList` | `getSuperClasses()`
`CachedClass` | `getTheCachedClass()`
`java.lang.Class` | `getTheClass()`
`int` | `getVersion()`
`MetaProperty` | `hasProperty(java.lang.Object obj, java.lang.String name)` @see MetaObjectProtocol#hasProperty(Object,String)
`void` | `incVersion()`
`void` | `initialize()`
`java.lang.Object` | `invokeConstructor(java.lang.Object[] arguments)`
`java.lang.Object` | `invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)`
`java.lang.Object` | `invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments)` Invokes the given method on the object.
`java.lang.Object` | `invokeMethod(java.lang.Class sender, java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments, boolean isCallToSuper, boolean fromInsideClass)`
`java.lang.Object` | `invokeMissingMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] arguments)`
`java.lang.Object` | `invokeMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)`
`java.lang.Object` | `invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)`
`protected java.lang.Object` | `invokeStaticMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)`
`boolean` | `isGroovyObject()`
`protected boolean` | `isInitialized()`
`boolean` | `isModified()`
`protected void` | `onGetPropertyFoundInHierarchy(MetaMethod method)`
`protected void` | `onInvokeMethodFoundInHierarchy(MetaMethod method)`
`protected void` | `onMixinMethodFound(MetaMethod method)`
`protected void` | `onSetPropertyFoundInHierarchy(MetaMethod method)`
`protected void` | `onSuperMethodFoundInHierarchy(MetaMethod method)`
`protected void` | `onSuperPropertyFoundInHierarchy(MetaBeanProperty property)`
`MetaMethod` | `pickMethod(java.lang.String methodName, java.lang.Class[] arguments)`
`java.util.List` | `respondsTo(java.lang.Object obj, java.lang.String name, java.lang.Object[] argTypes)` @see MetaObjectProtocol#respondsTo(Object, String, Object[])
`java.util.List` | `respondsTo(java.lang.Object obj, java.lang.String name)` @see MetaObjectProtocol#respondsTo(Object, String)
`java.lang.reflect.Constructor` | `retrieveConstructor(java.lang.Class[] arguments)`
`MetaMethod` | `retrieveStaticMethod(java.lang.String methodName, java.lang.Object[] arguments)`
`int` | `selectConstructorAndTransformArguments(int numberOfConstructors, java.lang.Object[] arguments)`
`void` | `setAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)`
`void` | `setAttribute(java.lang.Object object, java.lang.String attribute, java.lang.Object newValue)`
`void` | `setProperties(java.lang.Object bean, java.util.Map map)` @return the given property's value on the object
`void` | `setProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)`
`void` | `setProperty(java.lang.Object object, java.lang.String property, java.lang.Object newValue)`
`java.lang.String` | `toString()`

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### INVOKE_METHOD_METHOD

    protected static final java.lang.String INVOKE_METHOD_METHOD

### METHOD_MISSING

    protected static final java.lang.String METHOD_MISSING

### PROPERTY_MISSING

    protected static final java.lang.String PROPERTY_MISSING

### STATIC_METHOD_MISSING

    protected static final java.lang.String STATIC_METHOD_MISSING

### STATIC_PROPERTY_MISSING

    protected static final java.lang.String STATIC_PROPERTY_MISSING

### getPropertyMethod

    protected MetaMethod getPropertyMethod

### invokeMethodMethod

    protected MetaMethod invokeMethodMethod

### isGroovyObject

    protected final boolean isGroovyObject

### isMap

    protected final boolean isMap

### metaMethodIndex

    protected final MetaMethodIndex metaMethodIndex

### registry

    protected MetaClassRegistry registry

### setPropertyMethod

    protected MetaMethod setPropertyMethod

### theCachedClass

    protected final CachedClass theCachedClass

### theClass

    protected final java.lang.Class theClass

Constructor Detail

### MetaClassImpl

    public MetaClassImpl(java.lang.Class theClass, MetaMethod[] add)

### MetaClassImpl

    public MetaClassImpl(java.lang.Class theClass)

### MetaClassImpl

    public MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass, MetaMethod[] add)

### MetaClassImpl

    public MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass)

Method Detail

### addMetaBeanProperty

    public void addMetaBeanProperty(MetaBeanProperty mp)

### addMetaMethod

    public void addMetaMethod(MetaMethod method)

  Returns:
    the matching method which should be found

### addMetaMethodToIndex

    protected void addMetaMethodToIndex(MetaMethod method, Header header)

### addNewInstanceMethod

    public void addNewInstanceMethod(java.lang.reflect.Method method)

### addNewStaticMethod

    public void addNewStaticMethod(java.lang.reflect.Method method)

### applyPropertyDescriptors

    protected void applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors)

### checkIfGroovyObjectMethod

    protected final void checkIfGroovyObjectMethod(MetaMethod metaMethod)

  Chooses the correct method to use from a list of methods which match by name.
  Parameters:
    `methodOrList` - the possible methods to choose from
    arguments

### checkInitalised

    protected void checkInitalised()

  checks if the initialisation of the class id complete. This method should be called as a form of assert, it is no way to test if there is still initialisation work to be done. Such logic must be implemented in a different way.
  throws:
    IllegalStateException if the initialisation is incomplete yet

### chooseMethod

    protected java.lang.Object chooseMethod(java.lang.String methodName, java.lang.Object methodOrList, java.lang.Class[] arguments)

### clearInvocationCaches

    protected void clearInvocationCaches()

### createConstructorSite

    public CallSite createConstructorSite(CallSite site, java.lang.Object[] args)

### createPogoCallCurrentSite

    public CallSite createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.Object[] args)

### createPogoCallSite

    public CallSite createPogoCallSite(CallSite site, java.lang.Object[] args)

### createPojoCallSite

    public CallSite createPojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args)

### createStaticSite

    public CallSite createStaticSite(CallSite site, java.lang.Object[] args)

### dropMethodCache

    protected void dropMethodCache(java.lang.String name)

### dropStaticMethodCache

    protected void dropStaticMethodCache(java.lang.String name)

### findMethodInClassHierarchy

    protected static MetaMethod findMethodInClassHierarchy(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass)

### findMixinMethod

    protected MetaMethod findMixinMethod(java.lang.String methodName, java.lang.Class[] arguments)

### findOwnMethod

    protected static MetaMethod findOwnMethod(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass, MetaMethod method)

### findPropertyInClassHierarchy

    protected MetaBeanProperty findPropertyInClassHierarchy(java.lang.String propertyName, CachedClass theClass)

### getAdditionalMetaMethods

    public MetaMethod[] getAdditionalMetaMethods()

### getAttribute

    public java.lang.Object getAttribute(java.lang.Class sender, java.lang.Object receiver, java.lang.String messageName, boolean useSuper)

### getAttribute

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

### getAttribute

    public java.lang.Object getAttribute(java.lang.Object object, java.lang.String attribute)

### getClassInfo

    public ClassInfo getClassInfo()

### getClassNode

    public ClassNode getClassNode()

  return false: add method null: ignore method true: replace

### getEffectiveGetMetaProperty

    public MetaProperty getEffectiveGetMetaProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper)

  todo these special cases should be special MetaClasses maybe

### getMetaMethod

    public MetaMethod getMetaMethod(java.lang.String name, java.lang.Object[] argTypes)

  See Also:
    MetaObjectProtocol.getMetaMethod

### getMetaMethods

    public java.util.List getMetaMethods()

### getMetaProperty

    public MetaProperty getMetaProperty(java.lang.String name)

  See Also:
    MetaObjectProtocol.getMetaProperty

### getMethodWithCaching

    public MetaMethod getMethodWithCaching(java.lang.Class sender, java.lang.String methodName, java.lang.Object[] arguments, boolean isCallToSuper)

### getMethodWithoutCaching

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

### getMethods

    public java.util.List getMethods()

### getProperties

    public java.util.List getProperties()

### getProperty

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

### getProperty

    public java.lang.Object getProperty(java.lang.Object object, java.lang.String property)

### getRegistry

    public MetaClassRegistry getRegistry()

### getStaticMetaMethod

    public MetaMethod getStaticMetaMethod(java.lang.String name, java.lang.Object[] argTypes)

  See Also:
    MetaObjectProtocol.getStaticMetaMethod

### getSubclassMetaMethods

    protected java.lang.Object getSubclassMetaMethods(java.lang.String methodName)

### getSuperClasses

    protected java.util.LinkedList getSuperClasses()

### getTheCachedClass

    public final CachedClass getTheCachedClass()

### getTheClass

    public java.lang.Class getTheClass()

### getVersion

    public int getVersion()

### hasProperty

    public MetaProperty hasProperty(java.lang.Object obj, java.lang.String name)

  See Also:
    MetaObjectProtocol.hasProperty

### incVersion

    public void incVersion()

### initialize

    public void initialize()

### invokeConstructor

    public java.lang.Object invokeConstructor(java.lang.Object[] arguments)

### invokeMethod

    public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)

### invokeMethod

    public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments)

  Invokes the given method on the object.

### invokeMethod

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

### invokeMissingMethod

    public java.lang.Object invokeMissingMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] arguments)

### invokeMissingProperty

    public java.lang.Object invokeMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)

### invokeStaticMethod

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

### invokeStaticMissingProperty

    protected java.lang.Object invokeStaticMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)

### isGroovyObject

    public boolean isGroovyObject()

### isInitialized

    protected boolean isInitialized()

### isModified

    public boolean isModified()

### onGetPropertyFoundInHierarchy

    protected void onGetPropertyFoundInHierarchy(MetaMethod method)

### onInvokeMethodFoundInHierarchy

    protected void onInvokeMethodFoundInHierarchy(MetaMethod method)

### onMixinMethodFound

    protected void onMixinMethodFound(MetaMethod method)

### onSetPropertyFoundInHierarchy

    protected void onSetPropertyFoundInHierarchy(MetaMethod method)

### onSuperMethodFoundInHierarchy

    protected void onSuperMethodFoundInHierarchy(MetaMethod method)

### onSuperPropertyFoundInHierarchy

    protected void onSuperPropertyFoundInHierarchy(MetaBeanProperty property)

### pickMethod

    public MetaMethod pickMethod(java.lang.String methodName, java.lang.Class[] arguments)

### respondsTo

    public java.util.List respondsTo(java.lang.Object obj, java.lang.String name, java.lang.Object[] argTypes)

  See Also:
    MetaObjectProtocol.respondsTo

### respondsTo

    public java.util.List respondsTo(java.lang.Object obj, java.lang.String name)

  See Also:
    MetaObjectProtocol.respondsTo

### retrieveConstructor

    public java.lang.reflect.Constructor retrieveConstructor(java.lang.Class[] arguments)

### retrieveStaticMethod

    public MetaMethod retrieveStaticMethod(java.lang.String methodName, java.lang.Object[] arguments)

### selectConstructorAndTransformArguments

    public int selectConstructorAndTransformArguments(int numberOfConstructors, java.lang.Object[] arguments)

### setAttribute

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

### setAttribute

    public void setAttribute(java.lang.Object object, java.lang.String attribute, java.lang.Object newValue)

### setProperties

    public void setProperties(java.lang.Object bean, java.util.Map map)

  Returns:
    the given property's value on the object

### setProperty

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

### setProperty

    public void setProperty(java.lang.Object object, java.lang.String property, java.lang.Object newValue)

### toString

    public java.lang.String toString()

Groovy Documentation