nus-yam/ex-repair huggingface dataset:
Program: 91906
Project: 91906
Buggy source:
/** 
 * Invoked on serialization for saving the   {@link #characteristics} field.
 * @param out The output stream where to serialize this attribute.
 * @throws IOException If an I/O error occurred while writing.
 */
private void writeObject(final ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  final Attribute<?>[] characterizedBy;
  if (characteristics instanceof CharacteristicMap) {
    characterizedBy=characteristics.values().toArray(new Attribute<?>[characteristics.size()]);
  }
 else {
    characterizedBy=null;
  }
  out.writeObject(characterizedBy);
}

Fixed version (ground truth):
/** 
 * Invoked on serialization for saving the   {@link #characteristics} field.
 * @param out  the output stream where to serialize this attribute.
 * @throws IOException if an I/O error occurred while writing.
 */
private void writeObject(final ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  final Attribute<?>[] characterizedBy;
  if (characteristics instanceof CharacteristicMap) {
    characterizedBy=characteristics.values().toArray(new Attribute<?>[characteristics.size()]);
  }
 else {
    characterizedBy=null;
  }
  out.writeObject(characterizedBy);
}
Program: 91907
Project: 91907
Buggy source:
/** 
 * Invoked on deserialization for restoring the   {@link #characteristics} field.
 * @param in The input stream from which to deserialize an attribute.
 * @throws IOException If an I/O error occurred while reading or if the stream contains invalid data.
 * @throws ClassNotFoundException If the class serialized on the stream is not on the classpath.
 */
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  try {
    final Attribute<?>[] characterizedBy=(Attribute<?>[])in.readObject();
    if (characterizedBy != null) {
      characteristics=newCharacteristicsMap();
      characteristics.values().addAll(Arrays.asList(characterizedBy));
    }
  }
 catch (  RuntimeException e) {
    throw (IOException)new InvalidObjectException(e.getMessage()).initCause(e);
  }
}

Fixed version (ground truth):
/** 
 * Invoked on deserialization for restoring the   {@link #characteristics} field.
 * @param in  the input stream from which to deserialize an attribute.
 * @throws IOException if an I/O error occurred while reading or if the stream contains invalid data.
 * @throws ClassNotFoundException if the class serialized on the stream is not on the classpath.
 */
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
  in.defaultReadObject();
  try {
    final Attribute<?>[] characterizedBy=(Attribute<?>[])in.readObject();
    if (characterizedBy != null) {
      characteristics=newCharacteristicsMap();
      characteristics.values().addAll(Arrays.asList(characterizedBy));
    }
  }
 catch (  RuntimeException e) {
    throw (IOException)new InvalidObjectException(e.getMessage()).initCause(e);
  }
}
Program: 91909
Project: 91909
Buggy source:
/** 
 * Returns the attribute value, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAttributeType#getMaximumOccurs() maximum number}of attribute values is restricted to 1 or 0.
 * @return The attribute value (may be {@code null}).
 * @throws MultiValuedPropertyException if this attribute contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract V getValue() throws MultiValuedPropertyException ;

Fixed version (ground truth):
/** 
 * Returns the attribute value, or   {@code null} if none. This convenience method can be invoked inthe common case where the  {@linkplain DefaultAttributeType#getMaximumOccurs() maximum number}of attribute values is restricted to 1 or 0.
 * @return the attribute value (may be {@code null}).
 * @throws MultiValuedPropertyException if this attribute contains more than one value.
 * @see AbstractFeature#getPropertyValue(String)
 */
@Override public abstract V getValue() throws MultiValuedPropertyException ;
Program: 91910
Project: 91910
Buggy source:
/** 
 * Returns information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @return Information about the attribute.
 */
@Override public AttributeType<V> getType(){
  return type;
}

Fixed version (ground truth):
/** 
 * Returns information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @return information about the attribute.
 */
@Override public AttributeType<V> getType(){
  return type;
}
Program: 91911
Project: 91911
Buggy source:
/** 
 * Sets the attribute values. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Object)}.</p>
 * @param values The new values.
 * @throws InvalidPropertyValueException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException {
  super.setValues(values);
}

Fixed version (ground truth):
/** 
 * Sets the attribute values. All previous values are replaced by the given collection. <p>The default implementation ensures that the given collection contains at most one element, then delegates to   {@link #setValue(Object)}.</p>
 * @param values  the new values.
 * @throws InvalidPropertyValueException if the given collection contains too many elements.
 */
