result = (CpsFlowExecution) context.currentObject();
} else {
result = (CpsFlowExecution) ref.newInstance(CpsFlowExecution.class);
}
FlowNodeStorage storage = result.storage;
Stack<BlockStartNode> startNodes = new Stack<BlockStartNode>();
Map<Integer,FlowHead> heads = new TreeMap<Integer, FlowHead>();
while (reader.hasMoreChildren()) {
reader.moveDown();
String nodeName = reader.getNodeName();
if (nodeName.equals("result")) {
Result r = readChild(reader, context, Result.class, result);
setField(result, "result", r);
} else
if (nodeName.equals("script")) {
String script = readChild(reader, context, String.class, result);
setField(result, "script", script);
} else
if (nodeName.equals("loadedScripts")) {
Map loadedScripts = readChild(reader, context, Map.class, result);
setField(result, "loadedScripts", loadedScripts);
} else
if (nodeName.equals("owner")) {
FlowExecutionOwner owner = (FlowExecutionOwner) readChild(reader, context, Object.class, result);
setField(result, "owner", owner);
setField(result, "storage", storage = result.createStorage());
} else
if (nodeName.equals("user")) {
String user = readChild(reader, context, String.class, result);
setField(result, "user", user);
} else
if (nodeName.equals("head")) {
String[] head = readChild(reader, context, String.class, result).split(":");
FlowHead h = new FlowHead(result, Integer.parseInt(head[0]));
h.setForDeserialize(storage.getNode(head[1]));
heads.put(h.getId(), h);
} else
if (nodeName.equals("iota")) {
Integer iota = readChild(reader, context, Integer.class, result);
setField(result, "iota", new AtomicInteger(iota));
} else
if (nodeName.equals("start")) {
String id = readChild(reader, context, String.class, result);
startNodes.add((BlockStartNode) storage.getNode(id));
}
reader.moveUp();
}