}
}
if (difference) {
for (InputNode n : removed) {
writer.simpleTag(Parser.REMOVE_NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, Integer.toString(n.getId())));
}
}
for (InputNode n : graph.getNodes()) {
if (!difference || !equal.contains(n)) {
writer.startTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, Integer.toString(n.getId())));
writer.writeProperties(n.getProperties());
writer.endTag();
}
}
writer.endTag();
writer.startTag(Parser.EDGES_ELEMENT);
Set<InputEdge> removedEdges = new HashSet<InputEdge>();
Set<InputEdge> equalEdges = new HashSet<InputEdge>();
if (previous != null) {
for (InputEdge e : previous.getEdges()) {
if (graph.getEdges().contains(e)) {
equalEdges.add(e);
} else {
removedEdges.add(e);
}
}
}
if (difference) {
for (InputEdge e : removedEdges) {
writer.simpleTag(Parser.REMOVE_EDGE_ELEMENT, createProperties(e));
}
}
for (InputEdge e : graph.getEdges()) {
if (!difference || !equalEdges.contains(e)) {
if (!equalEdges.contains(e)) {
writer.simpleTag(Parser.EDGE_ELEMENT, createProperties(e));
}
}
}
writer.endTag();
writer.startTag(Parser.CONTROL_FLOW_ELEMENT);
for (InputBlock b : graph.getBlocks()) {
writer.startTag(Parser.BLOCK_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, b.getName()));
writer.startTag(Parser.SUCCESSORS_ELEMENT);
for (InputBlock s : b.getSuccessors()) {
writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName()));
}
writer.endTag();
writer.startTag(Parser.NODES_ELEMENT);
for (InputNode n : b.getNodes()) {
writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + ""));
}
writer.endTag();
writer.endTag();