close

Filter

loading table of contents...

Workflow Manual / Version 2401

Table Of Contents

5.4.2 Generic Expressions

Interface to implement

For a generic expression you have to implement the interface com.coremedia.workflow.WfExpression. Such an expression must return a java.lang.Comparable value. If you want to use the result of your expression for further evaluation, you should return a WfValue because this is what all built-in expressions operate on.

Convenience classes

For convenience you can subclass from com.coremedia.workflow.common.expressions.AbstractExpression and implement the evaluate() method, which is called by the CoreMedia Workflow Server. See Example 5.4, “Example of a generic expression” for a simple example of an expression.

Define expressions

The following XML fragment shows, how to define your expressions in the workflow definition.

.
.
  <Variable name="comment" type="String">
    <String value="TestString"/>
  </Variable>
.
.
  <If name="One">
    <Condition>
      <Less>
        <Expression class="com.coremedia.example.
                           expression.DemoExpression"/>
        <Get variable="comment"/>
      </Less>
    </Condition>
    <Then successor="True"/>
    <Else successor="False"/>
  </If>
.
.

Example 5.3. Use a generic expression in the workflow definition


Example generic expression

The following code example shows a simple expression which returns a StringValue.

public class SampleExpression extends AbstractExpression {

  public String getName() {return "SampleExpression";}

  public Comparable evaluate(WfInstance instance, 
                             Map localVariables) {
    return new StringValue("ConstantValue");
  }

}

Example 5.4. Example of a generic expression


Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.