|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.runtime.Invoker
A helper class to invoke methods or extract properties on arbitrary Java objects dynamically
Field Summary | |
protected static Object[] |
EMPTY_ARGUMENTS
|
protected static Class[] |
EMPTY_TYPES
|
Constructor Summary | |
Invoker()
|
Method Summary | |
Object[] |
asArray(Object arguments)
Converts the given object into an array; if its an array then just cast otherwise wrap it in an array |
boolean |
asBool(Object object)
|
protected Character |
asCharacter(Number value)
|
protected Character |
asCharacter(String text)
|
Collection |
asCollection(Object value)
|
int |
asInt(Object value)
|
Iterator |
asIterator(Object value)
|
List |
asList(Object value)
|
Number |
asNumber(Object value)
|
Object |
asType(Object object,
Class type)
|
int |
compareTo(Object left,
Object right)
Compares the two objects handling nulls gracefully and performing numeric type coercion if required |
protected String |
format(Object arguments,
boolean verbose)
|
groovy.lang.MetaClass |
getMetaClass(Object object)
|
groovy.lang.MetaClassRegistry |
getMetaRegistry()
|
Object |
getProperty(Object object,
String property)
Looks up the given property of the given object |
String |
inspect(Object self)
|
Object |
invokeConstructor(String type,
Object arguments)
|
Object |
invokeConstructorOf(Class type,
Object arguments)
|
Object |
invokeMethod(Object object,
String methodName,
Object arguments)
Invokes the given method on the object. |
Object |
invokeStaticMethod(String type,
String method,
Object arguments)
|
Object |
invokeSuperMethod(Object object,
String methodName,
Object arguments)
|
protected boolean |
isValidCharacterString(Object value)
|
protected Class |
loadClass(String type)
Attempts to load the given class via name using the current class loader for this code or the thread context class loader |
Matcher |
objectFindRegex(Object left,
Object right)
Find the right hand regex within the left hand string and return a matcher. |
boolean |
objectMatchRegex(Object left,
Object right)
Find the right hand regex within the left hand string and return a matcher. |
boolean |
objectsEqual(Object left,
Object right)
|
Pattern |
regexPattern(Object regex)
Compile a regular expression from a string. |
void |
setProperty(Object object,
String property,
Object newValue)
Sets the property on the given object |
String |
toString(Object arguments)
A helper method to provide some better toString() behaviour such as turning arrays into tuples |
String |
toTypeString(Object[] arguments)
A helper method to format the arguments types as a comma-separated list |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Object[] EMPTY_ARGUMENTS
protected static final Class[] EMPTY_TYPES
Constructor Detail |
public Invoker()
Method Detail |
public groovy.lang.MetaClassRegistry getMetaRegistry()
public groovy.lang.MetaClass getMetaClass(Object object)
public Object invokeMethod(Object object, String methodName, Object arguments)
object
- methodName
- arguments
-
public Object invokeSuperMethod(Object object, String methodName, Object arguments)
public Object invokeStaticMethod(String type, String method, Object arguments)
public Object invokeConstructor(String type, Object arguments)
public Object invokeConstructorOf(Class type, Object arguments)
public Object[] asArray(Object arguments)
public List asList(Object value)
public Collection asCollection(Object value)
public Iterator asIterator(Object value)
public boolean objectsEqual(Object left, Object right)
public String inspect(Object self)
public int compareTo(Object left, Object right)
public String toString(Object arguments)
public String toTypeString(Object[] arguments)
protected String format(Object arguments, boolean verbose)
public void setProperty(Object object, String property, Object newValue)
object
- property
- newValue
-
public Object getProperty(Object object, String property)
object
- property
-
public int asInt(Object value)
public Number asNumber(Object value)
protected Class loadClass(String type)
public Matcher objectFindRegex(Object left, Object right)
left
- string to compareright
- regular expression to compare the string to
public boolean objectMatchRegex(Object left, Object right)
left
- string to compareright
- regular expression to compare the string to
public Pattern regexPattern(Object regex)
regex
-
public Object asType(Object object, Class type)
public boolean asBool(Object object)
protected Character asCharacter(Number value)
protected Character asCharacter(String text)
protected boolean isValidCharacterString(Object value)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |