public abstract class _Iterator extends JAIterator implements _Operation
A state machine compatible extension of JAIterator.
SMBuilder smb = new SMBuilder(); new _Iterator(smb, "rs") { int i; int r = 1; int max; protected void init(StateMachine sm) { max = ((Integer) sm.request).intValue(); } protected void process(RP rp2) throws Exception { if (i >= max) rp2.process(new Integer(r)); else { i += 1; r = r * i; rp2.process(null); } } }; smb._return(new ObjectFunc(){ public Object get(StateMachine sm) { return sm.get("rs"); } }); smb.call(5, rp); Response: 120Constructor and Description |
---|
_Iterator(_SMBuilder smb)
Create an _Iterator
|
_Iterator(_SMBuilder smb,
String resultName)
Create an _Iterator
|
Modifier and Type | Method and Description |
---|---|
void |
call(SimpleMachine stateMachine,
RP rp)
Perform the operation.
|
protected void |
init(SimpleMachine stateMachine)
Optional initialization, as required.
|
void |
iterate(RP responseProcessor)
Iterates over the process method.
|
process
public _Iterator(_SMBuilder smb)
smb
- The state machine builder.public _Iterator(_SMBuilder smb, String resultName)
smb
- The state machine builder.resultName
- The name of the result, or null.public final void call(SimpleMachine stateMachine, RP rp) throws Exception
call
in interface _Operation
stateMachine
- The state machine driving the operation.rp
- The response processor.Exception
- Any uncaught exceptions raised while performing the operation.public final void iterate(RP responseProcessor) throws Exception
JAIterator
iterate
in class JAIterator
responseProcessor
- The response processor.Exception
- Any uncaught exceptions raised by the process method.protected void init(SimpleMachine stateMachine)
stateMachine
- The state machine.Copyright © 2012. All Rights Reserved.