Program: 136878
Project: 136878
Buggy source:
/** 
 * Method "generateDuplicate". This method is called when the input is a Integer.
 * @param valueIn The input sent to the function.
 * @param function The function used on the date parameter (see the enum Function).
 * @param extraParameter A parameter required by some functions (eg, Numeric Variance).
 * @return This method returns a Integer after the application of the parameter function.
 */
public Integer generateDuplicate(Integer valueIn,Function function,String extraParameter){
  if (function == Function.SET_TO_NULL) {
    return null;
  }
  if (valueIn == null) {
    return 0;
  }
  Integer finalValue=null;
switch (function) {
case NUMERIC_VARIANCE:
    Integer extraParam;
  try {
    extraParam=Integer.parseInt(extraParameter);
  }
 catch (  NumberFormatException e) {
    extraParam=10;
  }
if (extraParam < 0) {
  extraParam*=-1;
}
 else if (extraParam == 0) {
  extraParam=10;
}
int rate=0;
do {
rate=rnd.nextInt(2 * extraParam) - extraParam;
}
 while (rate == 0);
Float value=Float.parseFloat(valueIn.toString());
value*=((float)rate + 100) / 100;
finalValue=new Integer(Math.round(value));
break;
case REPLACE_NUMERIC:
try {
extraParam=Integer.parseInt(extraParameter);
}
 catch (NumberFormatException e) {
extraParam=0;
}
if (extraParam < 0) {
extraParam=0;
}
String str=valueIn.toString();
String res=str.replaceAll("String_Node_Str",extraParam.toString());
finalValue=Integer.valueOf(res);
break;
case GENERATE_BETWEEN:
String[] parameters=extraParameter.split("String_Node_Str");
if (parameters.length != 2) {
finalValue=0;
}
 else {
int a=0;
int b=0;
try {
a=Integer.valueOf(parameters[0].trim());
b=Integer.valueOf(parameters[1].trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
int min=(a < b) ? a : b;
int max=(a < b) ? b : a;
finalValue=rnd.nextInt((max - min) + 1) + min;
}
break;
case GENERATE_FROM_LIST:
String[] parameterss=extraParameter.split("String_Node_Str");
int[] parametersI=new int[parameterss.length];
if (parameterss.length > 0) {
for (int i=0; i < parameterss.length; ++i) {
String tmp=parameterss[i].replaceAll("String_Node_Str",EMPTY_STRING);
try {
parametersI[i]=Integer.parseInt(tmp);
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=parametersI[rnd.nextInt(parametersI.length)];
}
 else {
finalValue=0;
}
break;
case GENERATE_FROM_FILE:
try {
@SuppressWarnings("String_Node_Str") Scanner in=new Scanner(new FileReader(extraParameter));
List<Integer> tokens=new ArrayList<Integer>();
while (in.hasNext()) {
try {
tokens.add(Integer.parseInt(in.next()));
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=tokens.get(rnd.nextInt(tokens.size()));
}
 catch (FileNotFoundException e) {
finalValue=0;
}
break;
case HASH_GENERATE_LIST:
String[] parametersh=extraParameter.split("String_Node_Str");
int[] parametersIh=new int[parametersh.length];
if (parametersIh.length > 0) {
for (int i=0; i < parametersh.length; ++i) {
String tmp=parametersh[i].replaceAll("String_Node_Str",EMPTY_STRING);
try {
parametersIh[i]=Integer.parseInt(tmp);
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=parametersIh[Math.abs(valueIn.hashCode()) % parametersIh.length];
}
 else {
finalValue=0;
}
break;
case HASH_GENERATE_FILE:
try {
@SuppressWarnings("String_Node_Str") Scanner in=new Scanner(new FileReader(extraParameter));
List<Integer> tokens=new ArrayList<Integer>();
while (in.hasNext()) {
try {
tokens.add(Integer.parseInt(in.next()));
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=tokens.get(Math.abs(valueIn.hashCode()) % tokens.size());
}
 catch (FileNotFoundException e) {
finalValue=0;
}
break;
case REMOVE_FIRST_CHARS:
Integer extra=null;
try {
extra=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if ((int)Math.log10(valueIn) + 1 <= extra || extra < 0) {
finalValue=0;
break;
}
StringBuilder sb=new StringBuilder(valueIn.toString().substring(extra));
finalValue=Integer.parseInt(sb.toString());
break;
case REMOVE_LAST_CHARS:
Integer extraP=null;
try {
extraP=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if ((int)Math.log10(valueIn) + 1 <= extraP || extraP < 0) {
finalValue=0;
break;
}
finalValue=valueIn / (int)Math.pow(10.0,extraP);
break;
case REPLACE_FIRST_CHARS:
Integer extraPa=null;
try {
extraPa=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if (extraPa < 0) {
finalValue=0;
break;
}
extraPa=((int)Math.log10(valueIn) + 1 <= extraPa) ? (int)Math.log10(valueIn) + 1 : extraPa;
StringBuilder sbu=new StringBuilder(valueIn.toString());
StringBuilder remp=new StringBuilder(EMPTY_STRING);
for (int i=0; i < extraPa; ++i) {
remp.append(rnd.nextInt(9));
}
sbu.replace(0,extraPa,remp.toString());
finalValue=Integer.parseInt(sbu.toString());
break;
case REPLACE_LAST_CHARS:
Integer extraPar=null;
try {
extraPar=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if (extraPar < 0) {
finalValue=0;
break;
}
extraPar=((int)Math.log10(valueIn) + 1 <= extraPar) ? (int)Math.log10(valueIn) + 1 : extraPar;
StringBuilder sbui=new StringBuilder(valueIn.toString());
StringBuilder rempl=new StringBuilder(EMPTY_STRING);
for (int i=0; i < extraPar; ++i) {
rempl.append(rnd.nextInt(9));
}
sbui.replace(sbui.length() - extraPar,sbui.length(),rempl.toString());
finalValue=Integer.parseInt(sbui.toString());
break;
default :
finalValue=0;
}
return finalValue;
}

Fixed version (ground truth):
/** 
 * Method "generateDuplicate". This method is called when the input is a Integer.
 * @param valueIn The input sent to the function.
 * @param function The function used on the date parameter (see the enum Function).
 * @param extraParameter A parameter required by some functions (eg, Numeric Variance).
 * @return This method returns a Integer after the application of the parameter function.
 */
public Integer generateDuplicate(Integer valueIn,Function function,String extraParameter){
  if (function == Function.SET_TO_NULL) {
    return null;
  }
  if (valueIn == null) {
    return 0;
  }
  Integer finalValue=null;
switch (function) {
case NUMERIC_VARIANCE:
    Integer extraParam;
  try {
    extraParam=Integer.parseInt(extraParameter);
  }
 catch (  NumberFormatException e) {
    extraParam=10;
  }
if (extraParam < 0) {
  extraParam*=-1;
}
 else if (extraParam == 0) {
  extraParam=10;
}
int rate=0;
do {
rate=rnd.nextInt(2 * extraParam) - extraParam;
}
 while (rate == 0);
Float value=Float.parseFloat(valueIn.toString());
value*=((float)rate + 100) / 100;
finalValue=new Integer(Math.round(value));
break;
case REPLACE_NUMERIC:
try {
extraParam=Integer.parseInt(extraParameter);
}
 catch (NumberFormatException e) {
extraParam=0;
}
if (extraParam < 0 || extraParam > 9) {
extraParam=0;
}
String str=valueIn.toString();
String res=str.replaceAll("String_Node_Str",extraParam.toString());
finalValue=Integer.valueOf(res);
break;
case GENERATE_BETWEEN:
String[] parameters=extraParameter.split("String_Node_Str");
if (parameters.length != 2) {
finalValue=0;
}
 else {
int a=0;
int b=0;
try {
a=Integer.valueOf(parameters[0].trim());
b=Integer.valueOf(parameters[1].trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
int min=(a < b) ? a : b;
int max=(a < b) ? b : a;
finalValue=rnd.nextInt((max - min) + 1) + min;
}
break;
case GENERATE_FROM_LIST:
String[] parameterss=extraParameter.split("String_Node_Str");
int[] parametersI=new int[parameterss.length];
if (parameterss.length > 0) {
for (int i=0; i < parameterss.length; ++i) {
String tmp=parameterss[i].replaceAll("String_Node_Str",EMPTY_STRING);
try {
parametersI[i]=Integer.parseInt(tmp);
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=parametersI[rnd.nextInt(parametersI.length)];
}
 else {
finalValue=0;
}
break;
case GENERATE_FROM_FILE:
try {
@SuppressWarnings("String_Node_Str") Scanner in=new Scanner(new FileReader(extraParameter));
List<Integer> tokens=new ArrayList<Integer>();
while (in.hasNext()) {
try {
tokens.add(Integer.parseInt(in.next()));
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=tokens.get(rnd.nextInt(tokens.size()));
}
 catch (FileNotFoundException e) {
finalValue=0;
}
break;
case HASH_GENERATE_LIST:
String[] parametersh=extraParameter.split("String_Node_Str");
int[] parametersIh=new int[parametersh.length];
if (parametersIh.length > 0) {
for (int i=0; i < parametersh.length; ++i) {
String tmp=parametersh[i].replaceAll("String_Node_Str",EMPTY_STRING);
try {
parametersIh[i]=Integer.parseInt(tmp);
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=parametersIh[Math.abs(valueIn.hashCode()) % parametersIh.length];
}
 else {
finalValue=0;
}
break;
case HASH_GENERATE_FILE:
try {
@SuppressWarnings("String_Node_Str") Scanner in=new Scanner(new FileReader(extraParameter));
List<Integer> tokens=new ArrayList<Integer>();
while (in.hasNext()) {
try {
tokens.add(Integer.parseInt(in.next()));
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
}
finalValue=tokens.get(Math.abs(valueIn.hashCode()) % tokens.size());
}
 catch (FileNotFoundException e) {
finalValue=0;
}
break;
case REMOVE_FIRST_CHARS:
Integer extra=null;
try {
extra=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if ((int)Math.log10(valueIn) + 1 <= extra || extra < 0) {
finalValue=0;
break;
}
StringBuilder sb=new StringBuilder(valueIn.toString().substring(extra));
finalValue=Integer.parseInt(sb.toString());
break;
case REMOVE_LAST_CHARS:
Integer extraP=null;
try {
extraP=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if ((int)Math.log10(valueIn) + 1 <= extraP || extraP < 0) {
finalValue=0;
break;
}
finalValue=valueIn / (int)Math.pow(10.0,extraP);
break;
case REPLACE_FIRST_CHARS:
Integer extraPa=null;
try {
extraPa=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if (extraPa < 0) {
finalValue=0;
break;
}
extraPa=((int)Math.log10(valueIn) + 1 <= extraPa) ? (int)Math.log10(valueIn) + 1 : extraPa;
StringBuilder sbu=new StringBuilder(valueIn.toString());
StringBuilder remp=new StringBuilder(EMPTY_STRING);
for (int i=0; i < extraPa; ++i) {
remp.append(rnd.nextInt(9));
}
sbu.replace(0,extraPa,remp.toString());
finalValue=Integer.parseInt(sbu.toString());
break;
case REPLACE_LAST_CHARS:
Integer extraPar=null;
try {
extraPar=Integer.parseInt(extraParameter.trim());
}
 catch (NumberFormatException e) {
finalValue=0;
break;
}
if (extraPar < 0) {
finalValue=0;
break;
}
extraPar=((int)Math.log10(valueIn) + 1 <= extraPar) ? (int)Math.log10(valueIn) + 1 : extraPar;
StringBuilder sbui=new StringBuilder(valueIn.toString());
StringBuilder rempl=new StringBuilder(EMPTY_STRING);
for (int i=0; i < extraPar; ++i) {
rempl.append(rnd.nextInt(9));
}
sbui.replace(sbui.length() - extraPar,sbui.length(),rempl.toString());
finalValue=Integer.parseInt(sbui.toString());
break;
default :
finalValue=0;
}
return finalValue;
}