|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--groovy.lang.MetaClass
Allows methods to be dynamically added to existing classes at runtime
Field Summary | |
protected static Object[] |
ARRAY_WITH_NULL
|
protected static Object[] |
EMPTY_ARRAY
|
Constructor Summary | |
MetaClass(groovy.lang.MetaClassRegistry registry,
Class theClass)
|
Method Summary | |
protected void |
addMethods(Class theClass)
Adds all the methods declared in the given class to the metaclass ignoring any matching methods already defined by a derived class |
protected void |
addNewStaticInstanceMethod(Method method)
Allows static method definitions to be added to a meta class as if it was an instance method |
protected void |
addNewStaticMethodsFrom(Class theClass)
Adds all of the newly defined methods from the given class to this metaclass |
protected Object[] |
asArray(Object arguments)
Converts the given object into an array; if its an array then just cast otherwise wrap it in an array |
protected void |
checkForInvalidOverloading(String name,
Class[] baseTypes,
Class[] derivedTypes)
Checks that one of the parameter types is a superset of the other and that the two lists of types don't conflict. |
protected Object |
chooseEmptyMethodParams(List methods)
|
protected Object |
chooseMethod(String methodName,
List methods,
Object[] arguments)
Chooses the correct method to use from a list of methods which match by name. |
protected Object |
chooseMostGeneralMethodWith1Param(List methods)
|
protected Object |
chooseMostSpecificParams(String name,
List matchingMethods,
Object[] arguments)
|
protected boolean |
containsMatchingMethod(List list,
Method method)
|
protected Object |
createListenerProxy(Class listenerType,
String listenerMethodName,
groovy.lang.Closure closure)
|
protected Object |
doConstructorInvoke(Constructor constructor,
Object[] argumentArray)
|
protected Object |
doMethodInvoke(Object object,
Method method,
Object[] argumentArray)
|
protected Method |
findNewStaticInstanceMethod(String methodName,
Object[] staticArguments)
Lets walk the base class & interfaces list to see if we can find the method |
org.codehaus.groovy.ast.ClassNode |
getClassNode()
|
List |
getMethods(String name)
|
List |
getNewStaticInstanceMethods(String methodName)
|
protected Class[] |
getParameterTypes(Object methodOrConstructor)
|
Object |
getProperty(Object object,
String property)
|
List |
getStaticMethods(String name)
|
protected Object |
getStaticProperty(Class aClass,
String property)
|
Object |
invokeConstructor(Object[] arguments)
|
Object |
invokeMethod(Object object,
String methodName,
Object arguments)
|
Object |
invokeMethod(Object object,
String methodName,
Object[] arguments)
Invokes the given method on the object. |
Object |
invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
|
protected boolean |
isCompatibleInstance(Class type,
Object value)
|
protected boolean |
isGenericGetMethod(Method method)
|
protected boolean |
isGenericSetMethod(Method method)
|
protected void |
registerStaticMethods()
|
void |
setProperty(Object object,
String property,
Object newValue)
Sets the property value on an object |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final Object[] EMPTY_ARRAY
protected static final Object[] ARRAY_WITH_NULL
Constructor Detail |
public MetaClass(groovy.lang.MetaClassRegistry registry, Class theClass) throws IntrospectionException
Method Detail |
public List getMethods(String name)
public List getStaticMethods(String name)
protected void addNewStaticInstanceMethod(Method method)
method
- public Object invokeMethod(Object object, String methodName, Object arguments)
public Object invokeMethod(Object object, String methodName, Object[] arguments)
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments)
public Object invokeConstructor(Object[] arguments)
public List getNewStaticInstanceMethods(String methodName)
public Object getProperty(Object object, String property)
public void setProperty(Object object, String property, Object newValue)
public org.codehaus.groovy.ast.ClassNode getClassNode()
public String toString()
toString
in class Object
protected Object[] asArray(Object arguments)
protected Object createListenerProxy(Class listenerType, String listenerMethodName, groovy.lang.Closure closure)
listenerType
- the interface of the listener to proxylistenerMethodName
- the name of the method in the listener API to call the closure onclosure
- the closure to invoke on the listenerMethodName method invocation
protected void addMethods(Class theClass)
theClass
- protected boolean containsMatchingMethod(List list, Method method)
protected void addNewStaticMethodsFrom(Class theClass)
theClass
- protected Object getStaticProperty(Class aClass, String property)
protected Method findNewStaticInstanceMethod(String methodName, Object[] staticArguments)
protected Object doMethodInvoke(Object object, Method method, Object[] argumentArray)
protected Object doConstructorInvoke(Constructor constructor, Object[] argumentArray)
protected Object chooseMethod(String methodName, List methods, Object[] arguments)
methods
- the possible methods to choose fromarguments
- the original argument to the method
protected Object chooseMostSpecificParams(String name, List matchingMethods, Object[] arguments)
protected void checkForInvalidOverloading(String name, Class[] baseTypes, Class[] derivedTypes)
protected Class[] getParameterTypes(Object methodOrConstructor)
protected Object chooseMostGeneralMethodWith1Param(List methods)
protected Object chooseEmptyMethodParams(List methods)
protected boolean isCompatibleInstance(Class type, Object value)
protected boolean isGenericSetMethod(Method method)
protected boolean isGenericGetMethod(Method method)
protected void registerStaticMethods()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |