|
Groovy 1.7.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD |
interface MetaObjectProtocol
An interface that defines the API usable by clients of Groovy's Meta Object Protocol (MOP). These methods are implemented by the reference implementation of the
Method Summary | |
---|---|
Object
|
getAttribute(Object object, String attribute)
Retrieves an attribute of an instance of the class returned by the getTheClass() method. |
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 |
MetaProperty
|
getMetaProperty(String name)
Returns a MetaProperty for the given name or null if it doesn't exist |
List
|
getMethods()
Obtain a list of all the meta methods available on this meta class |
List
|
getProperties()
Obtain a list of all meta properties available on this meta class |
Object
|
getProperty(Object object, String property)
Retrieves a property of an instance of the class returned by the getTheClass() method. |
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 |
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 |
Object
|
invokeConstructor(Object[] arguments)
Invokes a constructor for the given arguments. |
Object
|
invokeMethod(Object object, String methodName, Object[] arguments)
Invokes a method on the given Object with the given name and arguments. |
Object
|
invokeMethod(Object object, String methodName, Object arguments)
Invokes a method on the given object, with the given name and single argument. |
Object
|
invokeStaticMethod(Object object, String methodName, Object[] arguments)
Invokes a static method on the given Object with the given name and arguments. |
List
|
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. |
List
|
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. |
void
|
setAttribute(Object object, String attribute, Object newValue)
Sets an attribute of an instance of the class returned by the getTheClass() method. |
void
|
setProperty(Object object, String property, Object newValue)
Sets a property of an instance of the class returned by the getTheClass() method. |
Method Detail |
---|
public Object getAttribute(Object object, String attribute)
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.
public MetaMethod getMetaMethod(String name, Object[] args)
public MetaProperty getMetaProperty(String name)
public List getMethods()
public List getProperties()
public Object getProperty(Object object, String property)
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.
public MetaMethod getStaticMetaMethod(String name, Object[] args)
public Class getTheClass()
public 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
public Object invokeConstructor(Object[] arguments)
public Object invokeMethod(Object object, String methodName, Object[] arguments)
Invokes 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.
public Object invokeMethod(Object object, String methodName, Object arguments)
Invokes a method on the given object, with the given name and single argument.
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments)
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
public List 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.
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
public List 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. 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
public void setAttribute(Object object, String attribute, Object newValue)
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.
public void setProperty(Object object, String property, Object newValue)
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.
Copyright © 2003-2009 The Codehaus. All rights reserved.