net.sf.groovydice.plugin
Class GroovyDiceAPI

java.lang.Object
  extended by net.sf.groovydice.plugin.GroovyDiceAPI
All Implemented Interfaces:
groovy.lang.GroovyObject

public class GroovyDiceAPI
extends Object
implements groovy.lang.GroovyObject

This class is responsible to modify the runtime environment and manage the dynamically added methods in order to enable them to be called from a Groovy expression.

Since:
1.3
Version:
1
Author:
Daniel F. Martins

Constructor Summary
GroovyDiceAPI()
           
 
Method Summary
 void add(Object entryMap, Object logic)
          Add a new entry to the dynamic API.
 groovy.lang.MetaClass getMetaClass()
           
 Object getMethods()
           
 Object getNumberClasses()
          Util method to get the list of number classes.
 Object getProperty(String name)
           
protected  void injectAspects()
          Inject code to enable Groovy's number classes and dice rolling commands to trigger the dynamic API lookup.
 Object invokeMethod(String name, Object args)
           
 Object isCommand(Object obj)
          Check whether the given object is a dice rolling command.
 Object isNumber(Object obj)
          Whether the given object is a number.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(String name, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroovyDiceAPI

public GroovyDiceAPI()
Method Detail

getMethods

public final Object getMethods()

add

public void add(Object entryMap,
                Object logic)
Add a new entry to the dynamic API.

Parameters:
entryMap - Map that contains information about the entry.
logic - Closure to call when the method gets invoked.

getNumberClasses

public Object getNumberClasses()
Util method to get the list of number classes.

Returns:
The list of number classes.

isCommand

public Object isCommand(Object obj)
Check whether the given object is a dice rolling command.

Parameters:
obj - Object to check.
Returns:
Whether the given object is a dice rolling command.

isNumber

public Object isNumber(Object obj)
Whether the given object is a number.

Parameters:
obj - Object to check
Returns:
Whether the given object is a number.

injectAspects

protected void injectAspects()
Inject code to enable Groovy's number classes and dice rolling commands to trigger the dynamic API lookup. This method is called during the initialization step.

See Also:
injectAspect(java.lang.Class)

getMetaClass

public groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

setMetaClass

public void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

invokeMethod

public Object invokeMethod(String name,
                           Object args)
Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public Object getProperty(String name)
Specified by:
getProperty in interface groovy.lang.GroovyObject

setProperty

public void setProperty(String name,
                        Object value)
Specified by:
setProperty in interface groovy.lang.GroovyObject


Copyright © 2008-2010 Daniel F. Martins. All Rights Reserved.