The counter can increment or decrement a value.
This counter has extended xml schema configuration. Take a look at the
schema
http://www.milyn.org/xsd/smooks/calc-1.1.xsd for more
information.
Example basic configuration:
<resource-config selector="orderItems">
<resource>org.dhatim.calc.Counter</resource>
<param name="beanId">count</param>
</resource-config>
Optional parameters:
<param name="start">1</param>
<param name="amount">2</param>
<param name="amountExpression">incrementAmount</param>
<param name="startExpression">startValue</param>
<param name="resetCondition">count == 10</param>
<param name="direction">DECREMENT</param>
<param name="executeAfter>false</param>
Description of configuration properties:
- beanId: The beanId in which the counter value is stored. The value is always stored as a Long type.
- start: The counter start value.
- startExpression: The result of this expression is the counter start value.
This expression is executed at the first count and every time the counter
is reset. The expression must result in an integer or a long.
If the startIndex attribute of the counter is set then this expression never gets
executed.
- amount: The amount that the counter increments or decrements the counter value.
- amountExpression: The result of this expression is the amount the counter increments or decrements.
This expression is executed every time the counter counts.
The expression must result in an integer.
If the amount attribute of the counter is set then this expression never gets
executed.
- resetCondition: When the expression is set and results in a true value then the counter is reset to
the start index. The expression must result in a boolean.
- direction: The direction that the counter counts. Can be INCREMENT (default) or DECREMENT.
- executeAfter: If the counter is executed after the element else it will execute before the element.
Default is 'false'.