|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovy.lang.MetaClass
groovy.lang.MetaClassImpl
public class MetaClassImpl
Allows methods to be dynamically added to existing classes at runtime
MetaClass
Field Summary | |
---|---|
protected MetaClassRegistry |
registry
|
Fields inherited from class groovy.lang.MetaClass |
---|
log, NO_METHOD_FOUND, theClass, useReflection |
Constructor Summary | |
---|---|
MetaClassImpl(MetaClassRegistry registry,
java.lang.Class theClass)
|
Method Summary | |
---|---|
protected void |
addMetaMethod(MetaMethod method)
adds a MetaMethod to this class. |
void |
addNewInstanceMethod(java.lang.reflect.Method method)
adds a new instance method to this meta class. |
void |
addNewStaticMethod(java.lang.reflect.Method method)
adds a new static method to this meta class. |
protected void |
cacheInstanceMethod(MethodKey key,
MetaMethod method)
|
protected void |
cacheStaticMethod(MethodKey key,
MetaMethod method)
|
protected void |
checkInitalised()
checks if the initialisation of the class id complete. |
protected void |
clearInvocationCaches()
remove all method call cache entries. |
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)
Deprecated. |
ClassNode |
getClassNode()
|
java.util.List |
getMetaMethods()
|
java.util.List |
getMethods()
|
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)
|
java.lang.Object |
getProperty(java.lang.Object object,
java.lang.String property)
Deprecated. |
void |
initialize()
complete the initlialisation process. |
java.lang.Object |
invokeConstructor(java.lang.Object[] arguments)
|
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[] originalArguments)
Deprecated. |
java.lang.Object |
invokeStaticMethod(java.lang.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
|
protected boolean |
isInitialized()
|
MetaMethod |
pickMethod(java.lang.Class sender,
java.lang.String methodName,
java.lang.Class[] arguments,
boolean isCallToSuper)
pick a method in a strict manner, i.e., without reinterpreting the first List argument. |
MetaMethod |
pickMethod(java.lang.String methodName,
java.lang.Class[] arguments)
Warning, this method will be removed until 1.0 |
java.lang.reflect.Constructor |
retrieveConstructor(java.lang.Class[] arguments)
|
MetaMethod |
retrieveMethod(java.lang.Class sender,
java.lang.String methodName,
java.lang.Class[] arguments,
boolean isCallToSuper)
|
protected MetaMethod |
retrieveMethod(java.lang.String methodName,
java.lang.Class[] arguments)
Warning, this method will be removed until 1.0 |
MetaMethod |
retrieveStaticMethod(java.lang.String methodName,
java.lang.Class[] arguments)
|
int |
selectConstructorAndTransformArguments(int numberOfCosntructors,
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)
Sets the given attribute (field) on the given object |
void |
setAttribute(java.lang.Object object,
java.lang.String attribute,
java.lang.Object newValue)
Deprecated. |
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)
Deprecated. |
java.lang.String |
toString()
|
Methods inherited from class groovy.lang.MetaClass |
---|
getAttribute, invokeConstructorAt, invokeMethod, invokeMissingMethod, isGroovyObject, isUseReflection, setUseReflection |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected MetaClassRegistry registry
Constructor Detail |
---|
public MetaClassImpl(MetaClassRegistry registry, java.lang.Class theClass)
Method Detail |
---|
public void addNewInstanceMethod(java.lang.reflect.Method method)
MetaClass
addNewInstanceMethod
in class MetaClass
method
- the method to be addedpublic void addNewStaticMethod(java.lang.reflect.Method method)
MetaClass
addNewStaticMethod
in class MetaClass
method
- the method to be addedpublic java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] originalArguments)
invokeMethod
in class MetaClass
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 class MetaClass
public MetaMethod retrieveMethod(java.lang.Class sender, java.lang.String methodName, java.lang.Class[] arguments, boolean isCallToSuper)
protected void cacheInstanceMethod(MethodKey key, MetaMethod method)
protected void cacheStaticMethod(MethodKey key, MetaMethod method)
public java.lang.reflect.Constructor retrieveConstructor(java.lang.Class[] arguments)
public MetaMethod retrieveStaticMethod(java.lang.String methodName, java.lang.Class[] arguments)
public MetaMethod pickMethod(java.lang.Class sender, java.lang.String methodName, java.lang.Class[] arguments, boolean isCallToSuper)
methodName
- arguments
- public java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
invokeStaticMethod
in class MetaClass
public java.lang.Object invokeConstructor(java.lang.Object[] arguments)
invokeConstructor
in class MetaClass
public int selectConstructorAndTransformArguments(int numberOfCosntructors, java.lang.Object[] arguments)
protected void checkInitalised()
java.lang.IllegalStateException
- if the initialisation is incomplete yetpublic 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)
getProperty
in class MetaClass
public java.util.List getProperties()
getProperties
in class MetaClass
public void setProperty(java.lang.Class sender, java.lang.Object object, java.lang.String name, java.lang.Object newValue, boolean useSuper, boolean fromInsideClass)
setProperty
in class MetaClass
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 class MetaClass
public ClassNode getClassNode()
getClassNode
in class MetaClass
public java.lang.String toString()
toString
in class java.lang.Object
protected void addMetaMethod(MetaMethod method)
method
- the MetaMethodinitialize()
protected boolean isInitialized()
public void initialize()
MetaClass
initialize
in class MetaClass
public java.util.List getMethods()
getMethods
in class MetaClass
public java.util.List getMetaMethods()
getMetaMethods
in class MetaClass
public java.lang.Object getProperty(java.lang.Object object, java.lang.String property)
getProperty
in class MetaClass
public void setProperty(java.lang.Object object, java.lang.String property, java.lang.Object newValue)
setProperty
in class MetaClass
public java.lang.Object getAttribute(java.lang.Object object, java.lang.String attribute)
getAttribute
in class MetaClass
public void setAttribute(java.lang.Object object, java.lang.String attribute, java.lang.Object newValue)
setAttribute
in class MetaClass
public MetaMethod pickMethod(java.lang.String methodName, java.lang.Class[] arguments)
MetaClass
pickMethod
in class MetaClass
protected MetaMethod retrieveMethod(java.lang.String methodName, java.lang.Class[] arguments)
MetaClass
retrieveMethod
in class MetaClass
protected void clearInvocationCaches()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |