|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.lang.MetaClass
public abstract class MetaClass
Base class for meta class implementations. The meta class is used to invoke methods or to get fields/properties. For proper initialization of this class it is not enough to only call the constructor, the initialize() must be called too. The invoke methods should check that initialize() was called. Adding methods is valid unless initilise method was called. Therefore addNewStaticMethod and addNewInstanceMethod should check that that initilise awas not called before.
Field Summary | |
---|---|
protected static Logger |
log
|
static Object |
NO_METHOD_FOUND
|
protected Class |
theClass
|
protected static boolean |
useReflection
|
Constructor Summary | |
---|---|
protected |
MetaClass(Class theClass)
|
Method Summary | |
---|---|
abstract void |
addNewInstanceMethod(Method method)
adds a new instance method to this meta class. |
abstract void |
addNewStaticMethod(Method method)
adds a new static method to this meta class. |
Object |
getAttribute(Class sender,
Object receiver,
String messageName,
boolean useSuper)
|
abstract Object |
getAttribute(Object object,
String attribute)
|
abstract ClassNode |
getClassNode()
|
abstract List |
getMetaMethods()
|
abstract List |
getMethods()
|
abstract List |
getProperties()
|
Object |
getProperty(Class sender,
Object receiver,
String messageName,
boolean useSuper,
boolean fromInsideClass)
|
abstract Object |
getProperty(Object object,
String property)
|
abstract void |
initialize()
complete the initlialisation process. |
abstract Object |
invokeConstructor(Object[] arguments)
|
Object |
invokeConstructorAt(Class at,
Object[] arguments)
Deprecated. |
Object |
invokeMethod(Class sender,
Object receiver,
String methodName,
Object[] arguments,
boolean isCallToSuper,
boolean fromInsideClass)
|
Object |
invokeMethod(Object object,
String methodName,
Object arguments)
|
abstract Object |
invokeMethod(Object object,
String methodName,
Object[] arguments)
|
Object |
invokeMissingMethod(Object instance,
String methodName,
Object[] arguments)
|
abstract Object |
invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
|
boolean |
isGroovyObject()
|
static boolean |
isUseReflection()
|
abstract MetaMethod |
pickMethod(String methodName,
Class[] arguments)
Deprecated. |
protected abstract MetaMethod |
retrieveMethod(String methodName,
Class[] arguments)
Deprecated. |
void |
setAttribute(Class sender,
Object receiver,
String messageName,
Object messageValue,
boolean useSuper,
boolean fromInsideClass)
|
abstract void |
setAttribute(Object object,
String attribute,
Object newValue)
|
void |
setProperty(Class sender,
Object receiver,
String messageName,
Object messageValue,
boolean useSuper,
boolean fromInsideClass)
|
abstract void |
setProperty(Object object,
String property,
Object newValue)
|
static void |
setUseReflection(boolean useReflection)
Allows reflection to be enabled in situations where bytecode generation of method invocations causes issues. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final Logger log
protected static boolean useReflection
public static final Object NO_METHOD_FOUND
protected final Class theClass
Constructor Detail |
---|
protected MetaClass(Class theClass)
Method Detail |
---|
public static boolean isUseReflection()
public static void setUseReflection(boolean useReflection)
useReflection
- public boolean isGroovyObject()
public Object invokeMissingMethod(Object instance, String methodName, Object[] arguments)
public Object invokeMethod(Object object, String methodName, Object arguments)
public Object invokeMethod(Class sender, Object receiver, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass)
public Object getProperty(Class sender, Object receiver, String messageName, boolean useSuper, boolean fromInsideClass)
public void setProperty(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)
public Object getAttribute(Class sender, Object receiver, String messageName, boolean useSuper)
public void setAttribute(Class sender, Object receiver, String messageName, Object messageValue, boolean useSuper, boolean fromInsideClass)
public abstract Object invokeConstructor(Object[] arguments)
public abstract Object invokeMethod(Object object, String methodName, Object[] arguments)
public abstract Object invokeStaticMethod(Object object, String methodName, Object[] arguments)
public abstract Object getProperty(Object object, String property)
public abstract void setProperty(Object object, String property, Object newValue)
public abstract Object getAttribute(Object object, String attribute)
public abstract void setAttribute(Object object, String attribute, Object newValue)
public abstract void addNewInstanceMethod(Method method)
method
- the method to be addedpublic abstract void addNewStaticMethod(Method method)
method
- the method to be addedpublic abstract void initialize()
public abstract List getProperties()
public abstract ClassNode getClassNode()
public abstract List getMetaMethods()
public abstract List getMethods()
public Object invokeConstructorAt(Class at, Object[] arguments)
public abstract MetaMethod pickMethod(String methodName, Class[] arguments)
protected abstract MetaMethod retrieveMethod(String methodName, Class[] arguments)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |