{
sCollectionExpression = XMLUtil.getReqStringAttr(element, "collection");
sItemVariableName = XMLUtil.getReqStringAttr(element, "variable");
}
Variable itemVar = activity.getFlow().findVariable(sItemVariableName);
if (itemVar == null)
{
itemVar = new Variable(sItemVariableName);
activity.getFlow().addVariable(itemVar);
}
String sLoopName = XMLUtil.getReqStringAttr(element, "name");
Object collectionExpression = helper.parse(sCollectionExpression,
false, activity.getFlow().getPosMap(), null, metadata.getGlobalEnvironment()
);
Variable collectionVar;
boolean bUseOldCollectionVar = (collectionExpression instanceof Symbol) && collectionExpression != Symbol.THIS;
// If collection is already stored in a variable, do not create a new one.
if (bUseOldCollectionVar)
{
collectionVar = activity.getFlow().getVariable(((Symbol)collectionExpression).getName());
}
else
{
collectionVar = new Variable(sLoopName + ":collection");
activity.getFlow().addVariable(collectionVar);
}
Variable indexVar = new Variable(sLoopName + ":var");
activity.getFlow().addVariable(indexVar);
Symbol collectionSym = collectionVar.getSymbol();
Symbol indexSym = indexVar.getSymbol();
Symbol itemSym = itemVar.getSymbol();
// Loop initializer step
Script initializer = new Script(sLoopName + ":init");