added = true;
precedingIndex = i;
}
AnnotationPanel panel = (AnnotationPanel) precOp.getAnnotationLabel(node);
switch(panel.getMode()) {
case ONLY_PRECEDING_AND_SUCCEEDING:
case ONLY_PRECEDING:
if(node.getClass() == JumpOverOperator.class) {
buffer.append(
spaces + "if(" + testName + " != " + originalNodeName + ") {\n"
);
spaces.append(" ");
}
buffer.append(
spaces + "if(_precedingOperators_" + runNumber + "_" + precedingIndex + ".size() != 1) {\n" +
spaces + " " + ((runNumber != 1) ? "continue" : "return false") + ";\n" +
spaces + "}\n"
);
if(node.getClass() == JumpOverOperator.class) {
spaces.delete(spaces.length()-4, spaces.length());
buffer.append(spaces + "}\n");
}
break;
case ALL_PRECEDING:
buffer.append(
"\n" +
spaces + "this._dim_" + currentDimension + " = -1;\n"
);
for(String variable : this.get_variables_for_next_dimension(precOp, true)) {
VariableContainer vc = this.variableList_left.get(variable);
buffer.append(vc.initiate_next_dimension(spaces, currentDimension, "_precedingOperators_" + runNumber + "_" + precedingIndex + ".size()", true));
}
break;
}
buffer.append(
"\n" +
spaces + "for(BasicOperator _precOp_" + runNumber + "_" + i + " : _precedingOperators_" + runNumber + "_" + precedingIndex + ") {\n"
);
bracesCount++;
spaces.append(" ");
switch(panel.getMode()) {
case ALL_PRECEDING:
buffer.append(
spaces + "this._dim_" + currentDimension + " += 1;\n" +
"\n"
);
break;
}
if(panel.isActive()) {
int opID = panel.getOpID();
if(opID != -1) {
buffer.append(
spaces + "if(_precOp_" + runNumber + "_" + i + ".getOperatorIDTuple(" + nodeName + ").getId() != " + opID + ") {\n" +
spaces + " continue;\n" +
spaces + "}\n" +
"\n"
);
}
}
String nextOpName = "_precOp_" + runNumber + "_" + i;
testName = "";
switch(panel.getMode()) {
default:
case EXISTS:
if(precOp.getClass() == JumpOverOperator.class) {
String[] data = this.handleJumpOverOperator(spaces, buffer, (JumpOverOperator) precOp, nextOpName, runNumber, 0, true);
nextOpName = data[0];
testName = data[1];
}
bracesCount += this.manage_node(spaces, buffer, precOp, nextOpName, visitedNodes, visitedConnections, runNumber, currentDimension, testName);
break;
case ALL_PRECEDING:
buffer.append(
spaces + "if(!this._checkPrivate" + this.count_private + "(" + nextOpName + ")) {\n" +
spaces + " return false;\n" +
spaces + "}\n"
);
this.generate_checkPrivate(precOp, visitedNodes, visitedConnections, currentDimension+1);
spaces.delete(spaces.length()-4, spaces.length());
buffer.append(spaces + "}\n");
bracesCount -= 1;
break;
case ALL_SUCCEEDING:
System.err.println("WARNING: This case should never happen!");
break;
case ONLY_PRECEDING_AND_SUCCEEDING:
case ONLY_SUCCEEDING:
buffer.append(
spaces + "if(" + nextOpName + ".getSucceedingOperators().size() != 1) {\n" +
spaces + " break;\n" +
spaces + "}\n" +
"\n"
);
if(precOp.getClass() == JumpOverOperator.class) {
String[] data = this.handleJumpOverOperator(spaces, buffer, (JumpOverOperator) precOp, nextOpName, runNumber, 0, true);
nextOpName = data[0];
testName = data[1];
}
bracesCount += this.manage_node(spaces, buffer, precOp, nextOpName, visitedNodes, visitedConnections, runNumber, currentDimension, testName);
break;
}
}
}
LinkedList<OperatorIDTuple<Operator>> succedingOperators = node.getSucceedingOperators();
if(succedingOperators.size() > 0) {
boolean added = false;
int succedingIndex = 0;
for(int i = 0; i < succedingOperators.size(); i += 1) {
OperatorIDTuple<Operator> sucOpIDTup = succedingOperators.get(i);
AbstractRuleOperator sucOp = (AbstractRuleOperator) sucOpIDTup.getOperator();
HashSet<Operator> connectionNodes = visitedConnections.get(node);
if(connectionNodes == null) {
connectionNodes = new HashSet<Operator>();
visitedConnections.put(node, connectionNodes);
}
else if(connectionNodes.contains(sucOp)) {
continue;
}
connectionNodes.add(sucOp);
if(!added) {
buffer.append(
"\n" +
spaces + "List<OperatorIDTuple> _succedingOperators_" + runNumber + "_" + i + " = " + nodeName + ".getSucceedingOperators();\n" +
"\n"
);
added = true;
succedingIndex = i;
}
AnnotationPanel panel = (AnnotationPanel) node.getAnnotationLabel(sucOp);
switch(panel.getMode()) {
case ONLY_PRECEDING_AND_SUCCEEDING:
case ONLY_SUCCEEDING:
buffer.append(
spaces + "if(_succedingOperators_" + runNumber + "_" + succedingIndex + ".size() != 1) {\n" +
spaces + " " + ((runNumber != 1) ? "continue" : "return false") + ";\n" +
spaces + "}\n"
);
break;
case ALL_SUCCEEDING:
buffer.append(
"\n" +
spaces + "this._dim_" + currentDimension + " = -1;\n"
);
for(String variable : this.get_variables_for_next_dimension(sucOp, false)) {
VariableContainer vc = this.variableList_left.get(variable);
buffer.append(vc.initiate_next_dimension(spaces, currentDimension, "_succedingOperators_" + runNumber + "_" + succedingIndex + ".size()", true));
}
break;
}
buffer.append(
"\n" +
spaces + "for(OperatorIDTuple _sucOpIDTup_" + runNumber + "_" + i + " : _succedingOperators_" + runNumber + "_" + succedingIndex + ") {\n"
);
bracesCount++;
spaces.append(" ");
switch(panel.getMode()) {
case ALL_SUCCEEDING:
buffer.append(
spaces + "this._dim_" + currentDimension + " += 1;\n" +
"\n"
);
break;
}
if(panel.isActive()) {
int opID = panel.getOpID();
if(opID != -1) {
buffer.append(
spaces + "if(_sucOpIDTup_" + runNumber + "_" + i + ".getId() != " + opID + ") {\n" +
spaces + " continue;\n" +
spaces + "}\n" +
"\n"
);
}
}
String nextOpName = "_sucOpIDTup_" + runNumber + "_" + i + ".getOperator()";
testName = "";
switch(panel.getMode()) {
default:
case EXISTS:
if(sucOp.getClass() == JumpOverOperator.class) {
String[] data = this.handleJumpOverOperator(spaces, buffer, (JumpOverOperator) sucOp, nextOpName, runNumber, 0, false);
nextOpName = data[0];