net.xoetrope.optional.evaluator
Class XGroovyEvaluator

java.lang.Object
  extended by net.xoetrope.optional.evaluator.XGroovyEvaluator
All Implemented Interfaces:
XAttributeEvaluator

public class XGroovyEvaluator
extends java.lang.Object
implements XAttributeEvaluator

An attribute evaluator

Copyright (c) Xoetrope Ltd., 2002-2004

$Revision: 2.2 $

License: see License.txt


Field Summary
protected  XExceptionHandler exceptionHandler
           
protected  groovy.lang.GroovyShell groovyShell
           
protected  java.util.Hashtable referenceObjects
           
protected  java.lang.Object result
           
 
Constructor Summary
XGroovyEvaluator()
           
 
Method Summary
 java.lang.Object evaluateAttribute(java.lang.Object instance, java.lang.String attributeValue)
          Get the value of an attribute.
 XMethodReference getMethodReference(java.lang.Object instance, java.lang.String attributeValue)
          Get the value of an attribute by evaluating a method reference
 XMethodReference getMethodReference(java.lang.String attributeValue)
          Get the value of an attribute by evaluating a method reference
 java.lang.Object getResult()
          Explicitly get the result of an evaluation.
 void setCurrentProject(XProject currentProject)
          Set the current project and complete any initialization that depends on the project reference/instance.
 void setExceptionHandler(XExceptionHandler eh)
          Set an exception handler for processing exceptions
 void setResult(java.lang.Object value)
          Explicitly set the result of an evaluation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

referenceObjects

protected java.util.Hashtable referenceObjects

groovyShell

protected groovy.lang.GroovyShell groovyShell

exceptionHandler

protected XExceptionHandler exceptionHandler

result

protected java.lang.Object result
Constructor Detail

XGroovyEvaluator

public XGroovyEvaluator()
Method Detail

setCurrentProject

public void setCurrentProject(XProject currentProject)
Set the current project and complete any initialization that depends on the project reference/instance.

Specified by:
setCurrentProject in interface XAttributeEvaluator
Parameters:
project - the current or owning project

evaluateAttribute

public java.lang.Object evaluateAttribute(java.lang.Object instance,
                                          java.lang.String attributeValue)
Get the value of an attribute.

Specified by:
evaluateAttribute in interface XAttributeEvaluator
Parameters:
instance - the page being loaded
attributeValue - the raw value of the attribute
Returns:
the evaluated value of the attribute

getMethodReference

public XMethodReference getMethodReference(java.lang.String attributeValue)
Get the value of an attribute by evaluating a method reference

Specified by:
getMethodReference in interface XAttributeEvaluator
Parameters:
attributeValue - the method name
Returns:
the method reference or null if the referenced/named method cannot be found

getMethodReference

public XMethodReference getMethodReference(java.lang.Object instance,
                                           java.lang.String attributeValue)
Get the value of an attribute by evaluating a method reference

Specified by:
getMethodReference in interface XAttributeEvaluator
Parameters:
instance - the current page or object that provides the methods or fields used in the evaluation
attributeValue - the method name
Returns:
the method reference or null if the referenced/named method cannot be found

setExceptionHandler

public void setExceptionHandler(XExceptionHandler eh)
Set an exception handler for processing exceptions

Specified by:
setExceptionHandler in interface XAttributeEvaluator
Parameters:
eh - the exception handler

setResult

public void setResult(java.lang.Object value)
Explicitly set the result of an evaluation. This method may be used by an exception handler to override the result and set a sensible value in case of an exception

Specified by:
setResult in interface XAttributeEvaluator
Parameters:
the - new result value

getResult

public java.lang.Object getResult()
Explicitly get the result of an evaluation. This method may be used by an exception handler to determine the result and set a sensible value in case of an exception

Specified by:
getResult in interface XAttributeEvaluator
Returns:
the current/intermediate result value