Program: 120987
Project: 120987
Buggy source:
private static boolean evaluateSimpleExpression(String simpleExpression,List<? extends IElementParameter> listParam,ElementParameter currentParam){
  boolean showParameter=false;
  String test=null;
  if (simpleExpression.contains(EQUALS)) {
    test=EQUALS;
  }
 else {
    if (simpleExpression.contains(NOT_EQUALS)) {
      test=NOT_EQUALS;
    }
  }
  if ((simpleExpression.contains("String_Node_Str") || simpleExpression.contains("String_Node_Str")) && simpleExpression.endsWith("String_Node_Str")) {
    return evaluateInExpression(simpleExpression,listParam);
  }
  if (test == null) {
    throwUnsupportedExpression(simpleExpression,currentParam);
    return false;
  }
  String[] strings=simpleExpression.split(test);
  String variableName=null, variableValue=null;
  for (  String string2 : strings) {
    String string=string2.trim();
    if (string.contains("String_Node_Str")) {
      variableValue=string;
      variableValue=variableValue.substring(1,string.lastIndexOf("String_Node_Str"));
    }
 else {
      variableName=string;
    }
  }
  if (variableName != null && EParameterName.CURRENT_OS.getName().equals(variableName)) {
    if (variableValue != null) {
      if (checkCurrentOS(variableValue) && EQUALS.endsWith(test)) {
        return true;
      }
 else       if (NOT_EQUALS.equals(test)) {
        return true;
      }
    }
  }
  if (listParam == null) {
    return false;
  }
  String[] varNames;
  varNames=StringUtils.split(variableName,'.');
  if ((variableName != null) && (variableValue != null)) {
    if (varNames[0].equals("String_Node_Str")) {
      if (currentParam != null && currentParam.getElement() instanceof INode) {
        INode node=(INode)currentParam.getElement();
        String relatedNodeName=ElementParameterParser.getValue(node,"String_Node_Str" + varNames[1] + "String_Node_Str");
        List<? extends INode> generatingNodes=node.getProcess().getGeneratingNodes();
        for (        INode aNode : generatingNodes) {
          if (aNode.getUniqueName().equals(relatedNodeName)) {
            simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str" + varNames[1]+ "String_Node_Str","String_Node_Str");
            List<? extends IElementParameter> elementParameters=aNode.getElementParameters();
            return evaluate(simpleExpression,elementParameters);
          }
        }
      }
    }
 else     if ("String_Node_Str".equals(varNames[0])) {
      if (listParam != null && listParam.size() > 0) {
        IElement element=listParam.get(0).getElement();
        if (element != null && element instanceof INode) {
          INode node=(INode)element;
          if (varNames.length > 2 && varNames[1] != null && varNames[2] != null) {
            IConnection[] allConnections=node.getProcess().getAllConnections("String_Node_Str" + varNames[1]);
            for (            IConnection c : allConnections) {
              IElementParameter elementParameter=c.getElementParameter(varNames[2]);
              if (variableValue.equals(elementParameter.getValue())) {
                return true;
              }
            }
          }
        }
      }
      return false;
    }
  }
  if ((variableName != null) && (variableValue != null)) {
    for (    IElementParameter param : listParam) {
      if (param.getName().equals(varNames[0])) {
        IElementParameter testedParameter=param;
        Object value=null;
        boolean found=false;
        if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
          List<Map<String,Object>> tableValues=(List<Map<String,Object>>)param.getValue();
          if (currentParam == null) {
            continue;
          }
          Map<String,Object> currentRow=tableValues.get(currentParam.getCurrentRow());
          if (currentRow.containsKey(varNames[1])) {
            for (            Object curObj : param.getListItemsValue()) {
              if (curObj instanceof IElementParameter) {
                IElementParameter testParam=(IElementParameter)curObj;
                if (testParam.getName().equals(varNames[1])) {
                  testedParameter=testParam;
                  break;
                }
              }
            }
            if (varNames.length == 2) {
              value=currentRow.get(varNames[1]);
            }
 else {
              if ("String_Node_Str".equals(varNames[2])) {
                IMetadataTable baseTable=null;
                IMetadataColumn baseColumn=null;
                INode node;
                Object obj=currentRow.get(testedParameter.getName());
                String columnName="String_Node_Str";
                if (obj instanceof String) {
                  columnName=(String)obj;
                }
 else                 if (obj instanceof Integer) {
                  columnName=testedParameter.getListItemsDisplayName()[(Integer)obj];
                }
                if (currentParam.getElement() instanceof INode) {
                  node=(INode)currentParam.getElement();
switch (testedParameter.getFieldType()) {
case COLUMN_LIST:
                    baseTable=node.getMetadataList().get(0);
                  break;
case PREV_COLUMN_LIST:
                IConnection connection=null;
              for (int i=0; i < node.getIncomingConnections().size(); i++) {
                IConnection curConnec=node.getIncomingConnections().get(i);
                if (curConnec.getLineStyle() == EConnectionType.FLOW_MAIN) {
                  connection=curConnec;
                  break;
                }
              }
            if (connection != null) {
              baseTable=connection.getMetadataTable();
            }
          break;
case LOOKUP_COLUMN_LIST:
        List<IConnection> refConnections=new ArrayList<IConnection>();
      for (int i=0; i < node.getIncomingConnections().size(); i++) {
        IConnection curConnec=node.getIncomingConnections().get(i);
        if (curConnec.getLineStyle() == EConnectionType.FLOW_REF) {
          refConnections.add(curConnec);
        }
      }
    for (    IConnection curConnec : refConnections) {
      IMetadataTable table=curConnec.getMetadataTable();
      for (      IMetadataColumn column : table.getListColumns()) {
        String name=curConnec.getName() + "String_Node_Str" + column.getLabel();
        if (name.equals(columnName)) {
          baseColumn=column;
        }
      }
    }
  break;
default :
}
if (baseTable != null) {
for (IMetadataColumn column : baseTable.getListColumns()) {
  if (column.getLabel().equals(columnName)) {
    baseColumn=column;
    break;
  }
}
}
if (baseColumn != null) {
switch (LanguageManager.getCurrentLanguage()) {
case JAVA:
  value=JavaTypesManager.getTypeToGenerate(baseColumn.getTalendType(),baseColumn.isNullable());
break;
default :
value=baseColumn.getTalendType();
}
if (value.equals(variableValue)) {
found=true;
}
}
}
}
}
}
}
 else if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE) || param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.QUERYSTORE_TYPE)|| param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
boolean child=false;
Map<String,IElementParameter> childParameters=param.getChildParameters();
if ("String_Node_Str".equals(param.getName())) {
if (childParameters != null) {
IElementParameter iElementParameter=childParameters.get("String_Node_Str");
if (iElementParameter != null) {
Object value2=iElementParameter.getValue();
if (variableValue.equals(value2.toString())) {
child=true;
found=true;
value=value2.toString();
}
}
}
}
if (varNames.length > 1 && varNames[1] != null) {
IElementParameter tempParam=childParameters.get(varNames[1]);
if (tempParam != null) {
value=tempParam.getValue();
if (value.equals(variableValue)) {
found=true;
}
child=true;
}
}
if (!child) {
value=testedParameter.getValue();
}
}
 else {
value=testedParameter.getValue();
}
if (value instanceof Integer) {
if (((Integer)value) < testedParameter.getListItemsValue().length) {
value=testedParameter.getListItemsValue()[(Integer)value];
}
}
if (value instanceof String) {
if (variableValue.equals(value)) {
found=true;
}
 else if (testedParameter.getListItemsValue() instanceof Object[]) {
Object[] values=testedParameter.getListItemsValue();
for (int i=0; i < values.length && !found; i++) {
if (values[i].equals(value)) {
String variableCode=testedParameter.getListItemsDisplayCodeName()[i];
if (variableCode.equals(variableValue)) {
found=true;
}
}
}
}
}
 else if (value instanceof Boolean) {
Boolean tmpValue=new Boolean(variableValue);
if (tmpValue.equals(value)) {
found=true;
}
}
if (found) {
if (test.equals(EQUALS)) {
showParameter=true;
}
}
 else {
if (test.equals(NOT_EQUALS)) {
showParameter=true;
}
}
}
}
}
return showParameter;
}

