|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroovy.lang.DelegatingMetaClass
public class DelegatingMetaClass
| Field Summary | |
|---|---|
protected MetaClass |
delegate
|
| Constructor Summary | |
|---|---|
DelegatingMetaClass(Class theClass)
|
|
DelegatingMetaClass(MetaClass delegate)
|
|
| Method Summary | |
|---|---|
void |
addMetaBeanProperty(MetaBeanProperty metaBeanProperty)
Adds a new MetaBeanProperty to the MetaClass |
void |
addMetaMethod(MetaMethod metaMethod)
Adds a new MetaMethod to the MetaClass |
void |
addNewInstanceMethod(Method method)
adds a new instance method to this MetaClass. |
void |
addNewStaticMethod(Method method)
adds a new static method to this MetaClass. |
boolean |
equals(Object obj)
|
MetaClass |
getAdaptee()
|
Object |
getAttribute(Class sender,
Object receiver,
String messageName,
boolean useSuper)
Retrieves the value of an attribute (field). |
Object |
getAttribute(Object object,
String attribute)
Retrieves an attribute of an instance of the class returned by the getTheClass() method. |
ClassNode |
getClassNode()
Obtains a reference to the original AST for the MetaClass if it is available at runtime |
MetaClass |
getMetaClass()
Returns the metaclass for a given class. |
MetaMethod |
getMetaMethod(String name,
Object[] args)
Retrieves an instance MetaMethod for the given name and argument values, using the types of the argument values to establish the chosen MetaMethod |
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 |
List<MetaProperty> |
getProperties()
Retrives a list of MetaProperty instances that the MetaClass has |
Object |
getProperty(Class sender,
Object receiver,
String messageName,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments. |
Object |
getProperty(Object object,
String property)
Retrieves a property of an instance of the class returned by the getTheClass() method. |
Object |
getProperty(String property)
Retrieves a property value. |
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 |
Class |
getTheClass()
Retrieves that Java Class that the attached Meta behaviours apply to |
int |
hashCode()
|
MetaProperty |
hasProperty(Object obj,
String name)
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 |
void |
initialize()
complete the initlialisation process. |
Object |
invokeConstructor(Object[] arguments)
Invokes a constructor for the given arguments. |
Object |
invokeMethod(Class sender,
Object receiver,
String methodName,
Object[] arguments,
boolean isCallToSuper,
boolean fromInsideClass)
Invokes a method on the given receiver for the specified arguments. |
Object |
invokeMethod(Object object,
String methodName,
Object arguments)
Invokes a method on the given object, with the given name and single argument. |
Object |
invokeMethod(Object object,
String methodName,
Object[] arguments)
Invokes a method on the given Object with the given name and arguments. |
Object |
invokeMethod(String name,
Object args)
Invokes the given method. |
Object |
invokeMissingMethod(Object instance,
String methodName,
Object[] arguments)
Attempts to invoke the methodMissing method otherwise throws a MissingMethodException |
Object |
invokeMissingProperty(Object instance,
String propertyName,
Object optionalValue,
boolean isGetter)
Invokes the propertyMissing method otherwise throws a MissingPropertyException |
Object |
invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
Invokes a static method on the given Object with the given name and arguments. |
boolean |
isGroovyObject()
|
boolean |
isModified()
Return whether the MetaClass has been modified or not |
MetaMethod |
pickMethod(String methodName,
Class[] arguments)
Deprecated. |
List<MetaMethod> |
respondsTo(Object obj,
String name)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name regardless of arguments. |
List<MetaMethod> |
respondsTo(Object obj,
String name,
Object[] argTypes)
Returns an object satisfying Groovy truth if the implementing MetaClass responds to a method with the given name and arguments types. |
int |
selectConstructorAndTransformArguments(int numberOfConstructors,
Object[] arguments)
Internal method to support Groovy runtime. |
void |
setAdaptee(MetaClass adaptee)
|
void |
setAttribute(Class sender,
Object receiver,
String messageName,
Object messageValue,
boolean useSuper,
boolean fromInsideClass)
Sets the value of an attribute (field). |
void |
setAttribute(Object object,
String attribute,
Object newValue)
Sets an attribute of an instance of the class returned by the getTheClass() method. |
void |
setMetaClass(MetaClass metaClass)
Allows the MetaClass to be replaced with a derived implementation. |
void |
setProperty(Class sender,
Object receiver,
String messageName,
Object messageValue,
boolean useSuper,
boolean fromInsideClass)
Retrieves a property on the given receiver for the specified arguments. |
void |
setProperty(Object object,
String property,
Object newValue)
Sets a property of an instance of the class returned by the getTheClass() method. |
void |
setProperty(String property,
Object newValue)
Sets the given property to the new value. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected MetaClass delegate
| Constructor Detail |
|---|
public DelegatingMetaClass(MetaClass delegate)
public DelegatingMetaClass(Class theClass)
| Method Detail |
|---|
public boolean isModified()
MutableMetaClass
isModified in interface MutableMetaClasspublic void addNewInstanceMethod(Method method)
MutableMetaClass
addNewInstanceMethod in interface MutableMetaClassmethod - the method to be addedpublic void addNewStaticMethod(Method method)
MutableMetaClass
addNewStaticMethod in interface MutableMetaClassmethod - the method to be addedpublic void addMetaMethod(MetaMethod metaMethod)
MutableMetaClass
addMetaMethod in interface MutableMetaClassmetaMethod - The MetaMethod to addpublic void addMetaBeanProperty(MetaBeanProperty metaBeanProperty)
MutableMetaClass
addMetaBeanProperty in interface MutableMetaClassmetaBeanProperty - The MetaBeanProperty instancepublic void initialize()
MetaClass
initialize in interface MetaClass
public Object getAttribute(Object object,
String attribute)
MetaObjectProtocolRetrieves 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 MetaObjectProtocolobject - An instance of the class returned by the getTheClass() methodattribute - The name of the attribute to retrieve the value for
MetaClassImplpublic ClassNode getClassNode()
MetaClass
getClassNode in interface MetaClasspublic List<MetaMethod> getMetaMethods()
MetaClass
getMetaMethods in interface MetaClasspublic List<MetaMethod> getMethods()
MetaClass
getMethods in interface MetaClassgetMethods in interface MetaObjectProtocolMetaMethod
public List<MetaMethod> respondsTo(Object obj,
String name,
Object[] argTypes)
MetaObjectProtocolReturns 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 MetaObjectProtocolobj - The object to inspectname - The name of the method of interestargTypes - The argument types to match against
public List<MetaMethod> respondsTo(Object obj,
String name)
MetaObjectProtocolReturns 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 MetaObjectProtocolobj - The object to inspectname - The name of the method of interest
public MetaProperty hasProperty(Object obj,
String name)
MetaObjectProtocolReturns 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 MetaObjectProtocolobj - The object to inspectname - The name of the property
public List<MetaProperty> getProperties()
MetaClass
getProperties in interface MetaClassgetProperties in interface MetaObjectProtocolMetaProperty
public Object getProperty(Object object,
String property)
MetaObjectProtocolRetrieves 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 MetaObjectProtocolobject - An instance of the class returned by the getTheClass() methodproperty - The name of the property to retrieve the value for
MetaClassImplpublic Object invokeConstructor(Object[] arguments)
MetaObjectProtocol
invokeConstructor in interface MetaObjectProtocolarguments - The arguments to the constructor
public Object invokeMethod(Object object,
String methodName,
Object arguments)
MetaObjectProtocolInvokes a method on the given object, with the given name and single argument.
invokeMethod in interface MetaObjectProtocolobject - The Object to invoke the method onmethodName - The name of the methodarguments - The argument to the method
MetaObjectProtocol.invokeMethod(Object, String, Object[])
public Object invokeMethod(Object object,
String methodName,
Object[] arguments)
MetaObjectProtocolInvokes a method on the given Object with the given name and arguments. The MetaClass will attempt to pick the best method for the given name and arguments. If a method cannot be invoked a MissingMethodException will be thrown.
invokeMethod in interface MetaObjectProtocolobject - The instance which the method is invoked onmethodName - The name of the methodarguments - The arguments to the method
MissingMethodException
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 MetaObjectProtocolobject - 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 setAttribute(Object object,
String attribute,
Object newValue)
MetaObjectProtocolSets 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 MetaObjectProtocolobject - An instance of the class returned by the getTheClass() methodattribute - The name of the attribute to setnewValue - The new value of the attributeMetaClassImpl
public void setProperty(Object object,
String property,
Object newValue)
MetaObjectProtocolSets 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 MetaObjectProtocolobject - An instance of the class returned by the getTheClass() methodproperty - The name of the property to setnewValue - The new value of the propertyMetaClassImplpublic boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic String toString()
toString in class Object
public MetaMethod pickMethod(String methodName,
Class[] arguments)
MetaClass
pickMethod in interface MetaClassmethodName - the name of the method to pickarguments - the method arguments
public Object getAttribute(Class sender,
Object receiver,
String messageName,
boolean useSuper)
MetaClass
getAttribute in interface MetaClasssender - 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 Object getProperty(Class sender,
Object receiver,
String messageName,
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 MetaClasssender - The java.lang.Class instance that requested the propertyreceiver - The Object which the property is being retrieved frommessageName - The name of the propertyuseSuper - Whether the call is to a super class propertyfromInsideClass - ??
public MetaProperty getMetaProperty(String name)
MetaObjectProtocol
getMetaProperty in interface MetaObjectProtocolname - The name of the MetaProperty
public MetaMethod getStaticMetaMethod(String name,
Object[] args)
MetaObjectProtocol
getStaticMetaMethod in interface MetaObjectProtocolname - The name of the MetaMethodargs - The argument types
public MetaMethod getStaticMetaMethod(String name,
Class[] argTypes)
public MetaMethod getMetaMethod(String name,
Object[] args)
MetaObjectProtocol
getMetaMethod in interface MetaObjectProtocolname - The name of the MetaMethodargs - The argument types
public Class getTheClass()
MetaObjectProtocol
getTheClass in interface MetaObjectProtocol
public Object invokeMethod(Class sender,
Object receiver,
String methodName,
Object[] arguments,
boolean isCallToSuper,
boolean fromInsideClass)
MetaClassInvokes a method on the given receiver for the specified arguments. The sender is the class that invoked the method on 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
invokeMethod in interface MetaClasssender - The java.lang.Class instance that invoked the methodreceiver - The object which the method was invoked onmethodName - The name of the methodarguments - 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 Object invokeMissingMethod(Object instance,
String methodName,
Object[] arguments)
MetaClassAttempts to invoke the methodMissing method otherwise throws a MissingMethodException
invokeMissingMethod in interface MetaClassinstance - The instance to invoke methodMissing onmethodName - The name of the methodarguments - The arguments to the method
MissingMethodException
public Object invokeMissingProperty(Object instance,
String propertyName,
Object optionalValue,
boolean isGetter)
MetaClass
invokeMissingProperty in interface MetaClassinstance - 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
public boolean isGroovyObject()
public void setAttribute(Class sender,
Object receiver,
String messageName,
Object messageValue,
boolean useSuper,
boolean fromInsideClass)
MetaClass
setAttribute in interface MetaClasssender - The class of the object that requested the attributereceiver - The instancemessageName - The name of the attributemessageValue - 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 void setProperty(Class sender,
Object receiver,
String messageName,
Object messageValue,
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
setProperty in interface MetaClasssender - The java.lang.Class instance that is mutating the propertyreceiver - The Object which the property is being set onmessageName - The name of the propertymessageValue - The new value of the property to setuseSuper - Whether the call is to a super class propertyfromInsideClass - ??
public int selectConstructorAndTransformArguments(int numberOfConstructors,
Object[] arguments)
MetaClass
selectConstructorAndTransformArguments in interface MetaClassnumberOfConstructors - The number of constructorsarguments - The arguments
public void setAdaptee(MetaClass adaptee)
public MetaClass getAdaptee()
public Object invokeMethod(String name,
Object args)
GroovyObject
invokeMethod in interface GroovyObjectname - the name of the method to callargs - the arguments to use for the method call
public Object getProperty(String property)
GroovyObject
getProperty in interface GroovyObjectproperty - the name of the property of interest
public void setProperty(String property,
Object newValue)
GroovyObject
setProperty in interface GroovyObjectproperty - the name of the property of interestnewValue - the new value for the propertypublic MetaClass getMetaClass()
GroovyObject
getMetaClass in interface GroovyObjectpublic void setMetaClass(MetaClass metaClass)
GroovyObject
setMetaClass in interface GroovyObjectmetaClass - the new metaclass
|
Copyright © 2003-2009 The Codehaus. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||