nus-yam/ex-repair huggingface dataset:
Program: 163415
Project: 163415
Buggy source:
@Test public void ensureExceptionsAreThrown(){
  CsvParserSettings parserSettings=new CsvParserSettings();
  BeanListProcessor<AB> beanProcessor=new BeanListProcessor<AB>(AB.class);
  parserSettings.setRowProcessor(beanProcessor);
  CsvParser parser=new CsvParser(parserSettings);
  try {
    parser.parse(new StringReader("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  TextParsingException e) {
  }
}

Fixed version (ground truth):
/** 
 * As of https://github.com/uniVocity/univocity-parsers/issues/48, this test is no longer valid by default Originally the parser would force an exact match of headers declared in the bean and in the input. With the changes introduced in Github_48, the parsing process became less strict to allow beans to be loaded using inputs with varying number of columns. When a column is not found in the input the values attributed to the bean will be considered null. If conversions are defined for that field, they will be applied over the null value. To keep getting errors when headers are not fully matched, enable the strict header validation using  {@link BeanProcessor#setStrictHeaderValidationEnabled(boolean)}
 */
@Test public void ensureExceptionsAreThrown(){
  CsvParserSettings parserSettings=new CsvParserSettings();
  BeanListProcessor<AB> beanProcessor=new BeanListProcessor<AB>(AB.class);
  beanProcessor.setStrictHeaderValidationEnabled(true);
  parserSettings.setRowProcessor(beanProcessor);
  CsvParser parser=new CsvParser(parserSettings);
  try {
    parser.parse(new StringReader("String_Node_Str"));
    fail("String_Node_Str");
  }
 catch (  TextParsingException e) {
  }
}
Program: 163416
Project: 163416
Buggy source:
/** 
 * In case of any exceptions, a   {@link TextWritingException} is thrown, and the output {@link java.io.Writer} is closed.
 * @param message Description of the error
 * @param recordValues values used to write to the output at the time the exception happened
 * @param cause the exception to be wrapped by a {@link TextWritingException}
 */
private TextWritingException throwExceptionAndClose(String message,Object[] recordValues,Throwable cause){
  try {
    throw new TextWritingException(message,recordCount,recordValues,cause);
  }
  finally {
    close();
  }
}

Fixed version (ground truth):
/** 
 * In case of any exceptions, a   {@link TextWritingException} is thrown, and the output {@link java.io.Writer} is closed.
 * @param message Description of the error
 * @param recordValues values used to write to the output at the time the exception happened
 * @param cause the exception to be wrapped by a {@link TextWritingException}
 */
private TextWritingException throwExceptionAndClose(String message,Object[] recordValues,Throwable cause){
  try {
    throw new TextWritingException(message,recordCount,recordValues,cause);
  }
  finally {
    try {
      close();
    }
 catch (    Throwable t) {
    }
  }
}
Program: 163417
Project: 163417
Buggy source:
/** 
 * Used when fields were selected and the input rows have a different order than the output. This method fills the internal #outputRow array with the values provided by the user in the correct order.
 * @param row user-provided data which has to be rearranged to the expected record sequence before writing to the output.
 */
private <T>void fillOutputRow(T[] row){
  if (row.length > indexesToWrite.length) {
    String msg="String_Node_Str" + this.indexesToWrite.length + "String_Node_Str"+ row.length+ "String_Node_Str";
    throwExceptionAndClose(msg,headers,null);
  }
  for (int i=0; i < indexesToWrite.length && i < row.length; i++) {
    outputRow[indexesToWrite[i]]=row[i];
  }
}

Fixed version (ground truth):
/** 
 * Used when fields were selected and the input rows have a different order than the output. This method fills the internal #outputRow array with the values provided by the user in the correct order.
 * @param row user-provided data which has to be rearranged to the expected record sequence before writing to the output.
 */
private <T>void fillOutputRow(T[] row){
  if (row.length > outputRow.length) {
    outputRow=row;
  }
 else   if (row.length > indexesToWrite.length) {
    for (int i=0; i < indexesToWrite.length; i++) {
      outputRow[indexesToWrite[i]]=row[indexesToWrite[i]];
    }
  }
 else {
    for (int i=0; i < indexesToWrite.length && i < row.length; i++) {
      outputRow[indexesToWrite[i]]=row[i];
    }
  }
}
Program: 163418
Project: 163418
Buggy source:
void processField(Field field,PropertyDescriptor propertyDescriptor){
  Parsed annotation=field.getAnnotation(Parsed.class);
  if (annotation != null) {
    FieldMapping mapping=new FieldMapping(beanClass,field,propertyDescriptor);
    parsedFields.add(mapping);
    setupConversions(field,mapping);
  }
}

Fixed version (ground truth):
/** 
 * Determines whether or not an annotated field should be processed. Can be overridden by subclasses for fine grained control.
 * @param field the field to be processed
 * @return {@code true} if the given field should be processed, otherwise {@code false}.
 */
protected boolean processField(FieldMapping field){
  return true;
}
Program: 163420
Project: 163420
Buggy source:
/** 
 * Converts a java bean instance into a sequence of values for writing.
 * @param bean           an instance of the type defined in this class constructor.
 * @param headers        All field names used to produce records in a given destination. May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexesToWrite The indexes of the headers that are actually being written. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @return a row of objects containing the values extracted from the java bean
 */
public final Object[] reverseConversions(T bean,String[] headers,int[] indexesToWrite){
  if (bean == null) {
    return null;
  }
  Object[] row;
  if (indexesToWrite != null) {
    row=new Object[indexesToWrite.length];
  }
 else   if (headers != null) {
    row=new Object[headers.length];
  }
 else {
    throw new TextWritingException("String_Node_Str" + bean.getClass().getName() + "String_Node_Str",-1,new Object[]{bean});
  }
  try {
    mapFieldsToValues(bean,row,headers,indexesToWrite,false);
  }
 catch (  DataProcessingException ex) {
    ex.markAsNonFatal();
    if (!beanClass.isAssignableFrom(bean.getClass())) {
      handleConversionError(ex,new Object[]{bean},-1);
    }
 else {
      handleConversionError(ex,row,-1);
    }
    return null;
  }
  if (super.reverseConversions(true,row,headers,indexesToWrite)) {
    return row;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Converts a java bean instance into a sequence of values for writing.
 * @param bean           an instance of the type defined in this class constructor.
 * @param headers        All field names used to produce records in a given destination. May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexesToWrite The indexes of the headers that are actually being written. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @return a row of objects containing the values extracted from the java bean
 */
public final Object[] reverseConversions(T bean,String[] headers,int[] indexesToWrite){
  if (bean == null) {
    return null;
  }
  Object[] row;
  if (headers != null) {
    row=new Object[headers.length];
  }
 else   if (indexesToWrite != null) {
    row=new Object[indexesToWrite.length];
  }
 else {
    throw new TextWritingException("String_Node_Str" + bean.getClass().getName() + "String_Node_Str",-1,new Object[]{bean});
  }
  try {
    mapFieldsToValues(bean,row,headers,indexesToWrite,false);
  }
 catch (  DataProcessingException ex) {
    ex.markAsNonFatal();
    if (!beanClass.isAssignableFrom(bean.getClass())) {
      handleConversionError(ex,new Object[]{bean},-1);
    }
 else {
      handleConversionError(ex,row,-1);
    }
    return null;
  }
  if (super.reverseConversions(true,row,headers,indexesToWrite)) {
    return row;
  }
  return null;
}
Program: 163421
Project: 163421
Buggy source:
/** 
 * Converts the java bean instance into a sequence of values for writing.
 * @param input an instance of the type defined in this class constructor.
 * @param headers All field names used to produce records in a given destination. May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexesToWrite The indexes of the headers that are actually being written. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @return a row of objects containing the values extracted from the java bean
 */
@Override public Object[] write(T input,String[] headers,int[] indexesToWrite){
  super.initialize();
  return reverseConversions(input,headers,indexesToWrite);
}

Fixed version (ground truth):
/** 
 * Converts the java bean instance into a sequence of values for writing.
 * @param input an instance of the type defined in this class constructor.
 * @param headers All field names used to produce records in a given destination. May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexesToWrite The indexes of the headers that are actually being written. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @return a row of objects containing the values extracted from the java bean
 */
@Override public Object[] write(T input,String[] headers,int[] indexesToWrite){
  if (!initialized) {
    this.headers=headers;
    super.initialize();
    this.headers=null;
  }
  return reverseConversions(input,headers,indexesToWrite);
}
Program: 163422
Project: 163422
Buggy source:
/** 
 * Defines a conversion from String to   {@link java.math.BigDecimal} using a sequence of acceptable numeric patterns.This constructor assumes the output of a conversion should be null when input is null
 * @param numericFormats list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in <code>revert(BigDecimal)</code>.
 */
public FormattedBigDecimalConversion(String... numericFormats){
  super(numericFormats);
}

Fixed version (ground truth):
/** 
 * Defines a conversion from String to   {@link java.math.BigDecimal} using a sequence of acceptable numeric patterns. The patternsmust be added to this conversion class through the  {@link #addFormat(String,String)} method.This constructor assumes the output of a conversion should be null when input is null
 */
public FormattedBigDecimalConversion(){
  super();
}
Program: 163423
Project: 163423
Buggy source:
/** 
 * Defines a conversion from String to   {@link java.lang.Number} using a sequence of acceptable numeric patterns.This constructor assumes the output of a conversion should be null when input is null
 * @param numericFormats list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String in {@link NumericConversion#revert(Number)}.
 */
public NumericConversion(String... numericFormats){
  this(null,null,numericFormats);
}

Fixed version (ground truth):
/** 
 * Defines a conversion from String to   {@link java.lang.Number} using a sequence of acceptable numeric patterns. The patternsmust be added to this conversion class through the  {@link #addFormat(String,String)} method.This constructor assumes the output of a conversion should be null when input is null
 */
public NumericConversion(){
  super();
}
Program: 163424
Project: 163424
Buggy source:
/** 
 * Converts a formatted numeric String to an instance of Number. <p>The pattern in the formatted input must match one of the numeric patterns provided in the constructor of this class.
 * @param input the String containing a formatted number which must be converted to a number
 * @return the Number instance containing the value represented by the given String, or the value of {@link ObjectConversion#getValueIfStringIsNull()} if the String input is null.
 */
@SuppressWarnings("String_Node_Str") @Override protected T fromString(String input){
  for (  DecimalFormat formatter : formatters) {
    try {
      return (T)formatter.parse(input);
    }
 catch (    ParseException ex) {
    }
  }
  throw new IllegalArgumentException("String_Node_Str" + input + "String_Node_Str"+ Arrays.toString(formats));
}

Fixed version (ground truth):
/** 
 * Converts a formatted numeric String to an instance of Number. <p>The pattern in the formatted input must match one of the numeric patterns provided in the constructor of this class.
 * @param input the String containing a formatted number which must be converted to a number
 * @return the Number instance containing the value represented by the given String, or the value of {@link ObjectConversion#getValueIfStringIsNull()} if the String input is null.
 */
@SuppressWarnings("String_Node_Str") @Override protected T fromString(String input){
  for (int i=0; i < formatters.length; i++) {
    position.setIndex(0);
    T out=(T)formatters[i].parse(input,position);
    if (position.getIndex() < input.length() && formatters.length > 1) {
      continue;
    }
 else {
      return out;
    }
  }
  throw new IllegalArgumentException("String_Node_Str" + input + "String_Node_Str"+ Arrays.toString(formats));
}
Program: 163425
Project: 163425
Buggy source:
private boolean quoteElement(String nextElement){
  if (quoteAllFields) {
    return true;
  }
  if (nextElement == null) {
    return false;
  }
  for (int j=0; j < nextElement.length(); j++) {
    char nextChar=nextElement.charAt(j);
    if (nextChar == separator || nextChar == newLine) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean quoteElement(String nextElement){
  if (quoteAllFields) {
    return true;
  }
  if (nextElement == null) {
    return false;
  }
  for (int j=0; j < nextElement.length(); j++) {
    char nextChar=nextElement.charAt(j);
    if (nextChar == separator || nextChar == newLine || nextChar == quotechar) {
      return true;
    }
  }
  return false;
}
Program: 163426
Project: 163426
Buggy source:
private boolean quoteElement(String nextElement){
  if (quoteAllFields) {
    return true;
  }
  if (nextElement == null) {
    return false;
  }
  for (int j=0; j < nextElement.length(); j++) {
    char nextChar=nextElement.charAt(j);
    if (nextChar == separator || nextChar == newLine) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean quoteElement(String nextElement){
  if (quoteAllFields) {
    return true;
  }
  if (nextElement == null) {
    return false;
  }
  for (int j=0; j < nextElement.length(); j++) {
    char nextChar=nextElement.charAt(j);
    if (nextChar == separator || nextChar == newLine || nextChar == quotechar) {
      return true;
    }
  }
  return false;
}
Program: 163427
Project: 163427
Buggy source:
/** 
 * Defines a conversion from String to   {@link java.math.BigDecimal} using a sequence of acceptable numeric patterns.This constructor assumes the output of a conversion should be null when input is null
 * @param numericFormats list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a BigDecimal into a String in <code>revert(BigDecimal)</code>.
 */
public FormattedBigDecimalConversion(String... numericFormats){
  super(numericFormats);
}

Fixed version (ground truth):
/** 
 * Defines a conversion from String to   {@link java.math.BigDecimal} using a sequence of acceptable numeric patterns. The patternsmust be added to this conversion class through the  {@link #addFormat(String,String)} method.This constructor assumes the output of a conversion should be null when input is null
 */
public FormattedBigDecimalConversion(){
  super();
}
Program: 163428
Project: 163428
Buggy source:
/** 
 * Defines a conversion from String to   {@link java.lang.Number} using a sequence of acceptable numeric patterns.This constructor assumes the output of a conversion should be null when input is null
 * @param numericFormats list of acceptable numeric patterns. The first pattern in this sequence will be used to convert a Number into a String in {@link NumericConversion#revert(Number)}.
 */
public NumericConversion(String... numericFormats){
  this(null,null,numericFormats);
}

Fixed version (ground truth):
/** 
 * Defines a conversion from String to   {@link java.lang.Number} using a sequence of acceptable numeric patterns. The patternsmust be added to this conversion class through the  {@link #addFormat(String,String)} method.This constructor assumes the output of a conversion should be null when input is null
 */
public NumericConversion(){
  super();
}
Program: 163429
Project: 163429
Buggy source:
/** 
 * Converts a formatted numeric String to an instance of Number. <p>The pattern in the formatted input must match one of the numeric patterns provided in the constructor of this class.
 * @param input the String containing a formatted number which must be converted to a number
 * @return the Number instance containing the value represented by the given String, or the value of {@link ObjectConversion#getValueIfStringIsNull()} if the String input is null.
 */
@SuppressWarnings("String_Node_Str") @Override protected T fromString(String input){
  for (  DecimalFormat formatter : formatters) {
    try {
      return (T)formatter.parse(input);
    }
 catch (    ParseException ex) {
    }
  }
  throw new DataProcessingException("String_Node_Str" + input + "String_Node_Str"+ Arrays.toString(formats));
}

Fixed version (ground truth):
/** 
 * Converts a formatted numeric String to an instance of Number. <p>The pattern in the formatted input must match one of the numeric patterns provided in the constructor of this class.
 * @param input the String containing a formatted number which must be converted to a number
 * @return the Number instance containing the value represented by the given String, or the value of {@link ObjectConversion#getValueIfStringIsNull()} if the String input is null.
 */
@SuppressWarnings("String_Node_Str") @Override protected T fromString(String input){
  for (int i=0; i < formatters.length; i++) {
    position.setIndex(0);
    T out=(T)formatters[i].parse(input,position);
    if (position.getIndex() < input.length() && formatters.length > 1) {
      continue;
    }
 else {
      return out;
    }
  }
  throw new DataProcessingException("String_Node_Str" + input + "String_Node_Str"+ Arrays.toString(formats));
}
Program: 163430
Project: 163430
Buggy source:
/** 
 * Configures the parser to process escape sequences in unquoted values. Defaults to   {@code false}. <p>By default, this is disabled and if the input is   {@code A""B,C}, the resulting value will be  {@code [A""B] and [C]} (i.e. the content is read as-is). However, if the parser is configured to process escape sequences in unquoted values, the result will be  {@code [A"B] and [C]}</p>
 * @param escapeUnquotedValues a flag indicating whether escape sequences should be processed in unquoted values 
 */
public void setEscapeUnquotedValues(boolean escapeUnquotedValues){
  this.escapeUnquotedValues=escapeUnquotedValues;
}

Fixed version (ground truth):
/** 
 * Configures the parser to process escape sequences in unquoted values. Defaults to   {@code false}. <p>By default, this is disabled and if the input is   {@code A""B,C}, the resulting value will be  {@code [A""B] and [C]} (i.e. the content is read as-is). However, if the parser is configuredto process escape sequences in unquoted values, the result will be  {@code [A"B] and [C]}</p>
 * @param escapeUnquotedValues a flag indicating whether escape sequences should be processed in unquoted values
 */
public void setEscapeUnquotedValues(boolean escapeUnquotedValues){
  this.escapeUnquotedValues=escapeUnquotedValues;
}
Program: 163431
Project: 163431
Buggy source:
/** 
 * Indicates whether escape sequences should be processed in unquoted values. Defaults to   {@code false}. <p>By default, this is disabled and if the input is   {@code A""B,C}, the resulting value will be  {@code [A""B] and [C]} (i.e. the content is read as-is). However, if the parser is configured to process escape sequences in unquoted values, the result will be  {@code [A"B] and [C]}</p>
 * @return true if escape sequences should be processed in unquoted values, otherwise false 
 */
public boolean isEscapeUnquotedValues(){
  return escapeUnquotedValues;
}

Fixed version (ground truth):
/** 
 * Indicates whether escape sequences should be processed in unquoted values. Defaults to   {@code false}. <p>By default, this is disabled and if the input is   {@code A""B,C}, the resulting value will be  {@code [A""B] and [C]} (i.e. the content is read as-is). However, if the parser is configuredto process escape sequences in unquoted values, the result will be  {@code [A"B] and [C]}</p>
 * @return true if escape sequences should be processed in unquoted values, otherwise false
 */
public boolean isEscapeUnquotedValues(){
  return escapeUnquotedValues;
}
Program: 163432
Project: 163432
Buggy source:
/** 
 * The CsvWriter supports all settings provided by   {@link CsvWriterSettings}, and requires this configuration to be properly initialized.
 * @param writer the output resource that will receive CSV records produced by this class.
 * @param settings the CSV writer configuration
 */
public CsvWriter(Writer writer,CsvWriterSettings settings){
  super(writer,settings);
  CsvFormat format=settings.getFormat();
  this.separator=format.getDelimiter();
  this.quotechar=format.getQuote();
  this.escapechar=format.getQuoteEscape();
  this.newLine=format.getNormalizedNewline();
  this.quoteAllFields=settings.getQuoteAllFields();
  this.ignoreLeading=settings.getIgnoreLeadingWhitespaces();
  this.ignoreTrailing=settings.getIgnoreTrailingWhitespaces();
}

Fixed version (ground truth):
/** 
 * The CsvWriter supports all settings provided by   {@link CsvWriterSettings}, and requires this configuration to be properly initialized.
 * @param writer the output resource that will receive CSV records produced by this class.
 * @param settings the CSV writer configuration
 */
public CsvWriter(Writer writer,CsvWriterSettings settings){
  super(writer,settings);
  CsvFormat format=settings.getFormat();
  this.separator=format.getDelimiter();
  this.quotechar=format.getQuote();
  this.escapechar=format.getQuoteEscape();
  this.escapeEscape=settings.getFormat().getCharToEscapeQuoteEscaping();
  this.newLine=format.getNormalizedNewline();
  this.quoteAllFields=settings.getQuoteAllFields();
  this.ignoreLeading=settings.getIgnoreLeadingWhitespaces();
  this.ignoreTrailing=settings.getIgnoreTrailingWhitespaces();
  this.escapeUnquoted=settings.isEscapeUnquotedValues();
}
Program: 163433
Project: 163433
Buggy source:
private void append(boolean isElementQuoted,String element){
  if (element == null) {
    element=nullValue;
  }
  if (element == null) {
    return;
  }
  int start=0;
  if (this.ignoreLeading) {
    start=skipLeadingWhitespace(element);
  }
  if (this.ignoreTrailing) {
    for (int i=start; i < element.length(); i++) {
      char nextChar=element.charAt(i);
      if (isElementQuoted && nextChar == quotechar) {
        appender.appendIgnoringWhitespace(escapechar);
      }
      appender.appendIgnoringWhitespace(nextChar);
    }
  }
 else {
    for (int i=start; i < element.length(); i++) {
      char nextChar=element.charAt(i);
      if (isElementQuoted && nextChar == quotechar) {
        appender.append(escapechar);
      }
      appender.append(nextChar);
    }
  }
}

Fixed version (ground truth):
private void append(boolean isElementQuoted,String element){
  if (element == null) {
    element=nullValue;
  }
  if (element == null) {
    return;
  }
  int start=0;
  if (this.ignoreLeading) {
    start=skipLeadingWhitespace(element);
  }
  if (this.ignoreTrailing) {
    for (int i=start; i < element.length(); i++) {
      char nextChar=element.charAt(i);
      if (nextChar == quotechar && (isElementQuoted || escapeUnquoted)) {
        appender.appendIgnoringWhitespace(escapechar);
      }
 else       if (nextChar == escapechar && escapeEscape != '\0' && (isElementQuoted || escapeUnquoted)) {
        appender.appendIgnoringWhitespace(escapeEscape);
      }
      appender.appendIgnoringWhitespace(nextChar);
    }
  }
 else {
    for (int i=start; i < element.length(); i++) {
      char nextChar=element.charAt(i);
      if (nextChar == quotechar && (isElementQuoted || escapeUnquoted)) {
        appender.append(escapechar);
      }
 else       if (nextChar == escapechar && escapeEscape != '\0' && (isElementQuoted || escapeUnquoted)) {
        appender.appendIgnoringWhitespace(escapeEscape);
      }
      appender.append(nextChar);
    }
  }
}
Program: 163434
Project: 163434
Buggy source:
@Override protected void addConfiguration(Map<String,Object> out){
  super.addConfiguration(out);
  out.put("String_Node_Str",quoteAllFields);
}

Fixed version (ground truth):
@Override protected void addConfiguration(Map<String,Object> out){
  super.addConfiguration(out);
  out.put("String_Node_Str",quoteAllFields);
  out.put("String_Node_Str",escapeUnquotedValues);
}
Program: 163435
Project: 163435
Buggy source:
private void setAlignment(FieldAlignment alignment,int position){
  if (alignment == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  validateIndex(position);
  this.fieldAlignment.set(position,alignment);
}

Fixed version (ground truth):
private void setAlignment(int position,FieldAlignment alignment){
  if (alignment == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  validateIndex(position);
  this.fieldAlignment.set(position,alignment);
}
Program: 163437
Project: 163437
Buggy source:
/** 
 * Iterates over all fields in the java bean instance and extracts its values.
 * @param instance the java bean instance to be read
 * @param row object array that will receive the values extracted from java bean
 * @param headers The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexes The indexes of the headers or row that are actually being used. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @param columnsReordered Indicates the indexes provided were reordered and do not match the original sequence of headers.
 */
private void mapFieldsToValues(T instance,Object[] row,String[] headers,int[] indexes,boolean columnsReordered){
  if (!fieldIndexesMapped) {
    mapFieldIndexes(row,headers,indexes,columnsReordered);
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  for (int i=0; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      row[i]=field.read(instance);
    }
  }
}

Fixed version (ground truth):
/** 
 * Iterates over all fields in the java bean instance and extracts its values.
 * @param instance the java bean instance to be read
 * @param row object array that will receive the values extracted from java bean
 * @param headers The names of all fields of the record (including any header that is not mapped to the java bean). May be null if no headers have been defined in {@link CommonSettings#getHeaders()}
 * @param indexes The indexes of the headers or row that are actually being used. May be null if no fields have been selected using {@link CommonSettings#selectFields(String)} or {@link CommonSettings#selectIndexes(Integer)}
 * @param columnsReordered Indicates the indexes provided were reordered and do not match the original sequence of headers.
 */
private void mapFieldsToValues(T instance,Object[] row,String[] headers,int[] indexes,boolean columnsReordered){
  if (row.length > this.lastFieldIndexMapped) {
    mapFieldIndexes(row,headers,indexes,columnsReordered);
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  for (int i=0; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      row[i]=field.read(instance);
    }
  }
}
Program: 163438
Project: 163438
Buggy source:
/** 
 * Identifies and extracts fields annotated with the   {@link Parsed} annotation
 */
protected final void initialize(){
  if (!initialized) {
    initialized=true;
    Map<String,PropertyDescriptor> properties=new HashMap<String,PropertyDescriptor>();
    try {
      BeanInfo beanInfo=Introspector.getBeanInfo(beanClass,Object.class);
      for (      PropertyDescriptor property : beanInfo.getPropertyDescriptors()) {
        String name=property.getName();
        properties.put(name,property);
      }
    }
 catch (    IntrospectionException e) {
    }
    Field[] declared=beanClass.getDeclaredFields();
    for (    Field field : declared) {
      Parsed annotation=field.getAnnotation(Parsed.class);
      if (annotation != null) {
        FieldMapping mapping=new FieldMapping(beanClass,field,properties.get(field.getName()));
        parsedFields.add(mapping);
        setupConversions(field,mapping);
      }
    }
    readOrder=null;
    fieldIndexesMapped=false;
  }
}

Fixed version (ground truth):
/** 
 * Identifies and extracts fields annotated with the   {@link Parsed} annotation
 */
protected final void initialize(){
  if (!initialized) {
    initialized=true;
    Map<String,PropertyDescriptor> properties=new HashMap<String,PropertyDescriptor>();
    try {
      BeanInfo beanInfo=Introspector.getBeanInfo(beanClass,Object.class);
      for (      PropertyDescriptor property : beanInfo.getPropertyDescriptors()) {
        String name=property.getName();
        properties.put(name,property);
      }
    }
 catch (    IntrospectionException e) {
    }
    Field[] declared=beanClass.getDeclaredFields();
    for (    Field field : declared) {
      Parsed annotation=field.getAnnotation(Parsed.class);
      if (annotation != null) {
        FieldMapping mapping=new FieldMapping(beanClass,field,properties.get(field.getName()));
        parsedFields.add(mapping);
        setupConversions(field,mapping);
      }
    }
    readOrder=null;
    lastFieldIndexMapped=-1;
  }
}
Program: 163439
Project: 163439
Buggy source:
/** 
 * Goes through a list of objects and associates each value to a particular field of a java bean instance
 * @param instance the java bean instance that is going to have its properties set
 * @param row the values to associate with each field of the javabean.
 * @param context information about the current parsing process.
 */
private void mapValuesToFields(T instance,Object[] row,ParsingContext context){
  if (!fieldIndexesMapped) {
    mapFieldIndexes(row,context.headers(),context.extractedFieldIndexes(),context.columnsReordered());
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  for (int i=0; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      Object value=row[i];
      field.write(instance,value);
    }
  }
}

Fixed version (ground truth):
/** 
 * Goes through a list of objects and associates each value to a particular field of a java bean instance
 * @param instance the java bean instance that is going to have its properties set
 * @param row the values to associate with each field of the javabean.
 * @param context information about the current parsing process.
 */
private void mapValuesToFields(T instance,Object[] row,ParsingContext context){
  if (row.length > lastFieldIndexMapped) {
    this.lastFieldIndexMapped=row.length;
    mapFieldIndexes(row,context.headers(),context.extractedFieldIndexes(),context.columnsReordered());
  }
  int last=row.length < readOrder.length ? row.length : readOrder.length;
  for (int i=0; i < last; i++) {
    FieldMapping field=readOrder[i];
    if (field != null) {
      Object value=row[i];
      field.write(instance,value);
    }
  }
}
Program: 163440
Project: 163440
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    throw new EOFException();
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      throw new EOFException();
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          throw new EOFException();
        }
      }
      if (i < length) {
        i++;
      }
    }
  }
  return ch;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public final char nextChar(){
  if (length == -1) {
    throw new EOFException();
  }
  char ch=buffer[i - 1];
  if (i >= length) {
    if (length != -1) {
      updateBuffer();
    }
 else {
      throw new EOFException();
    }
  }
  i++;
  if (lineSeparator1 == ch && (lineSeparator2 == '\0' || lineSeparator2 == buffer[i - 1])) {
    lineCount++;
    if (lineSeparator2 != '\0') {
      ch=normalizedLineSeparator;
      if (i >= length) {
        if (length != -1) {
          updateBuffer();
        }
 else {
          throw new EOFException();
        }
      }
      if (i < length) {
        i++;
      }
    }
 else {
      return normalizedLineSeparator;
    }
  }
  return ch;
}
Program: 163441
Project: 163441
Buggy source:
private void parseQuotedValue(char prev){
  ch=input.nextChar();
  while (!(prev == quote && (ch == delimiter || ch == newLine || ch <= ' '))) {
    if (ch != quote) {
      if (prev == quote) {
        if (parseUnescapedQuotes) {
          output.appender.append(quote);
          output.appender.append(ch);
          parseQuotedValue(ch);
          break;
        }
 else {
          throw new TextParsingException(context,"String_Node_Str" + quote + "String_Node_Str");
        }
      }
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      output.appender.append(quote);
      prev='\0';
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch != newLine && ch <= ' ') {
    whitespaceAppender.reset();
    do {
      whitespaceAppender.append(ch);
      ch=input.nextChar();
      if (ch == newLine) {
        return;
      }
    }
 while (ch <= ' ');
    if (!(ch == delimiter || ch == newLine) && parseUnescapedQuotes) {
      if (output.appender instanceof DefaultCharAppender) {
        output.appender.append(quote);
        ((DefaultCharAppender)output.appender).append(whitespaceAppender);
      }
      if (ch != quoteEscape) {
        output.appender.append(ch);
      }
      parseQuotedValue(ch);
    }
  }
  if (!(ch == delimiter || ch == newLine)) {
    throw new TextParsingException(context,"String_Node_Str" + ch + "String_Node_Str"+ delimiter+ "String_Node_Str");
  }
}

Fixed version (ground truth):
private void parseQuotedValue(char prev){
  ch=input.nextChar();
  while (!(prev == quote && (ch <= ' ' || ch == delimiter || ch == newLine))) {
    if (ch != quote && ch != quoteEscape) {
      if (prev == quote) {
        if (parseUnescapedQuotes) {
          output.appender.append(quote);
          output.appender.append(ch);
          parseQuotedValue(ch);
          break;
        }
 else {
          throw new TextParsingException(context,"String_Node_Str" + quote + "String_Node_Str");
        }
      }
      output.appender.append(ch);
      prev=ch;
    }
 else     if (prev == quoteEscape) {
      if (ch == quote) {
        output.appender.append(quote);
        prev='\0';
      }
 else {
        output.appender.append(prev);
      }
    }
 else {
      prev=ch;
    }
    ch=input.nextChar();
  }
  if (ch != newLine && ch <= ' ') {
    whitespaceAppender.reset();
    do {
      whitespaceAppender.append(ch);
      ch=input.nextChar();
      if (ch == newLine) {
        return;
      }
    }
 while (ch <= ' ');
    if (!(ch == delimiter || ch == newLine) && parseUnescapedQuotes) {
      if (output.appender instanceof DefaultCharAppender) {
        output.appender.append(quote);
        ((DefaultCharAppender)output.appender).append(whitespaceAppender);
      }
      if (ch != quoteEscape) {
        output.appender.append(ch);
      }
      parseQuotedValue(ch);
    }
  }
  if (!(ch == delimiter || ch == newLine)) {
    throw new TextParsingException(context,"String_Node_Str" + ch + "String_Node_Str"+ delimiter+ "String_Node_Str");
  }
}
Program: 163443
Project: 163443
Buggy source:
/** 
 * Applies a sequence of conversions associated with an Object value at a given index in a record.
 * @param executeInReverseOrder flag to indicate whether or not the conversion sequence must be executed in reverse order
 * @param index The index of parsed value in a record
 * @param value The value in a record
 * @return the Object resulting from a sequence of conversions against the original value.
 */
@SuppressWarnings("String_Node_Str") public Object reverseConversions(boolean executeInReverseOrder,int index,Object value){
  List<Conversion<String,?>> conversions=conversionsByIndex.get(index);
  if (conversions != null) {
    Conversion<String,?> conversion=null;
    try {
      if (executeInReverseOrder) {
        for (int i=conversions.size() - 1; i >= 0; i--) {
          conversion=conversions.get(i);
          value=((Conversion<String,Object>)conversion).revert(value);
        }
      }
 else {
        for (        Conversion<String,?> c : conversions) {
          conversion=c;
          value=((Conversion<String,Object>)conversion).revert(value);
        }
      }
    }
 catch (    Exception ex) {
      if (conversion != null) {
        throw new IllegalStateException("String_Node_Str" + value + "String_Node_Str"+ conversion.getClass().getName(),ex);
      }
 else {
        throw new IllegalStateException("String_Node_Str" + value + "String_Node_Str",ex);
      }
    }
  }
  return value;
}

Fixed version (ground truth):
/** 
 * Applies a sequence of conversions associated with an Object value at a given index in a record.
 * @param executeInReverseOrder flag to indicate whether or not the conversion sequence must be executed in reverse order
 * @param index The index of parsed value in a record
 * @param value The value in a record
 * @return the Object resulting from a sequence of conversions against the original value.
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public Object reverseConversions(boolean executeInReverseOrder,int index,Object value){
  List<Conversion<?,?>> conversions=conversionsByIndex.get(index);
  if (conversions != null) {
    Conversion conversion=null;
    try {
      if (executeInReverseOrder) {
        for (int i=conversions.size() - 1; i >= 0; i--) {
          conversion=conversions.get(i);
          value=conversion.revert(value);
        }
      }
 else {
        for (        Conversion<?,?> c : conversions) {
          conversion=c;
          value=conversion.revert(value);
        }
      }
    }
 catch (    Exception ex) {
      if (conversion != null) {
        throw new IllegalStateException("String_Node_Str" + value + "String_Node_Str"+ conversion.getClass().getName(),ex);
      }
 else {
        throw new IllegalStateException("String_Node_Str" + value + "String_Node_Str",ex);
      }
    }
  }
  return value;
}
Program: 163444
Project: 163444
Buggy source:
/** 
 * Applies a sequence of conversions associated with a String value parsed from a given index.
 * @param index The index of parsed value in a record
 * @param stringValue The parsed value in a record
 * @return the Object produced by a sequence of conversions against the original String value.
 */
public Object applyConversions(int index,String stringValue){
  List<Conversion<String,?>> conversions=conversionsByIndex.get(index);
  if (conversions != null) {
    for (    Conversion<String,?> conversion : conversions) {
      Object result=null;
      try {
        result=conversion.execute(stringValue);
        if (result == null || result instanceof String) {
          stringValue=(String)result;
        }
 else {
          return result;
        }
      }
 catch (      Exception ex) {
        throw new IllegalStateException("String_Node_Str" + result + "String_Node_Str"+ conversion.getClass().getName(),ex);
      }
    }
  }
  return stringValue;
}

Fixed version (ground truth):
/** 
 * Applies a sequence of conversions associated with a String value parsed from a given index.
 * @param index The index of parsed value in a record
 * @param stringValue The parsed value in a record
 * @return the Object produced by a sequence of conversions against the original String value.
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public Object applyConversions(int index,String stringValue){
  List<Conversion<?,?>> conversions=conversionsByIndex.get(index);
  if (conversions != null) {
    Object result=stringValue;
    for (    Conversion conversion : conversions) {
      try {
        result=conversion.execute(result);
      }
 catch (      Exception ex) {
        throw new IllegalStateException("String_Node_Str" + result + "String_Node_Str"+ conversion.getClass().getName(),ex);
      }
    }
    return result;
  }
  return stringValue;
}
Program: 163445
Project: 163445
Buggy source:
/** 
 * Ensures an individual field does not have the same conversion object applied to it more than once.
 * @param selector the selection of fields
 * @param conversionsAtIndex the sequence of conversions applied to a given index
 * @param conversionsToAdd the sequence of conversions to add to conversionsAtIndex
 */
private void validateDuplicates(FieldSelector selector,List<Conversion<String,?>> conversionsAtIndex,Conversion<String,?>[] conversionsToAdd){
  for (  Conversion<String,?> toAdd : conversionsToAdd) {
    for (    Conversion<String,?> existing : conversionsAtIndex) {
      if (toAdd == existing) {
        throw new IllegalArgumentException("String_Node_Str" + toAdd.getClass().getName() + "String_Node_Str"+ selector.describe());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Ensures an individual field does not have the same conversion object applied to it more than once.
 * @param selector the selection of fields
 * @param conversionsAtIndex the sequence of conversions applied to a given index
 * @param conversionsToAdd the sequence of conversions to add to conversionsAtIndex
 */
private void validateDuplicates(FieldSelector selector,List<Conversion<?,?>> conversionsAtIndex,Conversion<?,?>[] conversionsToAdd){
  for (  Conversion<?,?> toAdd : conversionsToAdd) {
    for (    Conversion<?,?> existing : conversionsAtIndex) {
      if (toAdd == existing) {
        throw new IllegalArgumentException("String_Node_Str" + toAdd.getClass().getName() + "String_Node_Str"+ selector.describe());
      }
    }
  }
}
Program: 163446
Project: 163446
Buggy source:
@Override public final void processStarted(ParsingContext context){
  splitter.clearValuesAndHeaders();
  batchCount=0;
  batchesProcessed=0;
}

Fixed version (ground truth):
@Override public final void processStarted(ParsingContext context){
  splitter.reset();
  batchCount=0;
  batchesProcessed=0;
}
Program: 163447
Project: 163447
Buggy source:
@Override public final void rowProcessed(String[] row,ParsingContext context){
  splitter.addValuesToColumns(false,row,context);
  batchCount++;
  if (batchCount >= rowsPerBatch) {
    batchProcessed(batchCount);
    batchCount=0;
    splitter.clearValues();
    batchesProcessed++;
  }
}

Fixed version (ground truth):
@Override public final void rowProcessed(String[] row,ParsingContext context){
  splitter.addValuesToColumns(row,context);
  batchCount++;
  if (batchCount >= rowsPerBatch) {
    batchProcessed(batchCount);
    batchCount=0;
    splitter.clearValues();
    batchesProcessed++;
  }
}
Program: 163448
Project: 163448
Buggy source:
@Override public final void processStarted(ParsingContext context){
  super.processStarted(context);
  splitter.clearValuesAndHeaders();
  batchCount=0;
  batchesProcessed=0;
}

Fixed version (ground truth):
@Override public final void processStarted(ParsingContext context){
  super.processStarted(context);
  splitter.reset();
  batchCount=0;
  batchesProcessed=0;
}
Program: 163449
Project: 163449
Buggy source:
@Override public final void rowProcessed(Object[] row,ParsingContext context){
  splitter.addValuesToColumns(false,row,context);
  batchCount++;
  if (batchCount >= rowsPerBatch) {
    batchProcessed(batchCount);
    batchCount=0;
    splitter.clearValues();
    batchesProcessed++;
  }
}

Fixed version (ground truth):
@Override public final void rowProcessed(Object[] row,ParsingContext context){
  splitter.addValuesToColumns(row,context);
  batchCount++;
  if (batchCount >= rowsPerBatch) {
    batchProcessed(batchCount);
    batchCount=0;
    splitter.clearValues();
    batchesProcessed++;
  }
}
Program: 163450
Project: 163450
Buggy source:
@Override public final void processStarted(ParsingContext context){
  splitter.clearValuesAndHeaders();
}

Fixed version (ground truth):
@Override public final void processStarted(ParsingContext context){
  splitter.reset();
}
Program: 163451
Project: 163451
Buggy source:
@Override public final void rowProcessed(String[] row,ParsingContext context){
  splitter.addValuesToColumns(true,row,context);
}

Fixed version (ground truth):
@Override public final void rowProcessed(String[] row,ParsingContext context){
  splitter.addValuesToColumns(row,context);
}
Program: 163452
Project: 163452
Buggy source:
void clearValues(){
  this.columnValues=null;
}

Fixed version (ground truth):
/** 
 * Removes any column values previously processed
 */
void clearValues(){
  addNullsFrom=rowCount;
  this.columnValues=null;
}
Program: 163453
Project: 163453
Buggy source:
String[] getHeaders(){
  return headers;
}

Fixed version (ground truth):
/** 
 * Returns the headers of the input. This can be either the headers defined in   {@link CommonSettings#getHeaders()}or the headers parsed in the input when   {@link CommonSettings#getHeaders()}  equals to {@code true}
 * @return the headers of all records parsed.
 */
String[] getHeaders(){
  return headers;
}
Program: 163454
Project: 163454
Buggy source:
List<List<T>> getColumnValues(){
  return columnValues;
}

Fixed version (ground truth):
/** 
 * Returns the values processed for each column
 * @return a list of lists. The stored lists correspond to the position of the column processed from the input; Each listcontains the corresponding values parsed for a column, across multiple rows.
 */
List<List<T>> getColumnValues(){
  return columnValues;
}
Program: 163455
Project: 163455
Buggy source:
ColumnSplitter(int initialRowSize){
  if (initialRowSize <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.initialRowSize=initialRowSize;
}

Fixed version (ground truth):
/** 
 * Creates a splitter allocating a space for a give number of expected rows to be read
 * @param expectedRowCount the expected number of rows to be parsed
 */
ColumnSplitter(int expectedRowCount){
  if (expectedRowCount <= 0) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  this.expectedRowCount=expectedRowCount;
}