Fixed version (ground truth):
private static boolean evaluateSimpleExpression(String simpleExpression,List<? extends IElementParameter> listParam,ElementParameter currentParam){
  boolean showParameter=false;
  String test=null;
  if (simpleExpression.contains(EQUALS)) {
    test=EQUALS;
  }
 else {
    if (simpleExpression.contains(NOT_EQUALS)) {
      test=NOT_EQUALS;
    }
  }
  if ((simpleExpression.contains("String_Node_Str") || simpleExpression.contains("String_Node_Str")) && simpleExpression.endsWith("String_Node_Str")) {
    return evaluateInExpression(simpleExpression,listParam);
  }
  if (test == null) {
    throwUnsupportedExpression(simpleExpression,currentParam);
    return false;
  }
  String[] strings=simpleExpression.split(test);
  String variableName=null, variableValue=null;
  for (  String string2 : strings) {
    String string=string2.trim();
    if (string.contains("String_Node_Str")) {
      variableValue=string;
      variableValue=variableValue.substring(1,string.lastIndexOf("String_Node_Str"));
    }
 else {
      variableName=string;
    }
  }
  if (variableName != null && EParameterName.CURRENT_OS.getName().equals(variableName)) {
    if (variableValue != null) {
      if (checkCurrentOS(variableValue) && EQUALS.endsWith(test)) {
        return true;
      }
 else       if (NOT_EQUALS.equals(test)) {
        return true;
      }
    }
  }
  if (listParam == null) {
    return false;
  }
  String[] varNames;
  varNames=StringUtils.split(variableName,'.');
  if ((variableName != null) && (variableValue != null)) {
    if (varNames[0].equals("String_Node_Str")) {
      if (currentParam != null && currentParam.getElement() instanceof INode) {
        INode node=(INode)currentParam.getElement();
        String relatedNodeName=ElementParameterParser.getValue(node,"String_Node_Str" + varNames[1] + "String_Node_Str");
        List<? extends INode> generatingNodes=node.getProcess().getGeneratingNodes();
        for (        INode aNode : generatingNodes) {
          if (aNode.getUniqueName().equals(relatedNodeName)) {
            simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str" + varNames[1]+ "String_Node_Str","String_Node_Str");
            List<? extends IElementParameter> elementParameters=aNode.getElementParameters();
            return evaluate(simpleExpression,elementParameters);
          }
        }
      }
    }
 else     if ("String_Node_Str".equals(varNames[0])) {
      if (listParam != null && listParam.size() > 0) {
        IElement element=listParam.get(0).getElement();
        if (element != null && element instanceof INode) {
          INode node=(INode)element;
          if (varNames.length > 2 && varNames[1] != null && varNames[2] != null) {
            IConnection[] allConnections=node.getProcess().getAllConnections("String_Node_Str" + varNames[1]);
            for (            IConnection c : allConnections) {
              IElementParameter elementParameter=c.getElementParameter(varNames[2]);
              if (variableValue.equals(elementParameter.getValue())) {
                return true;
              }
            }
          }
        }
      }
      return false;
    }
  }
  if ((variableName != null) && (variableValue != null)) {
    for (    IElementParameter param : listParam) {
      if (param.getName().equals(varNames[0])) {
        IElementParameter testedParameter=param;
        Object value=null;
        boolean found=false;
        if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
          List<Map<String,Object>> tableValues=(List<Map<String,Object>>)param.getValue();
          if (currentParam == null) {
            continue;
          }
          Map<String,Object> currentRow=tableValues.get(currentParam.getCurrentRow());
          if (currentRow.containsKey(varNames[1])) {
            for (            Object curObj : param.getListItemsValue()) {
              if (curObj instanceof IElementParameter) {
                IElementParameter testParam=(IElementParameter)curObj;
                if (testParam.getName().equals(varNames[1])) {
                  testedParameter=testParam;
                  break;
                }
              }
            }
            if (varNames.length == 2) {
              value=currentRow.get(varNames[1]);
            }
 else {
              if ("String_Node_Str".equals(varNames[2])) {
                IMetadataTable baseTable=null;
                IMetadataColumn baseColumn=null;
                INode node;
                Object obj=currentRow.get(testedParameter.getName());
                String columnName="String_Node_Str";
                if (obj instanceof String) {
                  columnName=(String)obj;
                }
 else                 if (obj instanceof Integer) {
                  int index=(Integer)obj;
                  if (index < testedParameter.getListItemsDisplayName().length && index >= 0) {
                    columnName=testedParameter.getListItemsDisplayName()[(Integer)obj];
                  }
                }
                if (currentParam.getElement() instanceof INode) {
                  node=(INode)currentParam.getElement();
switch (testedParameter.getFieldType()) {
case COLUMN_LIST:
                    baseTable=node.getMetadataList().get(0);
                  break;
case PREV_COLUMN_LIST:
                IConnection connection=null;
              for (int i=0; i < node.getIncomingConnections().size(); i++) {
                IConnection curConnec=node.getIncomingConnections().get(i);
                if (curConnec.getLineStyle() == EConnectionType.FLOW_MAIN) {
                  connection=curConnec;
                  break;
                }
              }
            if (connection != null) {
              baseTable=connection.getMetadataTable();
            }
          break;
case LOOKUP_COLUMN_LIST:
        List<IConnection> refConnections=new ArrayList<IConnection>();
      for (int i=0; i < node.getIncomingConnections().size(); i++) {
        IConnection curConnec=node.getIncomingConnections().get(i);
        if (curConnec.getLineStyle() == EConnectionType.FLOW_REF) {
          refConnections.add(curConnec);
        }
      }
    for (    IConnection curConnec : refConnections) {
      IMetadataTable table=curConnec.getMetadataTable();
      for (      IMetadataColumn column : table.getListColumns()) {
        String name=curConnec.getName() + "String_Node_Str" + column.getLabel();
        if (name.equals(columnName)) {
          baseColumn=column;
        }
      }
    }
  break;
default :
}
if (baseTable != null) {
for (IMetadataColumn column : baseTable.getListColumns()) {
  if (column.getLabel().equals(columnName)) {
    baseColumn=column;
    break;
  }
}
}
if (baseColumn != null) {
switch (LanguageManager.getCurrentLanguage()) {
case JAVA:
  value=JavaTypesManager.getTypeToGenerate(baseColumn.getTalendType(),baseColumn.isNullable());
break;
default :
value=baseColumn.getTalendType();
}
if (value.equals(variableValue)) {
found=true;
}
}
}
}
}
}
}
 else if (param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE) || param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || param.getFieldType().equals(EParameterFieldType.QUERYSTORE_TYPE)|| param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
boolean child=false;
Map<String,IElementParameter> childParameters=param.getChildParameters();
if ("String_Node_Str".equals(param.getName())) {
if (childParameters != null) {
IElementParameter iElementParameter=childParameters.get("String_Node_Str");
if (iElementParameter != null) {
Object value2=iElementParameter.getValue();
if (variableValue.equals(value2.toString())) {
child=true;
found=true;
value=value2.toString();
}
}
}
}
if (varNames.length > 1 && varNames[1] != null) {
IElementParameter tempParam=childParameters.get(varNames[1]);
if (tempParam != null) {
value=tempParam.getValue();
if (value.equals(variableValue)) {
found=true;
}
child=true;
}
}
if (!child) {
value=testedParameter.getValue();
}
}
 else {
value=testedParameter.getValue();
}
if (value instanceof Integer) {
if (((Integer)value) < testedParameter.getListItemsValue().length) {
value=testedParameter.getListItemsValue()[(Integer)value];
}
}
if (value instanceof String) {
if (variableValue.equals(value)) {
found=true;
}
 else if (testedParameter.getListItemsValue() instanceof Object[]) {
Object[] values=testedParameter.getListItemsValue();
for (int i=0; i < values.length && !found; i++) {
if (values[i].equals(value)) {
String variableCode=testedParameter.getListItemsDisplayCodeName()[i];
if (variableCode.equals(variableValue)) {
found=true;
}
}
}
}
}
 else if (value instanceof Boolean) {
Boolean tmpValue=new Boolean(variableValue);
if (tmpValue.equals(value)) {
found=true;
}
}
if (found) {
if (test.equals(EQUALS)) {
showParameter=true;
}
}
 else {
if (test.equals(NOT_EQUALS)) {
showParameter=true;
}
}
}
}
}
return showParameter;
}