Package weka.core.scripting
Class Groovy
java.lang.Object
weka.core.scripting.Groovy
- All Implemented Interfaces:
Serializable
,RevisionHandler
A helper class for Groovy.
In order to use Groovy, the jar containing all the classes must be present in
the CLASSPATH. This jar is normally found in the embeddable
sub-directory of the Groovy installation.
Tested with Groovy 1.5.7.
- Version:
- $Revision: 13692 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionreturns the currently used Groovy classloader.Returns the revision string.static Object
executes the specified method and returns the result, if any.executes the specified method on the current interpreter and returns the result, if any.static boolean
returns whether the Groovy classes are present or not, i.e.static void
If no arguments are given, it just prints the presence of the Groovy classes, otherwise it expects a Groovy filename to execute.static Object
initializes and returns a Groovy Interpreter.static Object
newInstance
(File file, Class<?> template) loads the module and returns a new instance of it as instance of the provided Java class template.
-
Field Details
-
CLASS_GROOVYCLASSLOADER
the classname of the Groovy classloader.- See Also:
-
-
Constructor Details
-
Groovy
public Groovy()default constructor, tries to instantiate a Groovy classloader.
-
-
Method Details
-
getClassLoader
returns the currently used Groovy classloader.- Returns:
- the classloader, can be null
-
invoke
executes the specified method on the current interpreter and returns the result, if any.- Parameters:
methodName
- the name of the methodparamClasses
- the classes of the parametersparamValues
- the values of the parameters- Returns:
- the return value of the method, if any (in that case null)
-
isPresent
public static boolean isPresent()returns whether the Groovy classes are present or not, i.e. whether the classes are in the classpath or not- Returns:
- whether the Groovy classes are available
-
newClassLoader
initializes and returns a Groovy Interpreter.- Returns:
- the interpreter or null if Groovy classes not present
-
newInstance
loads the module and returns a new instance of it as instance of the provided Java class template.- Parameters:
file
- the Groovy module filetemplate
- the template for the returned Java object- Returns:
- the Groovy object
-
invoke
public static Object invoke(Object o, String methodName, Class<?>[] paramClasses, Object[] paramValues) executes the specified method and returns the result, if any.- Parameters:
o
- the object the method should be called from, e.g., a Groovy InterpretermethodName
- the name of the methodparamClasses
- the classes of the parametersparamValues
- the values of the parameters- Returns:
- the return value of the method, if any (in that case null)
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-
main
If no arguments are given, it just prints the presence of the Groovy classes, otherwise it expects a Groovy filename to execute.- Parameters:
args
- commandline arguments
-