Class StandardJavaMethods
java.lang.Object
edu.tufts.hrilab.action.operators.StandardJavaMethods
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectinvokeMethod(Object o, String name, Object... args) Operator to invoke a method on an instantiated Java object with specified arguments.static ObjectinvokeStaticMethod(Class<?> clazz, String name, Object... args) Operator to invoke a static Java method with specified arguments.static ObjectOperator to instantiate a new Java object of the specified class with a variable number of arguments.
-
Constructor Details
-
StandardJavaMethods
public StandardJavaMethods()
-
-
Method Details
-
newObject
public static Object newObject(Class<?> clazz, Object... args) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, Throwable Operator to instantiate a new Java object of the specified class with a variable number of arguments.- Parameters:
clazz- class to instantiateargs- constructor arguments- Returns:
- Throws:
NoSuchMethodExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionThrowable
-
invokeMethod
public static Object invokeMethod(Object o, String name, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, Throwable Operator to invoke a method on an instantiated Java object with specified arguments. The invoked method must not be of type void.- Parameters:
o- Java object to invoke method onname- method nameargs- method arguments- Returns:
- method's return value
- Throws:
NoSuchMethodExceptionIllegalAccessExceptionInvocationTargetExceptionThrowable
-
invokeStaticMethod
public static Object invokeStaticMethod(Class<?> clazz, String name, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, Throwable Operator to invoke a static Java method with specified arguments. The invoked method must not be of type void.- Parameters:
clazz- class containing target static methodname- method nameargs- method arguments- Returns:
- method's return value
- Throws:
NoSuchMethodExceptionIllegalAccessExceptionInvocationTargetExceptionThrowable
-