@Override public void setValues(final Collection<? extends V> values) throws InvalidPropertyValueException {
  super.setValues(values);
}
Program: 91912
Project: 91912
Buggy source:
/** 
 * Sets the attribute value. All previous values are replaced by the given singleton. <div class="section">Validation</div> The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking the   {@link #quality()} method.
 * @param value The new value, or {@code null} for removing all values from this attribute.
 * @see AbstractFeature#setPropertyValue(String,Object)
 */
@Override public abstract void setValue(final V value);

Fixed version (ground truth):
/** 
 * Sets the attribute value. All previous values are replaced by the given singleton. <div class="section">Validation</div> The amount of validation performed by this method is implementation dependent. Usually, only the most basic constraints are verified. This is so for performance reasons and also because some rules may be temporarily broken while constructing a feature. A more exhaustive verification can be performed by invoking the   {@link #quality()} method.
 * @param value  the new value, or {@code null} for removing all values from this attribute.
 * @throws InvalidPropertyValueException if this method verifies argument validity and the given valuedoes not met the attribute constraints.
 * @see AbstractFeature#setPropertyValue(String,Object)
 */
@Override public abstract void setValue(final V value) throws InvalidPropertyValueException ;
Program: 91913
Project: 91913
Buggy source:
/** 
 * Returns a copy of this attribute. The default implementation returns a <em>shallow</em> copy: the attribute   {@linkplain #getValue() value} and {@linkplain #characteristics() characteristics}are <strong>not</strong> cloned. However subclasses may choose to do otherwise.
 * @return A clone of this attribute.
 * @throws CloneNotSupportedException if this attribute, the {@linkplain #getValue() value}or one of its   {@linkplain #characteristics() characteristics} can not be cloned.
 */
@Override @SuppressWarnings("String_Node_Str") public AbstractAttribute<V> clone() throws CloneNotSupportedException {
  final AbstractAttribute<V> clone=(AbstractAttribute<V>)super.clone();
  final Map<String,Attribute<?>> c=clone.characteristics;
  if (c instanceof CharacteristicMap) {
    clone.characteristics=((CharacteristicMap)c).clone();
  }
  return clone;
}

Fixed version (ground truth):
/** 
 * Returns a copy of this attribute. The default implementation returns a <em>shallow</em> copy: the attribute   {@linkplain #getValue() value} and {@linkplain #characteristics() characteristics}are <strong>not</strong> cloned. However subclasses may choose to do otherwise.
 * @return a clone of this attribute.
 * @throws CloneNotSupportedException if this attribute, the {@linkplain #getValue() value}or one of its   {@linkplain #characteristics() characteristics} can not be cloned.
 */
@Override @SuppressWarnings("String_Node_Str") public AbstractAttribute<V> clone() throws CloneNotSupportedException {
  final AbstractAttribute<V> clone=(AbstractAttribute<V>)super.clone();
  final Map<String,Attribute<?>> c=clone.characteristics;
  if (c instanceof CharacteristicMap) {
    clone.characteristics=((CharacteristicMap)c).clone();
  }
  return clone;
}
Program: 91914
Project: 91914
Buggy source:
/** 
 * Creates a new attribute of the given type.
 * @param type Information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @see #create(AttributeType)
 */
protected AbstractAttribute(final AttributeType<V> type){
  this.type=type;
}

Fixed version (ground truth):
/** 
 * Creates a new attribute of the given type.
 * @param type  information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @see #create(AttributeType)
 */
protected AbstractAttribute(final AttributeType<V> type){
  this.type=type;
}
Program: 91915
Project: 91915
Buggy source:
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >   The type of attribute values.
 * @param type  Information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value The initial value (may be {@code null}).
 * @return The new attribute.
 */
static <V>AbstractAttribute<V> create(final AttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}

Fixed version (ground truth):
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >    the type of attribute values.
 * @param type   information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value  the initial value (may be {@code null}).
 * @return The new attribute.
 */
static <V>AbstractAttribute<V> create(final AttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}
Program: 91916
Project: 91916
Buggy source:
/** 
 * Returns a string representation of this attribute. The returned string is for debugging purpose and may change in any future SIS version. The current implementation is like below:  {@preformat text}Attribute[“temperature” : Float] =  20.3, 17.8, 21.1} └─ characteristics: units=°C, accuracy=0.1 }
 * @return A string representation of this attribute for debugging purpose.
 */
