Program: 119321
Project: 119321
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;
  }
 else   if (simpleExpression.contains(GREAT_THAN)) {
    test=GREAT_THAN;
  }
 else   if (simpleExpression.contains(LESS_THAN)) {
    test=LESS_THAN;
  }
  if ((simpleExpression.contains("String_Node_Str") || simpleExpression.contains("String_Node_Str")) && simpleExpression.endsWith("String_Node_Str")) {
    return evaluateInExpression(simpleExpression,listParam);
  }
  List<String> paraNames=getParaNamesFromIsShowFunc(simpleExpression);
  if (paraNames.size() > 0) {
    String paraName=paraNames.get(0);
    try {
      checkIsShowLoop(paraName,simpleExpression,listParam,currentParam,null);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
      return false;
    }
    for (    IElementParameter param : listParam) {
      if (paraName != null && paraName.equals(param.getName())) {
        return param.isShow(param.getShowIf(),param.getNotShowIf(),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;
  }
  if ("String_Node_Str".equals(variableName)) {
    boolean isTIS=PluginChecker.isTIS();
    if ("String_Node_Str".equals(variableValue)) {
      return isTIS;
    }
 else {
      return !isTIS;
    }
  }
  String[] varNames;
  varNames=StringUtils.split(variableName,'.');
  if ((variableName != null) && (variableValue != null)) {
    if (varNames[0].equals("String_Node_Str")) {
      INode node=null;
      if (currentParam != null && currentParam.getElement() instanceof INode) {
        node=(INode)currentParam.getElement();
      }
 else       if (currentParam == null) {
        if (listParam != null && listParam.size() > 0) {
          IElement element=listParam.get(0).getElement();
          if (element instanceof INode) {
            node=(INode)element;
          }
        }
      }
      if (node != null && node.getElementParameters() != null) {
        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) {
            List<? extends IConnection> connections=new ArrayList<IConnection>();
            if ("String_Node_Str".equals(varNames[1]) || "String_Node_Str".equals(varNames[1])) {
              if ("String_Node_Str".equals(varNames[1])) {
                if ("String_Node_Str".equals(varNames[2])) {
                  connections=node.getIncomingConnections();
                }
 else {
                  connections=node.getIncomingConnections(EConnectionType.valueOf(varNames[2]));
                }
              }
 else {
                if ("String_Node_Str".equals(varNames[2])) {
                  connections=node.getOutgoingConnections();
                }
 else {
                  connections=node.getOutgoingConnections(EConnectionType.valueOf(varNames[2]));
                }
              }
              try {
                int connSize=connections.size();
                int targetNumber=Integer.parseInt(variableValue);
                if (GREAT_THAN.equals(test)) {
                  return connSize > targetNumber;
                }
 else                 if (LESS_THAN.equals(test)) {
                  return connSize < targetNumber;
                }
 else                 if (EQUALS.equals(test)) {
                  return connSize == targetNumber;
                }
 else                 if (NOT_EQUALS.equals(test)) {
                  return connSize != targetNumber;
                }
              }
 catch (              Exception e) {
              }
            }
 else {
              connections=node.getOutgoingConnections(EConnectionType.valueOf(varNames[1]));
              for (              IConnection c : connections) {
                IElementParameter elementParameter=c.getElementParameter(varNames[2]);
                if (variableValue.equals(elementParameter.getValue())) {
                  return true;
                }
              }
            }
          }
        }
      }
      return false;
    }
 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 IConnection) {
          INode sourceNode=((IConnection)element).getSource();
          simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str","String_Node_Str");
          return evaluate(simpleExpression,sourceNode.getElementParameters());
        }
      }
    }
 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 IConnection) {
          INode sourceNode=((IConnection)element).getTarget();
          simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str","String_Node_Str");
          return evaluate(simpleExpression,sourceNode.getElementParameters());
        }
      }
    }
  }
  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;
}
}
break;
}
}
}
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;
  }
 else   if (simpleExpression.contains(GREAT_THAN)) {
    test=GREAT_THAN;
  }
 else   if (simpleExpression.contains(LESS_THAN)) {
    test=LESS_THAN;
  }
  if ((simpleExpression.contains("String_Node_Str") || simpleExpression.contains("String_Node_Str")) && simpleExpression.endsWith("String_Node_Str")) {
    return evaluateInExpression(simpleExpression,listParam);
  }
  List<String> paraNames=getParaNamesFromIsShowFunc(simpleExpression);
  if (paraNames.size() > 0) {
    String paraName=paraNames.get(0);
    try {
      checkIsShowLoop(paraName,simpleExpression,listParam,currentParam,null);
    }
 catch (    Exception e) {
      ExceptionHandler.process(e);
      return false;
    }
    for (    IElementParameter param : listParam) {
      if (paraName != null && paraName.equals(param.getName())) {
        return param.isShow(param.getShowIf(),param.getNotShowIf(),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;
  }
  if ("String_Node_Str".equals(variableName)) {
    boolean isTIS=PluginChecker.isTIS();
    if ("String_Node_Str".equals(variableValue)) {
      return isTIS;
    }
 else {
      return !isTIS;
    }
  }
  String[] varNames;
  varNames=StringUtils.split(variableName,'.');
  if ((variableName != null) && (variableValue != null)) {
    if (varNames[0].equals("String_Node_Str")) {
      INode node=null;
      if (currentParam != null && currentParam.getElement() instanceof INode) {
        node=(INode)currentParam.getElement();
      }
 else       if (currentParam == null) {
        if (listParam != null && listParam.size() > 0) {
          IElement element=listParam.get(0).getElement();
          if (element instanceof INode) {
            node=(INode)element;
          }
        }
      }
      if (node != null) {
        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) {
            List<? extends IConnection> connections=new ArrayList<IConnection>();
            if ("String_Node_Str".equals(varNames[1]) || "String_Node_Str".equals(varNames[1])) {
              if ("String_Node_Str".equals(varNames[1])) {
                if ("String_Node_Str".equals(varNames[2])) {
                  connections=node.getIncomingConnections();
                }
 else {
                  connections=node.getIncomingConnections(EConnectionType.valueOf(varNames[2]));
                }
              }
 else {
                if ("String_Node_Str".equals(varNames[2])) {
                  connections=node.getOutgoingConnections();
                }
 else {
                  connections=node.getOutgoingConnections(EConnectionType.valueOf(varNames[2]));
                }
              }
              try {
                int connSize=connections.size();
                int targetNumber=Integer.parseInt(variableValue);
                if (GREAT_THAN.equals(test)) {
                  return connSize > targetNumber;
                }
 else                 if (LESS_THAN.equals(test)) {
                  return connSize < targetNumber;
                }
 else                 if (EQUALS.equals(test)) {
                  return connSize == targetNumber;
                }
 else                 if (NOT_EQUALS.equals(test)) {
                  return connSize != targetNumber;
                }
              }
 catch (              Exception e) {
              }
            }
 else {
              connections=node.getOutgoingConnections(EConnectionType.valueOf(varNames[1]));
              for (              IConnection c : connections) {
                IElementParameter elementParameter=c.getElementParameter(varNames[2]);
                if (variableValue.equals(elementParameter.getValue())) {
                  return true;
                }
              }
            }
          }
        }
      }
      return false;
    }
 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 IConnection) {
          INode sourceNode=((IConnection)element).getSource();
          simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str","String_Node_Str");
          return evaluate(simpleExpression,sourceNode.getElementParameters());
        }
      }
    }
 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 IConnection) {
          INode sourceNode=((IConnection)element).getTarget();
          simpleExpression=simpleExpression.replace(varNames[0] + "String_Node_Str","String_Node_Str");
          return evaluate(simpleExpression,sourceNode.getElementParameters());
        }
      }
    }
  }
  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;
}
}
break;
}
}
}
return showParameter;
}