org.jicengine.element
Class WrapperActionElement

java.lang.Object
  extended byorg.jicengine.element.AbstractElement
      extended byorg.jicengine.element.WrapperActionElement
All Implemented Interfaces:
ActionElement, Element

public class WrapperActionElement
extends AbstractElement
implements ActionElement

WrapperActionElement adds an action to a ValueElement.

Useful way for example transforming ValueElements as property-setters: wrap them inside a WrapperActionElement and set the action-operation to the set-property.

Design-note: currently, there's know way to give the action any parameters besides the implicit 'PARENT' and 'this' objects and global objects. (and we shouldn't create new data that is not available in the JIC-file?) of course, the action-Operation can always be constructor so that it won't need other parameters..

Author:
.timo

Field Summary
 
Fields inherited from interface org.jicengine.element.Element
VARIABLE_NAME_CDATA, VARIABLE_NAME_ELEMENT_INSTANCE, VARIABLE_NAME_PARENT_INSTANCE
 
Constructor Summary
WrapperActionElement(ValueElement valueElement, Location location, Operation action)
           
 
Method Summary
 void execute(Context globalContext, java.lang.Object parentInstance)
           Executes the action of this element.
 
Methods inherited from class org.jicengine.element.AbstractElement
getLocation, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jicengine.element.Element
getName
 

Constructor Detail

WrapperActionElement

public WrapperActionElement(ValueElement valueElement,
                            Location location,
                            Operation action)
Method Detail

execute

public void execute(Context globalContext,
                    java.lang.Object parentInstance)
             throws ElementException
Description copied from interface: ActionElement

Executes the action of this element. The operation doesn't return any value to its caller, although it can internally produce a value.

The client/user of this element will call this method. currently, the method is called only once. However, the action should be able to be executed multiple times.

in general, the execution consists of the following steps:

  1. if the element has an instance, it is created first (with parameters)
  2. if the element has other ActionElements as children, they are executed next
  3. finally, the actual action is executed (with parameters)

Specified by:
execute in interface ActionElement
Parameters:
globalContext - a Context where the instances marked with the 'id'-attribute are put.
parentInstance - the instance of the parent element. NOTE: null-value means that the value of the parent is not available (not yet or never), not that the instance of the parent is null!
Throws:
ElementException - if any part of the execution of the action fails.