|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroovy.lang.MetaClassImpl
org.codehaus.groovy.runtime.metaclass.ClosureMetaClass
public final class ClosureMetaClass
A meta class 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 instances 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!
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl |
|---|
MetaClassImpl.Index |
| Field Summary |
|---|
| Fields inherited from class groovy.lang.MetaClassImpl |
|---|
getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, 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. |
CallSite |
createPogoCallCurrentSite(CallSite site,
Class sender,
Object[] args)
|
CallSite |
createPogoCallSite(CallSite site,
Object[] args)
|
CallSite |
createPojoCallSite(CallSite site,
Object receiver,
Object[] args)
|
Object |
getAttribute(Class sender,
Object object,
String attribute,
boolean useSuper,
boolean fromInsideClass)
Looks up the given attribute (field) on the given object |
List<MetaMethod> |
getMetaMethods()
Retrieves a list of MetaMethods held by this class |
MetaProperty |
getMetaProperty(String name)
Returns a MetaProperty for the given name or null if it doesn't exist |
List<MetaMethod> |
getMethods()
Retrieves a list of MetaMethods held by the class |
MetaMethod |
getMethodWithoutCaching(int index,
Class sender,
String methodName,
Class[] arguments,
boolean isCallToSuper)
|
List<MetaProperty> |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ClosureMetaClass(MetaClassRegistry registry,
Class theClass)
| Method Detail |
|---|
public MetaProperty getMetaProperty(String name)
MetaObjectProtocol
getMetaProperty in interface MetaObjectProtocolgetMetaProperty in class MetaClassImplname - The name of the MetaProperty
MetaObjectProtocol.getMetaProperty(String)
public Object invokeMethod(Class sender,
Object object,
String methodName,
Object[] originalArguments,
boolean isCallToSuper,
boolean fromInsideClass)
MetaClassImpl
invokeMethod in interface MetaClassinvokeMethod in class MetaClassImplsender - The java.lang.Class instance that invoked the methodobject - The object which the method was invoked onmethodName - The name of the methodoriginalArguments - The arguments to the methodisCallToSuper - Whether the method is a call to a super class methodfromInsideClass - Whether the call was invoked from the inside or the outside of the class
public void initialize()
MetaClass
initialize in interface MetaClassinitialize in class MetaClassImplpublic List<MetaMethod> getMethods()
MetaClass
getMethods in interface MetaClassgetMethods in interface MetaObjectProtocolgetMethods in class MetaClassImplMetaMethodpublic List<MetaMethod> getMetaMethods()
MetaClass
getMetaMethods in interface MetaClassgetMetaMethods in class MetaClassImplpublic List<MetaProperty> getProperties()
MetaClassImpl
getProperties in interface MetaClassgetProperties in interface MetaObjectProtocolgetProperties in class MetaClassImplMetaProperty
public MetaMethod pickMethod(String name,
Class[] argTypes)
MetaClass
pickMethod in interface MetaClasspickMethod in class MetaClassImplname - the name of the method to pickargTypes - the method arguments
public MetaMethod retrieveStaticMethod(String methodName,
Class[] arguments)
protected boolean isInitialized()
isInitialized in class MetaClassImpl
public MetaMethod getStaticMetaMethod(String name,
Object[] args)
MetaObjectProtocol
getStaticMetaMethod in interface MetaObjectProtocolgetStaticMetaMethod in class MetaClassImplname - The name of the MetaMethodargs - The argument types
MetaObjectProtocol.getStaticMetaMethod(String, Object[])
public MetaMethod getStaticMetaMethod(String name,
Class[] argTypes)
public Object getProperty(Class sender,
Object object,
String name,
boolean useSuper,
boolean fromInsideClass)
MetaClassRetrieves 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
getProperty in interface MetaClassgetProperty in class MetaClassImplsender - The java.lang.Class instance that requested the propertyobject - The Object which the property is being retrieved fromname - The name of the propertyuseSuper - Whether the call is to a super class propertyfromInsideClass - ??
public Object getAttribute(Class sender,
Object object,
String attribute,
boolean useSuper,
boolean fromInsideClass)
MetaClassImpl
getAttribute in class MetaClassImpl
public void setAttribute(Class sender,
Object object,
String attribute,
Object newValue,
boolean useSuper,
boolean fromInsideClass)
MetaClassImpl
setAttribute in interface MetaClasssetAttribute in class MetaClassImplsender - The class of the object that requested the attributeobject - The instanceattribute - The name of the attributenewValue - The value of the attributeuseSuper - Whether to look-up on the super class or notfromInsideClass - Whether the call happened from the inside or the outside of a class
public Object invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
MetaObjectProtocolInvokes 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
invokeStaticMethod in interface MetaObjectProtocolinvokeStaticMethod in class MetaClassImplobject - An instance of the class returned by the getTheClass() method or the class itselfmethodName - The name of the methodarguments - The arguments to the method
MissingMethodException
public void setProperty(Class sender,
Object object,
String name,
Object newValue,
boolean useSuper,
boolean fromInsideClass)
MetaClassImpl
setProperty in interface MetaClasssetProperty in class MetaClassImplsender - The java.lang.Class instance that is mutating the propertyobject - The Object which the property is being set onname - The name of the propertynewValue - The new value of the property to setuseSuper - Whether the call is to a super class propertyfromInsideClass - ??
public MetaMethod getMethodWithoutCaching(int index,
Class sender,
String methodName,
Class[] arguments,
boolean isCallToSuper)
public void setProperties(Object bean,
Map map)
MetaClassImpl
setProperties in class MetaClassImplpublic void addMetaBeanProperty(MetaBeanProperty mp)
MetaClassImpl
addMetaBeanProperty in interface MutableMetaClassaddMetaBeanProperty in class MetaClassImplmp - The MetaBeanPropertypublic void addMetaMethod(MetaMethod method)
MetaClassImpl
addMetaMethod in interface MutableMetaClassaddMetaMethod in class MetaClassImplmethod - the MetaMethodMetaClassImpl.initialize()public void addNewInstanceMethod(Method method)
MutableMetaClass
addNewInstanceMethod in interface MutableMetaClassaddNewInstanceMethod in class MetaClassImplmethod - the method to be addedpublic void addNewStaticMethod(Method method)
MutableMetaClass
addNewStaticMethod in interface MutableMetaClassaddNewStaticMethod in class MetaClassImplmethod - the method to be addedpublic Constructor retrieveConstructor(Class[] arguments)
retrieveConstructor in class MetaClassImpl
public CallSite createPojoCallSite(CallSite site,
Object receiver,
Object[] args)
createPojoCallSite in class MetaClassImpl
public CallSite createPogoCallSite(CallSite site,
Object[] args)
createPogoCallSite in class MetaClassImpl
public CallSite createPogoCallCurrentSite(CallSite site,
Class sender,
Object[] args)
createPogoCallCurrentSite in class MetaClassImpl
|
Copyright © 2003-2009 The Codehaus. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||