|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.lang.MetaClassImpl
public class MetaClassImpl
Allows methods to be dynamically added to existing classes at runtime
MetaClass
Nested Class Summary | |
---|---|
private static class |
MetaClassImpl.DummyMetaMethod
|
private static class |
MetaClassImpl.GetBeanMethodMetaProperty
|
private static class |
MetaClassImpl.GetMethodMetaProperty
|
static class |
MetaClassImpl.Index
|
(package private) class |
MetaClassImpl.MethodIndex
|
private class |
MetaClassImpl.MethodIndexAction
|
Constructor Summary | |
---|---|
MetaClassImpl(java.lang.Class theClass)
|
|
MetaClassImpl(java.lang.Class theClass,
MetaMethod[] add)
|
|
MetaClassImpl(MetaClassRegistry registry,
java.lang.Class theClass)
|
|
MetaClassImpl(MetaClassRegistry registry,
java.lang.Class theClass,
MetaMethod[] add)
|
Method Summary | |
---|---|
private java.lang.Object |
addElementToList(java.lang.Object ret,
MetaMethod element)
|
private void |
addFields(CachedClass klass,
SingleKeyHashMap propertyIndex)
|
private void |
addInterfaceMethods(java.util.Set interfaces)
|
void |
addMetaBeanProperty(MetaBeanProperty mp)
Adds a new MetaBeanProperty to this MetaClass |
void |
addMetaMethod(MetaMethod method)
adds a MetaMethod to this class. |
protected void |
addMetaMethodToIndex(MetaMethod method,
MetaMethodIndex.Header header)
|
void |
addNewInstanceMethod(java.lang.reflect.Method method)
adds a new instance method to this MetaClass. |
private void |
addNewInstanceMethodToIndex(MetaMethod newMethod,
MetaMethodIndex.Header header)
|
void |
addNewStaticMethod(java.lang.reflect.Method method)
adds a new static method to this MetaClass. |
private void |
addNewStaticMethodToIndex(MetaMethod newMethod,
MetaMethodIndex.Header header)
|
private void |
addProperties()
|
private void |
addToAllMethodsIfPublic(MetaMethod metaMethod)
|
private void |
applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors)
|
private void |
applyStrayPropertyMethods(java.util.LinkedList superClasses,
MetaClassImpl.Index classPropertyIndex,
boolean isThis)
|
private CachedClass |
calcFirstGroovySuperClass(java.util.Collection superClasses)
|
protected void |
checkIfGroovyObjectMethod(MetaMethod metaMethod)
Checks if the metaMethod is a method from the GroovyObject interface such as setProperty, getProperty and invokeMethod |
private void |
checkIfStdMethod(MetaMethod method)
|
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)
Chooses the correct method to use from a list of methods which match by name. |
private java.lang.Object |
chooseMostSpecificParams(java.lang.String name,
java.util.List matchingMethods,
java.lang.Class[] arguments)
|
protected void |
clearInvocationCaches()
remove all method call cache entries. |
private void |
connectMultimethods(java.util.List superClasses,
CachedClass firstGroovyClass)
|
private void |
copyClassPropertyIndexForSuper(MetaClassImpl.Index dest)
|
private void |
copyNonPrivateFields(SingleKeyHashMap from,
SingleKeyHashMap to)
|
CallSite |
createConstructorSite(CallSite site,
java.lang.Object[] args)
|
private void |
createMetaBeanProperty(SingleKeyHashMap propertyIndex,
java.lang.String propName,
boolean isGetter,
MetaMethod propertyMethod)
|
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)
|
private static int |
distanceToObject(java.lang.Class c)
|
protected void |
dropMethodCache(java.lang.String name)
|
protected void |
dropStaticMethodCache(java.lang.String name)
|
private MetaProperty |
establishStaticMetaProperty(MetaProperty mp)
|
private void |
fillMethodIndex()
|
private void |
filterMatchingMethodForCategory(FastArray list,
MetaMethod method)
|
private int |
findMatchingMethod(CachedMethod[] data,
int from,
int to,
MetaMethod method)
|
private MetaMethod |
findMethod(CachedMethod aMethod)
|
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)
|
private MetaMethod |
findPropertyMethod(java.lang.Object methodOrList,
boolean isGetter)
|
private static MetaMethod |
findSubClassMethod(java.lang.Class instanceKlazz,
java.lang.String methodName,
java.lang.Class[] arguments,
MetaClass metaClass,
MetaMethod method)
|
MetaMethod[] |
getAdditionalMetaMethods()
|
java.lang.Object |
getAttribute(java.lang.Class sender,
java.lang.Object receiver,
java.lang.String messageName,
boolean useSuper)
Retrieves the value of an attribute (field). |
java.lang.Object |
getAttribute(java.lang.Class sender,
java.lang.Object object,
java.lang.String attribute,
boolean useSuper,
boolean fromInsideClass)
Looks up the given attribute (field) on the given object |
java.lang.Object |
getAttribute(java.lang.Object object,
java.lang.String attribute)
Retrieves an attribute of an instance of the class returned by the getTheClass() method. |
private MetaMethod |
getCategoryMethodGetter(java.lang.Class sender,
java.lang.String name,
boolean useLongVersion)
|
private MetaMethod |
getCategoryMethodSetter(java.lang.Class sender,
java.lang.String name,
boolean useLongVersion)
|
ClassInfo |
getClassInfo()
|
ClassNode |
getClassNode()
Obtains a reference to the original AST for the MetaClass if it is available at runtime |
MetaProperty |
getEffectiveGetMetaProperty(java.lang.Class sender,
java.lang.Object object,
java.lang.String name,
boolean useSuper)
|
private java.lang.Boolean |
getMatchKindForCategory(MetaMethod aMethod,
MetaMethod categoryMethod)
return false: add method null: ignore method true: replace |
MetaMethod |
getMetaMethod(java.lang.String name,
java.lang.Object[] argTypes)
Retrieves an instance MetaMethod for the given name and argument values, using the types of the argument values to establish the chosen MetaMethod |
java.util.List |
getMetaMethods()
Retrieves a list of MetaMethod instances held by this class |
private MetaProperty |
getMetaProperty(java.lang.Class _clazz,
java.lang.String name,
boolean useSuper,
boolean useStatic)
|
MetaProperty |
getMetaProperty(java.lang.String name)
Returns a MetaProperty for the given name or null if it doesn't exist |
private MetaProperty |
getMetaProperty(java.lang.String name,
boolean useStatic)
|
private MetaBeanProperty |
getMetaPropertyFromMutableMetaClass(java.lang.String propertyName,
MetaClass metaClass)
|
java.util.List |
getMethods()
Retrieves a list of MetaMethods held by the class |
private java.lang.Object |
getMethods(java.lang.Class sender,
java.lang.String name,
boolean isCallToSuper)
|
MetaMethod |
getMethodWithCaching(java.lang.Class sender,
java.lang.String methodName,
java.lang.Object[] arguments,
boolean isCallToSuper)
|
private MetaMethod |
getMethodWithCachingInternal(java.lang.Class sender,
CallSite site,
java.lang.Class[] params)
|
MetaMethod |
getMethodWithoutCaching(java.lang.Class sender,
java.lang.String methodName,
java.lang.Class[] arguments,
boolean isCallToSuper)
|
private MetaMethod[] |
getNewMetaMethods(CachedClass c)
|
private MetaMethod |
getNormalMethodWithCaching(java.lang.Object[] arguments,
MetaMethodIndex.Entry e)
|
java.util.List |
getProperties()
Get all the properties defined for this type |
java.lang.Object |
getProperty(java.lang.Class sender,
java.lang.Object object,
java.lang.String name,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments. |
java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String property)
Retrieves a property of an instance of the class returned by the getTheClass() method. |
private java.lang.String |
getPropName(java.lang.String methodName)
|
MetaMethod |
getStaticMetaMethod(java.lang.String name,
java.lang.Object[] argTypes)
Retreives a static MetaMethod for the given name and argument values, using the types of the arguments to establish the chosen MetaMethod |
private java.lang.Object |
getStaticMethods(java.lang.Class sender,
java.lang.String name)
|
protected java.lang.Object |
getSubclassMetaMethods(java.lang.String methodName)
|
protected java.util.LinkedList<CachedClass> |
getSuperClasses()
|
private MetaMethod |
getSuperMethodWithCaching(java.lang.Object[] arguments,
MetaMethodIndex.Entry e)
|
CachedClass |
getTheCachedClass()
|
java.lang.Class |
getTheClass()
Retrieves that Java Class that the attached Meta behaviours apply to |
int |
getVersion()
|
MetaProperty |
hasProperty(java.lang.Object obj,
java.lang.String name)
Returns true of the implementing MetaClass has a property of the given name |
void |
incVersion()
|
private void |
inheritFields(java.util.LinkedList superClasses)
|
private void |
inheritInterfaceNewMetaMethods(java.util.Set interfaces)
|
private void |
inheritStaticInterfaceFields(java.util.LinkedList superClasses,
java.util.Set interfaces)
|
void |
initialize()
complete the initlialisation process. |
private java.lang.Object |
invokeConstructor(java.lang.Class at,
java.lang.Object[] arguments)
|
java.lang.Object |
invokeConstructor(java.lang.Object[] arguments)
Invokes a constructor for the given arguments. |
java.lang.Object |
invokeConstructorAt(java.lang.Class at,
java.lang.Object[] arguments)
Deprecated. use invokeConstructor instead |
java.lang.Object |
invokeMethod(java.lang.Class sender,
java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] originalArguments,
boolean isCallToSuper,
boolean fromInsideClass)
Invokes the given method on the object. |
java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object arguments)
Invokes a method on the given object, with the given name and single argument. |
java.lang.Object |
invokeMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] originalArguments)
Invokes the given method on the object. |
private java.lang.Object |
invokeMethodOnGroovyObject(java.lang.String methodName,
java.lang.Object[] originalArguments,
java.lang.Object owner)
|
java.lang.Object |
invokeMissingMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object[] arguments)
Attempts to invoke the methodMissing method otherwise throws a MissingMethodException |
private java.lang.Object |
invokeMissingMethod(java.lang.Object instance,
java.lang.String methodName,
java.lang.Object[] arguments,
java.lang.RuntimeException original,
boolean isCallToSuper)
|
java.lang.Object |
invokeMissingProperty(java.lang.Object instance,
java.lang.String propertyName,
java.lang.Object optionalValue,
boolean isGetter)
Invokes the propertyMissing method otherwise throws a MissingPropertyException |
private java.lang.Object |
invokePropertyOrMissing(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] originalArguments,
boolean fromInsideClass,
boolean isCallToSuper)
|
private java.lang.Object |
invokeStaticClosureProperty(java.lang.Object[] originalArguments,
java.lang.Object prop)
|
java.lang.Object |
invokeStaticMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
Invokes a static method on the given Object with the given name and arguments. |
private java.lang.Object |
invokeStaticMissingMethod(java.lang.Class sender,
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)
Hook to deal with the case of MissingProperty for static properties. |
private boolean |
isBeanDerivative(java.lang.Class theClass)
|
private boolean |
isGenericGetMethod(MetaMethod method)
|
private boolean |
isGetPropertyMethod(MetaMethod metaMethod)
|
boolean |
isGroovyObject()
|
protected boolean |
isInitialized()
|
private boolean |
isInvokeMethod(MetaMethod metaMethod)
|
boolean |
isModified()
Return whether the MetaClass has been modified or not |
private boolean |
isSetPropertyMethod(MetaMethod metaMethod)
|
private MetaClass |
lookupObjectMetaClass(java.lang.Object object)
|
private void |
makeStaticPropertyIndex()
|
private static MetaMethod |
mostSpecific(MetaMethod method,
MetaMethod newMethod,
java.lang.Class instanceKlazz)
|
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)
Selects a method by name and argument classes. |
private MetaMethod |
pickStaticMethod(java.lang.String methodName,
java.lang.Class[] arguments)
|
private void |
populateMethods(java.util.LinkedList superClasses,
CachedClass firstGroovySuper)
|
private void |
removeMultimethodsOverloadedWithPrivateMethods()
|
private void |
replaceWithMOPCalls(CachedMethod[] mopMethods)
|
java.util.List |
respondsTo(java.lang.Object obj,
java.lang.String name)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of arguments. |
java.util.List |
respondsTo(java.lang.Object obj,
java.lang.String name,
java.lang.Object[] argTypes)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types. |
java.lang.reflect.Constructor |
retrieveConstructor(java.lang.Class[] arguments)
|
protected MetaMethod |
retrieveMethod(java.lang.String methodName,
java.lang.Class[] arguments)
Deprecated. use pickMethod instead |
MetaMethod |
retrieveStaticMethod(java.lang.String methodName,
java.lang.Object[] arguments)
|
private static boolean |
sameClasses(java.lang.Class[] params,
java.lang.Class[] arguments,
boolean weakNullCheck)
|
private static MetaMethod |
searchInterfacesForMetaMethod(java.lang.Class instanceKlazz,
java.lang.String methodName,
java.lang.Class[] arguments,
MetaClass metaClass)
|
private MetaBeanProperty |
searchInterfacesForMetaProperty(java.lang.String propertyName,
java.lang.Class[] interfaces)
|
int |
selectConstructorAndTransformArguments(int numberOfConstructors,
java.lang.Object[] arguments)
Internal method to support Groovy runtime. |
void |
setAttribute(java.lang.Class sender,
java.lang.Object object,
java.lang.String attribute,
java.lang.Object newValue,
boolean useSuper,
boolean fromInsideClass)
Sets the given attribute (field) on the given object |
void |
setAttribute(java.lang.Object object,
java.lang.String attribute,
java.lang.Object newValue)
Sets an attribute of an instance of the class returned by the getTheClass() method. |
void |
setProperties(java.lang.Object bean,
java.util.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(java.lang.Class sender,
java.lang.Object object,
java.lang.String name,
java.lang.Object newValue,
boolean useSuper,
boolean fromInsideClass)
Sets the property value on an object |
void |
setProperty(java.lang.Object object,
java.lang.String property,
java.lang.Object newValue)
Sets a property of an instance of the class returned by the getTheClass() method. |
private void |
setupProperties(java.beans.PropertyDescriptor[] propertyDescriptors)
This will build up the property map (Map of MetaProperty objects, keyed on property name). |
java.lang.String |
toString()
|
private MetaMethod |
tryListParamMetaMethod(java.lang.Class sender,
java.lang.String methodName,
boolean isCallToSuper,
java.lang.Object[] arguments)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String CLOSURE_CALL_METHOD
private static final java.lang.String CLOSURE_DO_CALL_METHOD
private static final java.lang.String CLOSURE_CURRY_METHOD
protected static final java.lang.String STATIC_METHOD_MISSING
protected static final java.lang.String STATIC_PROPERTY_MISSING
protected static final java.lang.String METHOD_MISSING
protected static final java.lang.String PROPERTY_MISSING
private static final java.lang.String GET_PROPERTY_METHOD
private static final java.lang.String SET_PROPERTY_METHOD
protected static final java.lang.String INVOKE_METHOD_METHOD
private static final java.lang.Class[] METHOD_MISSING_ARGS
private static final java.lang.Class[] GETTER_MISSING_ARGS
private static final java.lang.Class[] SETTER_MISSING_ARGS
protected final java.lang.Class theClass
protected final CachedClass theCachedClass
private static final MetaMethod[] EMPTY
protected MetaMethod getPropertyMethod
protected MetaMethod invokeMethodMethod
protected MetaMethod setPropertyMethod
protected MetaClassRegistry registry
protected final boolean isGroovyObject
protected final boolean isMap
private ClassNode classNode
private final MetaClassImpl.Index classPropertyIndex
private MetaClassImpl.Index classPropertyIndexForSuper
private final SingleKeyHashMap staticPropertyIndex
private final java.util.Map listeners
private FastArray constructors
private final java.util.List allMethods
private java.util.List interfaceMethods
private boolean initialized
private final MetaProperty arrayLengthProperty
private static final MetaMethod AMBIGUOUS_LISTENER_METHOD
private static final java.lang.Object[] EMPTY_ARGUMENTS
private final java.util.Set newGroovyMethodsSet
private MetaMethod genericGetMethod
private MetaMethod genericSetMethod
private MetaMethod propertyMissingGet
private MetaMethod propertyMissingSet
private static final MetaMethod NULL_METHOD
private MetaMethod methodMissing
private MetaMethodIndex.Header mainClassMethodHeader
protected final MetaMethodIndex metaMethodIndex
private final MetaMethod[] myNewMetaMethods
private final MetaMethod[] additionalMetaMethods
private static final java.util.HashMap propNames
private static final SingleKeyHashMap.Copier NAME_INDEX_COPIER
private static final SingleKeyHashMap.Copier METHOD_INDEX_COPIER
Constructor Detail |
---|
public MetaClassImpl(java.lang.Class theClass, MetaMethod[] add)
public MetaClassImpl(java.lang.Class theClass)
public MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass, MetaMethod[] add)
public MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass)
Method Detail |
---|
public final CachedClass getTheCachedClass()
public java.util.List respondsTo(java.lang.Object obj, java.lang.String name, java.lang.Object[] argTypes)
MetaObjectProtocol
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types.
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
respondsTo
in interface MetaObjectProtocol
obj
- The object to inspectname
- The name of the method of interestargTypes
- The argument types to match against
MetaObjectProtocol.respondsTo(Object, String, Object[])
public java.util.List respondsTo(java.lang.Object obj, java.lang.String name)
MetaObjectProtocol
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of arguments. In other words this method will return for foo() and foo(String).
Note that this method's return value is based on realised methods and does not take into account objects or classes that implement invokeMethod or methodMissing
This method is "safe" in that it will always return a value and never throw an exception
respondsTo
in interface MetaObjectProtocol
obj
- The object to inspectname
- The name of the method of interest
MetaObjectProtocol.respondsTo(Object, String)
public MetaProperty hasProperty(java.lang.Object obj, java.lang.String name)
MetaObjectProtocol
Returns true of the implementing MetaClass has a property of the given name
Note that this method will only return true for realised properties and does not take into account implementation of getProperty or propertyMissing
hasProperty
in interface MetaObjectProtocol
obj
- The object to inspectname
- The name of the property
MetaObjectProtocol.hasProperty(Object,String)
public MetaProperty getMetaProperty(java.lang.String name)
MetaObjectProtocol
getMetaProperty
in interface MetaObjectProtocol
name
- The name of the MetaProperty
MetaObjectProtocol.getMetaProperty(String)
public MetaMethod getStaticMetaMethod(java.lang.String name, java.lang.Object[] argTypes)
MetaObjectProtocol
getStaticMetaMethod
in interface MetaObjectProtocol
name
- The name of the MetaMethodargTypes
- The argument types
MetaObjectProtocol.getStaticMetaMethod(String, Object[])
public MetaMethod getMetaMethod(java.lang.String name, java.lang.Object[] argTypes)
MetaObjectProtocol
getMetaMethod
in interface MetaObjectProtocol
name
- The name of the MetaMethodargTypes
- The argument types
MetaObjectProtocol.getMetaMethod(String, Object[])
public java.lang.Class getTheClass()
MetaObjectProtocol
getTheClass
in interface MetaObjectProtocol
public boolean isGroovyObject()
private void fillMethodIndex()
private void populateMethods(java.util.LinkedList superClasses, CachedClass firstGroovySuper)
private MetaMethod[] getNewMetaMethods(CachedClass c)
private void addInterfaceMethods(java.util.Set interfaces)
protected java.util.LinkedList<CachedClass> getSuperClasses()
private void removeMultimethodsOverloadedWithPrivateMethods()
private void replaceWithMOPCalls(CachedMethod[] mopMethods)
private void inheritInterfaceNewMetaMethods(java.util.Set interfaces)
private void connectMultimethods(java.util.List superClasses, CachedClass firstGroovyClass)
private CachedClass calcFirstGroovySuperClass(java.util.Collection superClasses)
private java.lang.Object getMethods(java.lang.Class sender, java.lang.String name, boolean isCallToSuper)
private java.lang.Object getStaticMethods(java.lang.Class sender, java.lang.String name)
public boolean isModified()
MutableMetaClass
isModified
in interface MutableMetaClass
public void addNewInstanceMethod(java.lang.reflect.Method method)
MutableMetaClass
addNewInstanceMethod
in interface MutableMetaClass
method
- the method to be addedprivate void addNewInstanceMethodToIndex(MetaMethod newMethod, MetaMethodIndex.Header header)
public void addNewStaticMethod(java.lang.reflect.Method method)
MutableMetaClass
addNewStaticMethod
in interface MutableMetaClass
method
- the method to be addedprivate void addNewStaticMethodToIndex(MetaMethod newMethod, MetaMethodIndex.Header header)
public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object arguments)
MetaObjectProtocol
Invokes a method on the given object, with the given name and single argument.
invokeMethod
in interface MetaObjectProtocol
object
- The Object to invoke the method onmethodName
- The name of the methodarguments
- The argument to the method
MetaObjectProtocol.invokeMethod(Object, String, Object[])
public java.lang.Object invokeMissingMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] arguments)
MetaClass
Attempts to invoke the methodMissing method otherwise throws a MissingMethodException
invokeMissingMethod
in interface MetaClass
instance
- The instance to invoke methodMissing onmethodName
- The name of the methodarguments
- The arguments to the method
MissingMethodException
public java.lang.Object invokeMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)
MetaClass
invokeMissingProperty
in interface MetaClass
instance
- The instance of the classpropertyName
- The name of the propertyoptionalValue
- The value of the property which could be null in the case of a getterisGetter
- Whether the missing property event was the result of a getter or a setter
private java.lang.Object invokeMissingMethod(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] arguments, java.lang.RuntimeException original, boolean isCallToSuper)
protected void onSuperPropertyFoundInHierarchy(MetaBeanProperty property)
protected void onMixinMethodFound(MetaMethod method)
protected void onSuperMethodFoundInHierarchy(MetaMethod method)
protected void onInvokeMethodFoundInHierarchy(MetaMethod method)
protected void onSetPropertyFoundInHierarchy(MetaMethod method)
protected void onGetPropertyFoundInHierarchy(MetaMethod method)
protected java.lang.Object invokeStaticMissingProperty(java.lang.Object instance, java.lang.String propertyName, java.lang.Object optionalValue, boolean isGetter)
instance
- The instancepropertyName
- The name of the propertyoptionalValue
- The value in the case of a setterisGetter
- True if its a getter
public java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments)
invokeMethod
in interface MetaObjectProtocol
object
- The instance which the method is invoked onmethodName
- The name of the methodoriginalArguments
- The arguments to the method
MissingMethodException
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)
invokeMethod
in interface MetaClass
sender
- 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
private MetaMethod tryListParamMetaMethod(java.lang.Class sender, java.lang.String methodName, boolean isCallToSuper, java.lang.Object[] arguments)
private java.lang.Object invokePropertyOrMissing(java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments, boolean fromInsideClass, boolean isCallToSuper)
private MetaClass lookupObjectMetaClass(java.lang.Object object)
private java.lang.Object invokeMethodOnGroovyObject(java.lang.String methodName, java.lang.Object[] originalArguments, java.lang.Object owner)
public MetaMethod getMethodWithCaching(java.lang.Class sender, java.lang.String methodName, java.lang.Object[] arguments, boolean isCallToSuper)
private static boolean sameClasses(java.lang.Class[] params, java.lang.Class[] arguments, boolean weakNullCheck)
private MetaMethod getMethodWithCachingInternal(java.lang.Class sender, CallSite site, java.lang.Class[] params)
private MetaMethod getSuperMethodWithCaching(java.lang.Object[] arguments, MetaMethodIndex.Entry e)
private MetaMethod getNormalMethodWithCaching(java.lang.Object[] arguments, MetaMethodIndex.Entry e)
public java.lang.reflect.Constructor retrieveConstructor(java.lang.Class[] arguments)
public MetaMethod retrieveStaticMethod(java.lang.String methodName, java.lang.Object[] arguments)
public MetaMethod getMethodWithoutCaching(java.lang.Class sender, java.lang.String methodName, java.lang.Class[] arguments, boolean isCallToSuper)
public java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
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
invokeStaticMethod
in interface MetaObjectProtocol
object
- 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
private java.lang.Object invokeStaticClosureProperty(java.lang.Object[] originalArguments, java.lang.Object prop)
private java.lang.Object invokeStaticMissingMethod(java.lang.Class sender, java.lang.String methodName, java.lang.Object[] arguments)
private MetaMethod pickStaticMethod(java.lang.String methodName, java.lang.Class[] arguments)
public java.lang.Object invokeConstructorAt(java.lang.Class at, java.lang.Object[] arguments)
public java.lang.Object invokeConstructor(java.lang.Object[] arguments)
MetaObjectProtocol
invokeConstructor
in interface MetaObjectProtocol
arguments
- The arguments to the constructor
public int selectConstructorAndTransformArguments(int numberOfConstructors, java.lang.Object[] arguments)
MetaClass
selectConstructorAndTransformArguments
in interface MetaClass
numberOfConstructors
- The number of constructorsarguments
- The arguments
protected void checkInitalised()
java.lang.IllegalStateException
- if the initialisation is incomplete yetprivate java.lang.Object invokeConstructor(java.lang.Class at, java.lang.Object[] arguments)
public void setProperties(java.lang.Object bean, java.util.Map map)
public java.lang.Object getProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper, boolean fromInsideClass)
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
getProperty
in interface MetaClass
sender
- 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 MetaProperty getEffectiveGetMetaProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, boolean useSuper)
private MetaMethod getCategoryMethodGetter(java.lang.Class sender, java.lang.String name, boolean useLongVersion)
private MetaMethod getCategoryMethodSetter(java.lang.Class sender, java.lang.String name, boolean useLongVersion)
public java.util.List getProperties()
getProperties
in interface MetaClass
getProperties
in interface MetaObjectProtocol
MetaProperty
private MetaMethod findPropertyMethod(java.lang.Object methodOrList, boolean isGetter)
private java.lang.Object addElementToList(java.lang.Object ret, MetaMethod element)
private static int distanceToObject(java.lang.Class c)
private void setupProperties(java.beans.PropertyDescriptor[] propertyDescriptors)
private void makeStaticPropertyIndex()
private MetaProperty establishStaticMetaProperty(MetaProperty mp)
private void copyClassPropertyIndexForSuper(MetaClassImpl.Index dest)
private void inheritStaticInterfaceFields(java.util.LinkedList superClasses, java.util.Set interfaces)
private void inheritFields(java.util.LinkedList superClasses)
private void addFields(CachedClass klass, SingleKeyHashMap propertyIndex)
private void copyNonPrivateFields(SingleKeyHashMap from, SingleKeyHashMap to)
private void applyStrayPropertyMethods(java.util.LinkedList superClasses, MetaClassImpl.Index classPropertyIndex, boolean isThis)
private java.lang.String getPropName(java.lang.String methodName)
private void createMetaBeanProperty(SingleKeyHashMap propertyIndex, java.lang.String propName, boolean isGetter, MetaMethod propertyMethod)
private void applyPropertyDescriptors(java.beans.PropertyDescriptor[] propertyDescriptors)
public void addMetaBeanProperty(MetaBeanProperty mp)
addMetaBeanProperty
in interface MutableMetaClass
mp
- The MetaBeanPropertypublic void setProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
setProperty
in interface MetaClass
sender
- 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
- ??private MetaProperty getMetaProperty(java.lang.Class _clazz, java.lang.String name, boolean useSuper, boolean useStatic)
private MetaProperty getMetaProperty(java.lang.String name, boolean useStatic)
public java.lang.Object getAttribute(java.lang.Class sender, java.lang.Object receiver, java.lang.String messageName, boolean useSuper)
MetaClass
getAttribute
in interface MetaClass
sender
- The class of the object that requested the attributereceiver
- The instancemessageName
- The name of the attributeuseSuper
- Whether to look-up on the super class or not
public java.lang.Object getAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, boolean useSuper, boolean fromInsideClass)
public void setAttribute(java.lang.Class sender, java.lang.Object object, java.lang.String attribute, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
setAttribute
in interface MetaClass
sender
- 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 classpublic ClassNode getClassNode()
MetaClass
getClassNode
in interface MetaClass
public java.lang.String toString()
toString
in class java.lang.Object
public void addMetaMethod(MetaMethod method)
addMetaMethod
in interface MutableMetaClass
method
- the MetaMethodinitialize()
protected void addMetaMethodToIndex(MetaMethod method, MetaMethodIndex.Header header)
protected final void checkIfGroovyObjectMethod(MetaMethod metaMethod)
metaMethod
- The metaMethod instanceGroovyObject
private boolean isSetPropertyMethod(MetaMethod metaMethod)
private boolean isGetPropertyMethod(MetaMethod metaMethod)
private boolean isInvokeMethod(MetaMethod metaMethod)
private void checkIfStdMethod(MetaMethod method)
protected boolean isInitialized()
private java.lang.Boolean getMatchKindForCategory(MetaMethod aMethod, MetaMethod categoryMethod)
private void filterMatchingMethodForCategory(FastArray list, MetaMethod method)
private int findMatchingMethod(CachedMethod[] data, int from, int to, MetaMethod method)
private MetaMethod findMethod(CachedMethod aMethod)
protected java.lang.Object chooseMethod(java.lang.String methodName, java.lang.Object methodOrList, java.lang.Class[] arguments)
methodOrList
- the possible methods to choose fromarguments
- private java.lang.Object chooseMostSpecificParams(java.lang.String name, java.util.List matchingMethods, java.lang.Class[] arguments)
private boolean isGenericGetMethod(MetaMethod method)
public void initialize()
MetaClass
initialize
in interface MetaClass
private void addProperties()
private boolean isBeanDerivative(java.lang.Class theClass)
private void addToAllMethodsIfPublic(MetaMethod metaMethod)
public java.util.List getMethods()
MetaClass
getMethods
in interface MetaClass
getMethods
in interface MetaObjectProtocol
MetaMethod
public java.util.List getMetaMethods()
MetaClass
getMetaMethods
in interface MetaClass
protected void dropStaticMethodCache(java.lang.String name)
protected void dropMethodCache(java.lang.String name)
public CallSite createPojoCallSite(CallSite site, java.lang.Object receiver, java.lang.Object[] args)
public CallSite createStaticSite(CallSite site, java.lang.Object[] args)
public CallSite createPogoCallSite(CallSite site, java.lang.Object[] args)
public CallSite createPogoCallCurrentSite(CallSite site, java.lang.Class sender, java.lang.Object[] args)
public CallSite createConstructorSite(CallSite site, java.lang.Object[] args)
public ClassInfo getClassInfo()
public int getVersion()
public void incVersion()
public MetaMethod[] getAdditionalMetaMethods()
protected MetaBeanProperty findPropertyInClassHierarchy(java.lang.String propertyName, CachedClass theClass)
private MetaBeanProperty searchInterfacesForMetaProperty(java.lang.String propertyName, java.lang.Class[] interfaces)
private MetaBeanProperty getMetaPropertyFromMutableMetaClass(java.lang.String propertyName, MetaClass metaClass)
protected MetaMethod findMixinMethod(java.lang.String methodName, java.lang.Class[] arguments)
protected static MetaMethod findMethodInClassHierarchy(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass)
private static MetaMethod findSubClassMethod(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass, MetaMethod method)
private static MetaMethod mostSpecific(MetaMethod method, MetaMethod newMethod, java.lang.Class instanceKlazz)
private static MetaMethod searchInterfacesForMetaMethod(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass)
protected static MetaMethod findOwnMethod(java.lang.Class instanceKlazz, java.lang.String methodName, java.lang.Class[] arguments, MetaClass metaClass, MetaMethod method)
protected java.lang.Object getSubclassMetaMethods(java.lang.String methodName)
public java.lang.Object getProperty(java.lang.Object object, java.lang.String property)
MetaObjectProtocol
Retrieves a property of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean getter, or if no such getter exists a public field of the instance.
getProperty
in interface MetaObjectProtocol
object
- An instance of the class returned by the getTheClass() methodproperty
- The name of the property to retrieve the value for
MetaClassImpl
public void setProperty(java.lang.Object object, java.lang.String property, java.lang.Object newValue)
MetaObjectProtocol
Sets a property of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to invoke a JavaBean setter, or if no such setter exists to set a public field of the instance.
setProperty
in interface MetaObjectProtocol
object
- An instance of the class returned by the getTheClass() methodproperty
- The name of the property to setnewValue
- The new value of the propertyMetaClassImpl
public java.lang.Object getAttribute(java.lang.Object object, java.lang.String attribute)
MetaObjectProtocol
Retrieves an attribute of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in attempt to read a field of the instance.
getAttribute
in interface MetaObjectProtocol
object
- An instance of the class returned by the getTheClass() methodattribute
- The name of the attribute to retrieve the value for
MetaClassImpl
public void setAttribute(java.lang.Object object, java.lang.String attribute, java.lang.Object newValue)
MetaObjectProtocol
Sets an attribute of an instance of the class returned by the getTheClass() method.
What this means is largely down to the MetaClass implementation, however the default case would result in an attempt to set a field of the instance.
setAttribute
in interface MetaObjectProtocol
object
- An instance of the class returned by the getTheClass() methodattribute
- The name of the attribute to setnewValue
- The new value of the attributeMetaClassImpl
public MetaMethod pickMethod(java.lang.String methodName, java.lang.Class[] arguments)
MetaClass
pickMethod
in interface MetaClass
methodName
- the name of the method to pickarguments
- the method arguments
protected MetaMethod retrieveMethod(java.lang.String methodName, java.lang.Class[] arguments)
protected void clearInvocationCaches()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |