incubator.net.xoetrope.scripts
Class ScriptAttributeEvaluator

java.lang.Object
  extended by incubator.net.xoetrope.scripts.ScriptAttributeEvaluator
All Implemented Interfaces:
XAttributeEvaluator

public class ScriptAttributeEvaluator
extends java.lang.Object

    
implements XAttributeEvaluator

    

Evaluates a script attribute by passing the scripts following the prefix 'script:' to the ScriptEngine. The scripts can be an a function that was predifined in the page Scripts tag or a script that is just being defined. eg. script:myFunction(); given that myFunction was define in the page Scripts tag. eg. script:out.println('Hello World'); the script is just being defined.


Field Summary
protected  java.util.Hashtable classInstances
          The collection of class instances that are known to implement the methods of evaluated attributes
protected  PageSupport currentPage
           
 
Constructor Summary
ScriptAttributeEvaluator()
          Create a new instance of the evaluator
 
Method Summary
 java.lang.Object evaluateAttribute(PageSupport page, java.lang.String attributeValue)
          Get the value of an attribute.
 PageSupport getCurrentPage()
          Get the current page.
 XMethodReference getMethodReference(PageSupport page, 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
 void setCurrentProject(XProject currentProject)
          Set the current project and complete any initialization that depends on the project reference/instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classInstances

protected java.util.Hashtable classInstances
The collection of class instances that are known to implement the methods of evaluated attributes


currentPage

protected PageSupport currentPage
Constructor Detail

ScriptAttributeEvaluator

public ScriptAttributeEvaluator()
Create a new instance of the evaluator

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(PageSupport page,
                                          java.lang.String attributeValue)
Get the value of an attribute.

Specified by:
evaluateAttribute in interface XAttributeEvaluator
Parameters:
page - 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(PageSupport page,
                                           java.lang.String attributeValue)
Get the value of an attribute by evaluating a method reference

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

getCurrentPage

public PageSupport getCurrentPage()
Get the current page. In most cases this should correspond to the active page at the time the evaluator was last used, but no guarantees can be provided that multiple threads are not updating the value. The value should be retrieved and cached as soon as the evaluated method is entered as other method calls could have the side effect of reseting the value.

Returns:
the current page object