@Debug @Override public String toString(){
  final StringBuilder buffer=FieldType.toString("String_Node_Str",type,Classes.getShortName(type.getValueClass()),getValues().iterator());
  if (characteristics != null && !characteristics.isEmpty()) {
    buffer.append(System.lineSeparator());
    String separator="String_Node_Str";
    for (    final Map.Entry<String,Attribute<?>> entry : characteristics.entrySet()) {
      buffer.append(separator).append(entry.getKey()).append('=').append(entry.getValue().getValue());
      separator="String_Node_Str";
    }
  }
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Returns a string representation of this attribute. The returned string is for debugging purpose and may change in any future SIS version. The current implementation is like below:  {@preformat text}Attribute[“temperature” : Float] =  20.3, 17.8, 21.1} └─ characteristics: units=°C, accuracy=0.1 }
 * @return a string representation of this attribute for debugging purpose.
 */
@Debug @Override public String toString(){
  final StringBuilder buffer=FieldType.toString("String_Node_Str",type,Classes.getShortName(type.getValueClass()),getValues().iterator());
  if (characteristics != null && !characteristics.isEmpty()) {
    buffer.append(System.lineSeparator());
    String separator="String_Node_Str";
    for (    final Map.Entry<String,Attribute<?>> entry : characteristics.entrySet()) {
      buffer.append(separator).append(entry.getKey()).append('=').append(entry.getValue().getValue());
      separator="String_Node_Str";
    }
  }
  return buffer.toString();
}
Program: 91917
Project: 91917
Buggy source:
/** 
 * Given a concatenated string as produced by   {@link #getValue()}, separates the components around the separator and forward the values to the original attributes. If one of the values can not be parsed, then this method does not store any property value ("all or nothing" behavior).
 * @param value  the concatenated string.
 * @throws UnconvertibleObjectException if one of the attribute values can not be parsed to the expected type.
 */
@Override public void setValue(final String value) throws UnconvertibleObjectException {
}

Fixed version (ground truth):
/** 
 * Given a concatenated string as produced by   {@link #getValue()}, separates the components around the separator and forward the values to the original attributes. If one of the values can not be parsed, then this method does not store any property value ("all or nothing" behavior).
 * @param value  the concatenated string.
 * @throws InvalidPropertyValueException if one of the attribute values can not be parsed to the expected type.
 */
@Override public void setValue(final String value) throws InvalidPropertyValueException {
}
Program: 91918
Project: 91918
Buggy source:
/** 
 * Creates a feature type with an string join operation. The feature contains the following properties: <ul> <li>  {@code name} as a {@link String}</li> <li>  {@code age} as an {@link Integer}</li> <li>  {@code summary} as string join of {@code name} and {@code age} attributes.</li></ul>
 * @return The feature for a person.
 */
private static DefaultFeatureType person(){
  final PropertyType nameType=new DefaultAttributeType<>(name("String_Node_Str"),String.class,1,1,null);
  final PropertyType ageType=new DefaultAttributeType<>(name("String_Node_Str"),Integer.class,1,1,null);
  final PropertyType cmpType=FeatureOperations.compound(name("String_Node_Str"),"String_Node_Str","String_Node_Str","String_Node_Str",nameType,ageType);
  return new DefaultFeatureType(name("String_Node_Str"),false,null,nameType,ageType,cmpType);
}

Fixed version (ground truth):
/** 
 * Creates a feature type with an string join operation. The feature contains the following properties: <ul> <li>  {@code name} as a {@link String}</li> <li>  {@code age} as an {@link Integer}</li> <li>  {@code summary} as string join of {@code name} and {@code age} attributes.</li></ul> The operation uses  {@code "<<:"} and {@code ":>>"} as prefix and suffix respectivelyavoid avoiding confusion if a code spelled the variable name (e.g.  {@code prefix}) instead of using it.
 * @return The feature for a person.
 */
private static DefaultFeatureType person(){
  final PropertyType nameType=new DefaultAttributeType<>(name("String_Node_Str"),String.class,1,1,null);
  final PropertyType ageType=new DefaultAttributeType<>(name("String_Node_Str"),Integer.class,1,1,null);
  final PropertyType cmpType=FeatureOperations.compound(name("String_Node_Str"),"String_Node_Str","String_Node_Str","String_Node_Str",nameType,ageType);
  return new DefaultFeatureType(name("String_Node_Str"),false,null,nameType,ageType,cmpType);
}
Program: 91919
Project: 91919
Buggy source:
/** 
 * Reports a non-fatal warning that occurred while parsing a WKT.
 * @param message The message. Can not be {@code null}.
 * @param ex      The non-fatal exception that occurred while parsing the element, or {@code null}.
 */
