net.xoetrope.xui.evaluator
Class XDefaultAttributeEvaluator

java.lang.Object
  extended by net.xoetrope.xui.evaluator.XDefaultAttributeEvaluator
All Implemented Interfaces:
XAttributeEvaluator

public class XDefaultAttributeEvaluator
extends java.lang.Object

    
implements XAttributeEvaluator

    

An attribute evaluator

An evaluated attribute's implementing method is by default in the owner page such that a reference like

${myMethod()}

would evaluate to a method in the current page with a signature like:

public void myMethod();

The attributes can also be defined in classes other than the current page or classes derived from XPage. The syntax for such expressions is as follows:

where mypackage is the name of the Java package containing the class MyClass. The value of referenceName is a user defined value that identifies the instance of the class. The application instantiates an instance of the class when the expression is first encountered and thereafter maintains the instance with each subsequent call retrieving the same instance of the class.

The method call can contain zero or more arguments

Copyright (c) Xoetrope Ltd., 2002-2004

$Revision: 2.9 $

License: see License.txt


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
XDefaultAttributeEvaluator()
           
 
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 method reference for the methods named in the attribute
 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

XDefaultAttributeEvaluator

public XDefaultAttributeEvaluator()
Parameters:
currentProject - the current project
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 method reference for the methods named in the attribute

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 page from which the evaluation is invoked
attributeValue - the attribute to be evaluated
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