final void warning(final InternationalString message,final Exception ex){
  if (warnings == null) {
    warnings=new Warnings(errorLocale,true,ignoredElements);
  }
  warnings.add(message,ex,null);
}

Fixed version (ground truth):
/** 
 * Reports a non-fatal warning that occurred while parsing a WKT.
 * @param parent  The parent element, or {@code null} if unknown.
 * @param element The element that we can not parse, or {@code null} if unknown.
 * @param message The message. Can be {@code null} only if {@code ex} is non-null.
 * @param ex      The non-fatal exception that occurred while parsing the element, or {@code null}.
 */
final void warning(final Element parent,final Element element,final InternationalString message,final Exception ex){
  if (warnings == null) {
    warnings=new Warnings(errorLocale,true,ignoredElements);
  }
  warnings.add(message,ex,(parent != null && element != null) ? new String[]{parent.keyword,element.keyword} : null);
}
Program: 91922
Project: 91922
Buggy source:
/** 
 * Parses an   {@code "ImageCRS"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#79">WKT 2 specification §12</a>.
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "ImageCRS"} element as an {@link ImageCRS} object.
 * @throws ParseException if the {@code "ImageCRS"} element can not be parsed.
 */
private ImageCRS parseImageCRS(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.ImageCRS);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final ImageDatum datum=parseImageDatum(MANDATORY,element);
  final Unit<?> unit=parseUnit(element);
  final CoordinateSystem cs;
  try {
    cs=parseCoordinateSystem(element,WKTKeywords.Cartesian,2,false,unit,datum);
    final Map<String,?> properties=parseMetadataAndClose(element,name,datum);
    if (cs instanceof CartesianCS) {
      return crsFactory.createImageCRS(properties,datum,(CartesianCS)cs);
    }
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
  throw element.illegalCS(cs);
}

Fixed version (ground truth):
/** 
 * Parses an   {@code "ImageCRS"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#79">WKT 2 specification §12</a>.
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "ImageCRS"} element as an {@link ImageCRS} object.
 * @throws ParseException if the {@code "ImageCRS"} element can not be parsed.
 */
private ImageCRS parseImageCRS(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.ImageCRS);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final ImageDatum datum=parseImageDatum(MANDATORY,element);
  final Unit<?> unit=parseUnit(element);
  final CoordinateSystem cs;
  try {
    cs=parseCoordinateSystem(element,WKTKeywords.Cartesian,2,false,unit,datum);
    final Map<String,?> properties=parseMetadataAndClose(element,name,datum);
    if (cs instanceof AffineCS) {
      return crsFactory.createImageCRS(properties,datum,(AffineCS)cs);
    }
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
  throw element.illegalCS(cs);
}
Program: 91925
Project: 91925
Buggy source:
/** 
 * Parses a   {@code "EngineeringDatum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#76">WKT 2 specification §11.2</a>. The legacy WKT 1 pattern was: {@preformat text}LOCAL_DATUM["<name>", <datum type>  ,<authority>}] } The datum type (WKT 1 only) is currently ignored.
 * @param mode   {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param isWKT1 {@code true} if the parent is a WKT 1 element.
 * @return The {@code "EngineeringDatum"} element as an {@link EngineeringDatum} object.
 * @throws ParseException if the {@code "EngineeringDatum"} element can not be parsed.
 */
private EngineeringDatum parseEngineeringDatum(final int mode,final Element parent,final boolean isWKT1) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.EngineeringDatum,WKTKeywords.EDatum,WKTKeywords.Local_Datum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  if (isWKT1) {
    element.pullInteger("String_Node_Str");
  }
  try {
    return datumFactory.createEngineeringDatum(parseAnchorAndClose(element,name));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "EngineeringDatum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#76">WKT 2 specification §11.2</a>. The legacy WKT 1 pattern was: {@preformat wkt}LOCAL_DATUM["<name>", <datum type>  ,<authority>}] } The datum type (WKT 1 only) is currently ignored.
 * @param mode   {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param isWKT1 {@code true} if the parent is a WKT 1 element.
 * @return The {@code "EngineeringDatum"} element as an {@link EngineeringDatum} object.
 * @throws ParseException if the {@code "EngineeringDatum"} element can not be parsed.
 */
private EngineeringDatum parseEngineeringDatum(final int mode,final Element parent,final boolean isWKT1) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.EngineeringDatum,WKTKeywords.EDatum,WKTKeywords.Local_Datum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  if (isWKT1) {
    element.pullInteger("String_Node_Str");
  }
  try {
    return datumFactory.createEngineeringDatum(parseAnchorAndClose(element,name));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 91932
Project: 91932
Buggy source:
/** 
 * Parses a   {@code "VerticalDatum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#71">WKT 2 specification §10.2</a>. The legacy WKT 1 pattern was: {@preformat text}VERT_DATUM["<name>", <datum type>  ,<authority>}] }
 * @param mode   {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param isWKT1 {@code true} if the parent is a WKT 1 element.
 * @return The {@code "VerticalDatum"} element as a {@link VerticalDatum} object.
 * @throws ParseException if the {@code "VerticalDatum"} element can not be parsed.
 */
private VerticalDatum parseVerticalDatum(final int mode,final Element parent,final boolean isWKT1) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.VerticalDatum,WKTKeywords.VDatum,WKTKeywords.Vert_Datum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  VerticalDatumType type=null;
  if (isWKT1) {
    type=VerticalDatumTypes.fromLegacy(element.pullInteger("String_Node_Str"));
  }
  if (type == null) {
    type=VerticalDatumTypes.guess(name,null,null);
  }
  try {
    return datumFactory.createVerticalDatum(parseAnchorAndClose(element,name),type);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "VerticalDatum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#71">WKT 2 specification §10.2</a>. The legacy WKT 1 pattern was: {@preformat wkt}VERT_DATUM["<name>", <datum type>  ,<authority>}] }
 * @param mode   {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param isWKT1 {@code true} if the parent is a WKT 1 element.
 * @return The {@code "VerticalDatum"} element as a {@link VerticalDatum} object.
 * @throws ParseException if the {@code "VerticalDatum"} element can not be parsed.
 */
private VerticalDatum parseVerticalDatum(final int mode,final Element parent,final boolean isWKT1) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.VerticalDatum,WKTKeywords.VDatum,WKTKeywords.Vert_Datum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  VerticalDatumType type=null;
  if (isWKT1) {
    type=VerticalDatumTypes.fromLegacy(element.pullInteger("String_Node_Str"));
  }
  if (type == null) {
    type=VerticalDatumTypes.guess(name,null,null);
  }
  try {
    return datumFactory.createVerticalDatum(parseAnchorAndClose(element,name),type);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 91934
Project: 91934
Buggy source:
/** 
 * Parses a   {@code "TimeDatum"} element. This element has the following pattern:{@preformat text}TimeDatum["<name>", TimeOrigin[<time origin>]  ,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "TimeDatum"} element as a {@link TemporalDatum} object.
 * @throws ParseException if the {@code "TimeDatum"} element can not be parsed.
 */
private TemporalDatum parseTimeDatum(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.TimeDatum,WKTKeywords.TDatum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final Element origin=element.pullElement(MANDATORY,WKTKeywords.TimeOrigin);
  final Date epoch=origin.pullDate("String_Node_Str");
  origin.close(ignoredElements);
  try {
    return datumFactory.createTemporalDatum(parseAnchorAndClose(element,name),epoch);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "TimeDatum"} element. This element has the following pattern:{@preformat wkt}TimeDatum["<name>", TimeOrigin[<time origin>]  ,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "TimeDatum"} element as a {@link TemporalDatum} object.
 * @throws ParseException if the {@code "TimeDatum"} element can not be parsed.
 */
private TemporalDatum parseTimeDatum(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.TimeDatum,WKTKeywords.TDatum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final Element origin=element.pullElement(MANDATORY,WKTKeywords.TimeOrigin);
  final Date epoch=origin.pullDate("String_Node_Str");
  origin.close(ignoredElements);
  try {
    return datumFactory.createTemporalDatum(parseAnchorAndClose(element,name),epoch);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 91935
Project: 91935
Buggy source:
/** 
 * Parses an <strong>optional</strong>   {@code "TOWGS84"} element.This element is specific to WKT 1 and has the following pattern: {@preformat textTOWGS84[<dx>, <dy>, <dz>, <ex>, <ey>, <ez>, <ppm>]}
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "TOWGS84"} element as a {@link org.apache.sis.referencing.datum.BursaWolfParameters} object,or  {@code null} if no {@code "TOWGS84"} has been found.
 * @throws ParseException if the {@code "TOWGS84"} can not be parsed.
 */
private Object parseToWGS84(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.ToWGS84);
  if (element == null) {
    return null;
  }
  final double[] values=new double[ToWGS84.length];
  for (int i=0; i < values.length; ) {
    values[i]=element.pullDouble(ToWGS84[i]);
    if ((++i % 3) == 0 && element.isEmpty()) {
      break;
    }
  }
  element.close(ignoredElements);
  return referencing.createToWGS84(values);
}

Fixed version (ground truth):
/** 
 * Parses an <strong>optional</strong>   {@code "TOWGS84"} element.This element is specific to WKT 1 and has the following pattern: {@preformat wktTOWGS84[<dx>, <dy>, <dz>, <ex>, <ey>, <ez>, <ppm>]}
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "TOWGS84"} element as a {@link org.apache.sis.referencing.datum.BursaWolfParameters} object,or  {@code null} if no {@code "TOWGS84"} has been found.
 * @throws ParseException if the {@code "TOWGS84"} can not be parsed.
 */
private Object parseToWGS84(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.ToWGS84);
  if (element == null) {
    return null;
  }
  final double[] values=new double[ToWGS84.length];
  for (int i=0; i < values.length; ) {
    values[i]=element.pullDouble(ToWGS84[i]);
    if ((++i % 3) == 0 && element.isEmpty()) {
      break;
    }
  }
  element.close(ignoredElements);
  return referencing.createToWGS84(values);
}
Program: 91936
Project: 91936
Buggy source:
/** 
 * Parses a   {@code "Datum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#54">WKT 2 specification §8.2.4</a>. The legacy WKT 1 pattern was: {@preformat text}DATUM["<name>", <spheroid>  ,<to wgs84>} {,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param meridian the prime meridian, or {@code null} for Greenwich.
 * @return The {@code "Datum"} element as a {@link GeodeticDatum} object.
 * @throws ParseException if the {@code "Datum"} element can not be parsed.
 * @see org.apache.sis.referencing.datum.DefaultGeodeticDatum#formatTo(Formatter)
 */
private GeodeticDatum parseDatum(final int mode,final Element parent,PrimeMeridian meridian) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.Datum,WKTKeywords.GeodeticDatum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final Ellipsoid ellipsoid=parseEllipsoid(MANDATORY,element);
  final Object toWGS84=parseToWGS84(OPTIONAL,element);
  final Map<String,Object> properties=parseAnchorAndClose(element,name);
  if (meridian == null) {
    meridian=referencing.getGreenwich();
  }
  if (toWGS84 != null) {
    properties.put(ReferencingServices.BURSA_WOLF_KEY,toWGS84);
  }
  try {
    return datumFactory.createGeodeticDatum(properties,ellipsoid,meridian);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "Datum"} (WKT 2) element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#54">WKT 2 specification §8.2.4</a>. The legacy WKT 1 pattern was: {@preformat wkt}DATUM["<name>", <spheroid>  ,<to wgs84>} {,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @param meridian the prime meridian, or {@code null} for Greenwich.
 * @return The {@code "Datum"} element as a {@link GeodeticDatum} object.
 * @throws ParseException if the {@code "Datum"} element can not be parsed.
 * @see org.apache.sis.referencing.datum.DefaultGeodeticDatum#formatTo(Formatter)
 */
private GeodeticDatum parseDatum(final int mode,final Element parent,PrimeMeridian meridian) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.Datum,WKTKeywords.GeodeticDatum);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  final Ellipsoid ellipsoid=parseEllipsoid(MANDATORY,element);
  final Object toWGS84=parseToWGS84(OPTIONAL,element);
  final Map<String,Object> properties=parseAnchorAndClose(element,name);
  if (meridian == null) {
    meridian=referencing.getGreenwich();
  }
  if (toWGS84 != null) {
    properties.put(ReferencingServices.BURSA_WOLF_KEY,toWGS84);
  }
  try {
    return datumFactory.createGeodeticDatum(properties,ellipsoid,meridian);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 91938
Project: 91938
Buggy source:
/** 
 * Parses a   {@code "CompoundCRS"} element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#110">WKT 2 specification §16</a>. The legacy WKT 1 specification was: {@preformat text}COMPD_CS["<name>", <head cs>, <tail cs>  ,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "CompoundCRS"} element as a {@link CompoundCRS} object.
 * @throws ParseException if the {@code "CompoundCRS"} element can not be parsed.
 */
private CompoundCRS parseCompoundCRS(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.CompoundCRS,WKTKeywords.Compd_CS);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  CoordinateReferenceSystem crs;
  final List<CoordinateReferenceSystem> components=new ArrayList<>(4);
  while ((crs=parseCoordinateReferenceSystem(element,components.size() < 2)) != null) {
    components.add(crs);
  }
  try {
    return crsFactory.createCompoundCRS(parseMetadataAndClose(element,name,null),components.toArray(new CoordinateReferenceSystem[components.size()]));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "CompoundCRS"} element. The syntax is given by<a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#110">WKT 2 specification §16</a>. The legacy WKT 1 specification was: {@preformat wkt}COMPD_CS["<name>", <head cs>, <tail cs>  ,<authority>}] }
 * @param mode {@link #FIRST},   {@link #OPTIONAL} or {@link #MANDATORY}.
 * @param parent The parent element.
 * @return The {@code "CompoundCRS"} element as a {@link CompoundCRS} object.
 * @throws ParseException if the {@code "CompoundCRS"} element can not be parsed.
 */
private CompoundCRS parseCompoundCRS(final int mode,final Element parent) throws ParseException {
  final Element element=parent.pullElement(mode,WKTKeywords.CompoundCRS,WKTKeywords.Compd_CS);
  if (element == null) {
    return null;
  }
  final String name=element.pullString("String_Node_Str");
  CoordinateReferenceSystem crs;
  final List<CoordinateReferenceSystem> components=new ArrayList<>(4);
  while ((crs=parseCoordinateReferenceSystem(element,components.size() < 2)) != null) {
    components.add(crs);
  }
  try {
    return crsFactory.createCompoundCRS(parseMetadataAndClose(element,name,null),components.toArray(new CoordinateReferenceSystem[components.size()]));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 91940
Project: 91940
Buggy source:
/** 
 * Removes the next   {@link Object} from the list and returns it.
 * @param key The parameter name. Used for formatting an error message if no number is found.
 * @return The next {@link Object} on the list (never {@code null}).
 * @throws ParseException if no more object is available.
 */
public Object pullObject(final String key) throws ParseException {
  final Iterator<Object> iterator=list.iterator();
  while (iterator.hasNext()) {
    final Object object=iterator.next();
    if (object != null) {
      iterator.remove();
      return object;
    }
  }
  throw missingComponent(key);
}

Fixed version (ground truth):
/** 
 * Removes the next   {@link Object} from the list and returns it.
 * @param key The parameter name. Used for formatting an error message if no number is found.
 * @return The next {@link Object} on the list (never {@code null}).
 * @throws ParseException if no more object is available.
 */
public Object pullObject(final String key) throws ParseException {
  final Iterator<Object> iterator=list.iterator();
  while (iterator.hasNext()) {
    final Object object=iterator.next();
    if (object != null && !(object instanceof Element)) {
      iterator.remove();
      return object;
    }
  }
  throw missingComponent(key);
}
Program: 91941
Project: 91941
Buggy source:
/** 
 * Removes the next object of the given type from the list and returns it, if presents.
 * @param type The object type.
 * @return The next object on the list, or {@code null} if none.
 */
@SuppressWarnings("String_Node_Str") public <T>T pullOptional(final Class<T> type){
  final Iterator<Object> iterator=list.iterator();
  while (iterator.hasNext()) {
    final Object object=iterator.next();
    if (type.isInstance(object)) {
      iterator.remove();
      return (T)object;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Removes the next object of the given type from the list and returns it, if presents.
 * @param type The object type.
 * @return The next object on the list, or {@code null} if none.
 */
@SuppressWarnings("String_Node_Str") public <T>T pullOptional(final Class<T> type){
  final Iterator<Object> iterator=list.iterator();
  while (iterator.hasNext()) {
    final Object object=iterator.next();
    if (type.isInstance(object) && !(object instanceof Element)) {
      iterator.remove();
      return (T)object;
    }
  }
  return null;
}
Program: 91944
Project: 91944
Buggy source:
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP,Option.DEBUG));
}
Program: 91945
Project: 91945
Buggy source:
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}

Fixed version (ground truth):
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(args,e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(args,e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}
Program: 91946
Project: 91946
Buggy source:
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 */
private static void error(final Exception e){
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    err.println(e.getLocalizedMessage());
    err.flush();
  }
 else {
    final PrintStream err=System.err;
    err.println(e.getLocalizedMessage());
    err.flush();
  }
}

Fixed version (ground truth):
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 * @param args The command line arguments, used only for detecting if the {@code --debug} option was present.
 */
private static void error(final String[] args,final Exception e){
  final boolean debug=ArraysExt.containsIgnoreCase(args,Option.PREFIX + "String_Node_Str");
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
 else {
    @SuppressWarnings("String_Node_Str") final PrintStream err=System.err;
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
}
Program: 91947
Project: 91947
Buggy source:
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "help"} sub-command.
 */
HelpSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91948
Project: 91948
Buggy source:
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP));
  this.isCRS=isCRS;
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "metadata"} or {@code "crs"} sub-command.
 * @param isCRS {@code true} for the {@code "crs"} sub-command,or  {@code false} for the {@code "metadata"} sub-command.
 */
MetadataSC(final boolean isCRS,final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.FORMAT,Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.COLORS,Option.HELP,Option.DEBUG));
  this.isCRS=isCRS;
}
Program: 91950
Project: 91950
Buggy source:
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "mime-type"} sub-command.
 */
MimeTypeSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.ENCODING,Option.HELP,Option.DEBUG));
}
Program: 91952
Project: 91952
Buggy source:
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  err.println(Exceptions.formatChainedMessages(locale,message,e));
}

Fixed version (ground truth):
/** 
 * Prints the given error message followed by the message in the given exception.
 * @param message The message to print before the exception, or {@code null}.
 * @param e The exception which occurred.
 */
final void error(final String message,final Exception e){
  out.flush();
  if (debug) {
    e.printStackTrace(err);
  }
 else {
    err.println(Exceptions.formatChainedMessages(locale,message,e));
  }
}
Program: 91953
Project: 91953
Buggy source:
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP));
}

Fixed version (ground truth):
/** 
 * Creates the   {@code "about"} sub-command.
 */
AboutSC(final int commandIndex,final String... args) throws InvalidOptionException {
  super(commandIndex,args,EnumSet.of(Option.LOCALE,Option.TIMEZONE,Option.ENCODING,Option.BRIEF,Option.VERBOSE,Option.HELP,Option.DEBUG));
}
Program: 91954
Project: 91954
Buggy source:
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}

Fixed version (ground truth):
/** 
 * Prints the information to the standard output stream.
 * @param args Command-line options.
 */
public static void main(final String[] args){
  final LogManager manager=LogManager.getLogManager();
  if (MonolineFormatter.class.getName().equals(manager.getProperty(ConsoleHandler.class.getName() + "String_Node_Str"))) {
    MonolineFormatter.install();
  }
  final Command c;
  try {
    c=new Command(args);
  }
 catch (  InvalidCommandException e) {
    error(args,e);
    System.exit(INVALID_COMMAND_EXIT_CODE);
    return;
  }
catch (  InvalidOptionException e) {
    error(args,e);
    System.exit(INVALID_OPTION_EXIT_CODE);
    return;
  }
  int status;
  try {
    status=c.run();
  }
 catch (  Exception e) {
    status=exitCodeFor(e);
  }
  if (status != 0) {
    System.exit(status);
  }
}
Program: 91955
Project: 91955
Buggy source:
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 */
private static void error(final Exception e){
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    err.println(e.getLocalizedMessage());
    err.flush();
  }
 else {
    final PrintStream err=System.err;
    err.println(e.getLocalizedMessage());
    err.flush();
  }
}

Fixed version (ground truth):
/** 
 * Prints the message of the given exception. This method is invoked only when the error occurred before the   {@link SubCommand} has been built, otherwise the {@link SubCommand#err} printer shall be used.
 * @param args The command line arguments, used only for detecting if the {@code --debug} option was present.
 */
private static void error(final String[] args,final Exception e){
  final boolean debug=ArraysExt.containsIgnoreCase(args,Option.PREFIX + "String_Node_Str");
  final Console console=System.console();
  if (console != null) {
    final PrintWriter err=console.writer();
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
 else {
    @SuppressWarnings("String_Node_Str") final PrintStream err=System.err;
    if (debug) {
      e.printStackTrace(err);
    }
 else {
      err.println(e.getLocalizedMessage());
    }
    err.flush();
  }
}