nus-yam/ex-repair huggingface dataset:
Program: 92138
Project: 92138
Buggy source:
/** 
 * Parses a   {@code "GEOCCS"} element.This element has the following pattern: {@preformat textGEOCCS["<name>", <datum>, <prime meridian>, <linear unit>}{,<axis> ,<axis> ,<axis>} {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "GEOCCS"} element as a {@link GeocentricCRS} object.
 * @throws ParseException if the {@code "GEOCCS"} element can not be parsed.
 */
private GeocentricCRS parseGeoCCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.GeocCS);
  final String name=element.pullString("String_Node_Str");
  final PrimeMeridian meridian=parsePrimem(element,NonSI.DEGREE_ANGLE);
  final GeodeticDatum datum=parseDatum(element,meridian);
  final Unit<Length> linearUnit=parseUnit(element,SI.METRE);
  CartesianCS cs;
  CoordinateSystemAxis axis0, axis1=null, axis2=null;
  axis0=parseAxis(element,linearUnit,false);
  try {
    if (axis0 != null) {
      axis1=parseAxis(element,linearUnit,true);
      axis2=parseAxis(element,linearUnit,true);
    }
    final Map<String,?> properties=parseAuthorityAndClose(element,name);
    if (axis0 != null && !isAxisIgnored) {
      cs=csFactory.createCartesianCS(properties,axis0,axis1,axis2);
      cs=referencing.upgradeGeocentricCS(cs);
    }
 else {
      cs=referencing.getGeocentricCS(linearUnit);
    }
    return crsFactory.createGeocentricCRS(properties,datum,cs);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "GEOCCS"} element.This element has the following pattern: {@preformat textGEOCCS["<name>", <datum>, <prime meridian>, <linear unit>}{,<axis> ,<axis> ,<axis>} {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "GEOCCS"} element as a {@link GeocentricCRS} object.
 * @throws ParseException if the {@code "GEOCCS"} element can not be parsed.
 */
private GeocentricCRS parseGeoCCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.GeocCS);
  final String name=element.pullString("String_Node_Str");
  final PrimeMeridian meridian=parsePrimem(element,NonSI.DEGREE_ANGLE);
  final GeodeticDatum datum=parseDatum(element,meridian);
  final Unit<Length> linearUnit=parseUnit(element,SI.METRE);
  CartesianCS cs;
  CoordinateSystemAxis axis0, axis1=null, axis2=null;
  axis0=parseAxis(element,false,linearUnit,false);
  try {
    if (axis0 != null) {
      axis1=parseAxis(element,false,linearUnit,true);
      axis2=parseAxis(element,false,linearUnit,true);
    }
    final Map<String,?> properties=parseAuthorityAndClose(element,name);
    if (axis0 != null && !isAxisIgnored) {
      cs=csFactory.createCartesianCS(properties,axis0,axis1,axis2);
      cs=referencing.upgradeGeocentricCS(cs);
    }
 else {
      cs=referencing.getGeocentricCS(linearUnit);
    }
    return crsFactory.createGeocentricCRS(properties,datum,cs);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 92139
Project: 92139
Buggy source:
/** 
 * Parses a   {@code "GEOGCS"} element. This element has the following pattern:{@preformat text}GEOGCS["<name>", <datum>, <prime meridian>, <angular unit>   ,<twin axes>} {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "GEOGCS"} element as a {@link GeographicCRS} object.
 * @throws ParseException if the {@code "GEOGCS"} element can not be parsed.
 */
private GeographicCRS parseGeoGCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.GeogCS);
  Object name=element.pullString("String_Node_Str");
  final Unit<Angle> angularUnit=parseUnit(element,SI.RADIAN);
  final PrimeMeridian meridian=parsePrimem(element,angularUnit);
  final GeodeticDatum datum=parseDatum(element,meridian);
  if (((String)name).isEmpty()) {
    name=datum.getName();
  }
  CoordinateSystemAxis axis0=parseAxis(element,angularUnit,false);
  CoordinateSystemAxis axis1=null;
  try {
    if (axis0 != null) {
      axis1=parseAxis(element,angularUnit,true);
    }
    if (axis0 == null || isAxisIgnored) {
      axis0=createAxis("String_Node_Str",AxisDirection.EAST,angularUnit);
      axis1=createAxis("String_Node_Str",AxisDirection.NORTH,angularUnit);
    }
    final Map<String,?> properties=parseAuthorityAndClose(element,name);
    return crsFactory.createGeographicCRS(properties,datum,csFactory.createEllipsoidalCS(properties,axis0,axis1));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "GEOGCS"} element. This element has the following pattern:{@preformat text}GEOGCS["<name>", <datum>, <prime meridian>, <angular unit>   ,<twin axes>} {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "GEOGCS"} element as a {@link GeographicCRS} object.
 * @throws ParseException if the {@code "GEOGCS"} element can not be parsed.
 */
private GeographicCRS parseGeoGCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.GeogCS);
  Object name=element.pullString("String_Node_Str");
  final Unit<Angle> angularUnit=parseUnit(element,SI.RADIAN);
  final PrimeMeridian meridian=parsePrimem(element,angularUnit);
  final GeodeticDatum datum=parseDatum(element,meridian);
  if (((String)name).isEmpty()) {
    name=datum.getName();
  }
  CoordinateSystemAxis axis0=parseAxis(element,true,angularUnit,false);
  CoordinateSystemAxis axis1=null;
  try {
    if (axis0 != null) {
      axis1=parseAxis(element,true,angularUnit,true);
    }
    if (axis0 == null || isAxisIgnored) {
      axis0=createAxis(AxisNames.GEODETIC_LONGITUDE,"String_Node_Str",AxisDirection.EAST,angularUnit);
      axis1=createAxis(AxisNames.GEODETIC_LATITUDE,"String_Node_Str",AxisDirection.NORTH,angularUnit);
    }
    final Map<String,?> properties=parseAuthorityAndClose(element,name);
    return crsFactory.createGeographicCRS(properties,datum,csFactory.createEllipsoidalCS(properties,axis0,axis1));
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}
Program: 92140
Project: 92140
Buggy source:
/** 
 * Tests   {@link CharEncoding#getAbbreviation(CoordinateSystem,CoordinateSystemAxis)}.
 */
@Test public void testGetAbbreviation(){
  assertAbbreviationEquals("String_Node_Str",new Geographic("String_Node_Str","String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geocentric("String_Node_Str","String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geographic("String_Node_Str","String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geocentric("String_Node_Str","String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Tests   {@link CharEncoding#getAbbreviation(CoordinateSystem,CoordinateSystemAxis)}.
 */
@Test public void testGetAbbreviation(){
  assertAbbreviationEquals("String_Node_Str",new Geographic(AxisNames.GEODETIC_LATITUDE,"String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geocentric(AxisNames.SPHERICAL_LATITUDE,"String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geographic(AxisNames.GEODETIC_LONGITUDE,"String_Node_Str"));
  assertAbbreviationEquals("String_Node_Str",new Geocentric(AxisNames.SPHERICAL_LONGITUDE,"String_Node_Str"));
}
Program: 92141
Project: 92141
Buggy source:
/** 
 * Suggests an abbreviation for the given axis direction. The unit of measurement may be used for resolving some ambiguities like whether   {@link AxisDirection#EAST} is for "x" (Easting)or "λ" (Longitude). The axis name is used only in last resort.
 * @param name      The axis name for which to suggest an abbreviation.
 * @param direction The axis direction for which to suggest an abbreviation.
 * @param unit      The axis unit of measurement, for disambiguation.
 * @return A suggested abbreviation.
 * @since 0.6
 */
public String suggestAbbreviation(final String name,final AxisDirection direction,final Unit<?> unit){
  throw moduleNotFound();
}

Fixed version (ground truth):
/** 
 * Suggests an abbreviation for the given axis direction. The unit of measurement may be used for resolving some ambiguities like whether   {@link AxisDirection#EAST} is for "x" (Easting)or "λ" (Longitude).
 * @param name      The axis name for which to suggest an abbreviation.
 * @param direction The axis direction for which to suggest an abbreviation.
 * @param unit      The axis unit of measurement, for disambiguation.
 * @return A suggested abbreviation.
 * @since 0.6
 */
public String suggestAbbreviation(final String name,final AxisDirection direction,final Unit<?> unit){
  throw moduleNotFound();
}
Program: 92143
Project: 92143
Buggy source:
/** 
 * Suggests an abbreviation for the given axis direction. The unit of measurement may be used for resolving some ambiguities like whether   {@link AxisDirection#EAST} is for "x" (Easting)or "λ" (Longitude). The axis name is used only in last resort.
 * @param name      The axis name for which to suggest an abbreviation.
 * @param direction The axis direction for which to suggest an abbreviation.
 * @param unit      The axis unit of measurement, for disambiguation.
 * @return A suggested abbreviation.
 * @since 0.6
 */
@Override public String suggestAbbreviation(final String name,final AxisDirection direction,final Unit<?> unit){
  return AxisDirections.suggestAbbreviation(name,direction,unit);
}

Fixed version (ground truth):
/** 
 * Suggests an abbreviation for the given axis direction. The unit of measurement may be used for resolving some ambiguities like whether   {@link AxisDirection#EAST} is for "x" (Easting)or "λ" (Longitude).
 * @param name      The axis name for which to suggest an abbreviation.
 * @param direction The axis direction for which to suggest an abbreviation.
 * @param unit      The axis unit of measurement, for disambiguation.
 * @return A suggested abbreviation.
 * @since 0.6
 */
@Override public String suggestAbbreviation(final String name,final AxisDirection direction,final Unit<?> unit){
  return AxisDirections.suggestAbbreviation(name,direction,unit);
}
Program: 92146
Project: 92146
Buggy source:
/** 
 * Tests the   {@link CharSequences#camelCaseToAcronym(CharSequence)} method.
 */
@Test public void testCamelCaseToAcronym(){
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertNull(camelCaseToAcronym(null));
}

Fixed version (ground truth):
/** 
 * Tests the   {@link CharSequences#camelCaseToAcronym(CharSequence)} method.
 */
@Test public void testCamelCaseToAcronym(){
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertEquals("String_Node_Str",camelCaseToAcronym("String_Node_Str").toString());
  assertNull(camelCaseToAcronym(null));
}
Program: 92147
Project: 92147
Buggy source:
/** 
 * Constructor for private use by   {@link WKTFormat} only. This allows to use the number formatcreated by  {@link WKTFormat#createFormat(Class)}, which may be overridden by the user.
 */
Formatter(final Locale locale,final Symbols symbols,final NumberFormat numberFormat,final DateFormat dateFormat,final UnitFormat unitFormat){
  this.locale=locale;
  this.convention=Convention.DEFAULT;
  this.authority=Convention.DEFAULT.getNameAuthority();
  this.symbols=symbols;
  this.lineSeparator=this.symbols.lineSeparator();
  this.indentation=WKTFormat.DEFAULT_INDENTATION;
  this.numberFormat=numberFormat;
  this.dateFormat=dateFormat;
  this.unitFormat=unitFormat;
}

Fixed version (ground truth):
/** 
 * Constructor for private use by   {@link WKTFormat} only. This allows to use the number formatcreated by  {@link WKTFormat#createFormat(Class)}, which may be overridden by the user.
 */
Formatter(final Locale locale,final Symbols symbols,final NumberFormat numberFormat,final DateFormat dateFormat,final UnitFormat unitFormat){
  this.locale=locale;
  this.convention=Convention.DEFAULT;
  this.authority=Convention.DEFAULT.getNameAuthority();
  this.symbols=symbols;
  this.lineSeparator=this.symbols.lineSeparator();
  this.indentation=WKTFormat.DEFAULT_INDENTATION;
  this.numberFormat=numberFormat;
  this.dateFormat=dateFormat;
  this.unitFormat=new PatchedUnitFormat(unitFormat);
}
Program: 92148
Project: 92148
Buggy source:
/** 
 * Constructs a parser for the specified set of symbols using the specified set of factories.
 * @param symbols       The set of symbols to use.
 * @param convention    The WKT convention to use.
 * @param isAxisIgnored {@code true} if {@code AXIS} elements should be ignored.
 * @param errorLocale   The locale for error messages (not for parsing), or {@code null} for the system default.
 * @param factories     On input, the factories to use. On output, the factories used. Can be null.
 */
GeodeticObjectParser(final Symbols symbols,final Convention convention,final boolean isAxisIgnored,final Locale errorLocale,final Map<Class<?>,Factory> factories){
  super(symbols,getFactory(MathTransformFactory.class,factories),errorLocale);
  crsFactory=getFactory(CRSFactory.class,factories);
  csFactory=getFactory(CSFactory.class,factories);
  datumFactory=getFactory(DatumFactory.class,factories);
  referencing=ReferencingServices.getInstance();
  opFactory=referencing.getCoordinateOperationFactory(null,mtFactory);
  this.convention=convention;
  this.isAxisIgnored=isAxisIgnored;
}

Fixed version (ground truth):
/** 
 * Constructs a parser for the specified set of symbols using the specified set of factories. This constructor is for   {@link WKTFormat} usage only.
 * @param symbols       The set of symbols to use.
 * @param numberFormat  The number format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param dateFormat    The date format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param convention    The WKT convention to use.
 * @param isAxisIgnored {@code true} if {@code AXIS} elements should be ignored.
 * @param errorLocale   The locale for error messages (not for parsing), or {@code null} for the system default.
 * @param factories     On input, the factories to use. On output, the factories used. Can be null.
 */
GeodeticObjectParser(final Symbols symbols,final NumberFormat numberFormat,final DateFormat dateFormat,final Convention convention,final boolean isAxisIgnored,final Locale errorLocale,final Map<Class<?>,Factory> factories){
  super(symbols,numberFormat,dateFormat,getFactory(MathTransformFactory.class,factories),errorLocale);
  crsFactory=getFactory(CRSFactory.class,factories);
  csFactory=getFactory(CSFactory.class,factories);
  datumFactory=getFactory(DatumFactory.class,factories);
  referencing=ReferencingServices.getInstance();
  opFactory=referencing.getCoordinateOperationFactory(null,mtFactory);
  this.convention=convention;
  this.isAxisIgnored=isAxisIgnored;
}
Program: 92149
Project: 92149
Buggy source:
/** 
 * Creates a parser using the specified set of symbols and factory.
 * @param symbols     The set of symbols to use.
 * @param mtFactory   The factory to use to create {@link MathTransform} objects.
 * @param errorLocale The locale for error messages (not for parsing), or {@code null} for the system default.
 */
public MathTransformParser(final Symbols symbols,final MathTransformFactory mtFactory,final Locale errorLocale){
  super(symbols,errorLocale);
  this.mtFactory=mtFactory;
  ensureNonNull("String_Node_Str",mtFactory);
}

Fixed version (ground truth):
/** 
 * Creates a parser using the specified set of symbols and factory.
 * @param symbols       The set of symbols to use.
 * @param numberFormat  The number format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param dateFormat    The date format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param mtFactory     The factory to use to create {@link MathTransform} objects.
 * @param errorLocale   The locale for error messages (not for parsing), or {@code null} for the system default.
 */
MathTransformParser(final Symbols symbols,final NumberFormat numberFormat,final DateFormat dateFormat,final MathTransformFactory mtFactory,final Locale errorLocale){
  super(symbols,numberFormat,dateFormat,errorLocale);
  this.mtFactory=mtFactory;
  ensureNonNull("String_Node_Str",mtFactory);
}
Program: 92150
Project: 92150
Buggy source:
/** 
 * Constructs a parser using the specified set of symbols.
 * @param symbols     The set of symbols to use.
 * @param errorLocale The locale for error messages (not for parsing), or {@code null} for the system default.
 */
Parser(final Symbols symbols,final Locale errorLocale){
  this.errorLocale=errorLocale;
  ensureNonNull("String_Node_Str",symbols);
  this.symbols=symbols;
  numberFormat=symbols.createNumberFormat();
  if (SCIENTIFIC_NOTATION && numberFormat instanceof DecimalFormat) {
    final DecimalFormat decimalFormat=(DecimalFormat)numberFormat;
    exponentSymbol=decimalFormat.getDecimalFormatSymbols().getExponentSeparator();
    String pattern=decimalFormat.toPattern();
    if (!pattern.contains("String_Node_Str")) {
      final StringBuilder buffer=new StringBuilder(pattern);
      final int split=pattern.indexOf(';');
      if (split >= 0) {
        buffer.insert(split,"String_Node_Str");
      }
      buffer.append("String_Node_Str");
      decimalFormat.applyPattern(buffer.toString());
    }
  }
 else {
    exponentSymbol=null;
  }
  ignoredElements=new LinkedHashMap<String,List<String>>();
}

Fixed version (ground truth):
/** 
 * Constructs a parser using the specified set of symbols.
 * @param symbols       The set of symbols to use.
 * @param numberFormat  The number format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param dateFormat    The date format provided by {@link WKTFormat}, or   {@code null} for a default format.
 * @param errorLocale   The locale for error messages (not for parsing), or {@code null} for the system default.
 */
Parser(final Symbols symbols,NumberFormat numberFormat,final DateFormat dateFormat,final Locale errorLocale){
  ensureNonNull("String_Node_Str",symbols);
  if (numberFormat == null) {
    numberFormat=symbols.createNumberFormat();
  }
  this.symbols=symbols;
  this.numberFormat=numberFormat;
  this.dateFormat=dateFormat;
  this.errorLocale=errorLocale;
  if (SCIENTIFIC_NOTATION && numberFormat instanceof DecimalFormat) {
    final DecimalFormat decimalFormat=(DecimalFormat)numberFormat;
    exponentSymbol=decimalFormat.getDecimalFormatSymbols().getExponentSeparator();
    String pattern=decimalFormat.toPattern();
    if (!pattern.contains("String_Node_Str")) {
      final StringBuilder buffer=new StringBuilder(pattern);
      final int split=pattern.indexOf(';');
      if (split >= 0) {
        buffer.insert(split,"String_Node_Str");
      }
      buffer.append("String_Node_Str");
      decimalFormat.applyPattern(buffer.toString());
    }
  }
 else {
    exponentSymbol=null;
  }
  ignoredElements=new LinkedHashMap<String,List<String>>();
}
Program: 92151
Project: 92151
Buggy source:
/** 
 * Creates an object from the given character sequence. The parsing begins at the index given by the   {@code pos} argument.
 * @param text The character sequence for the object to parse.
 * @param pos  The position where to start the parsing.
 * @return The parsed object.
 * @throws ParseException If an error occurred while parsing the object.
 */
@Override public Object parse(final CharSequence text,final ParsePosition pos) throws ParseException {
  if (parser == null) {
    if (factories == null) {
      factories=new HashMap<Class<?>,Factory>();
    }
    parser=new GeodeticObjectParser(symbols,convention,false,getLocale(),factories);
  }
  return parser.parseObject(text.toString(),pos);
}

Fixed version (ground truth):
/** 
 * Creates an object from the given character sequence. The parsing begins at the index given by the   {@code pos} argument.
 * @param text The character sequence for the object to parse.
 * @param pos  The position where to start the parsing.
 * @return The parsed object.
 * @throws ParseException If an error occurred while parsing the object.
 */
@Override public Object parse(final CharSequence text,final ParsePosition pos) throws ParseException {
  if (parser == null) {
    if (factories == null) {
      factories=new HashMap<Class<?>,Factory>();
    }
    parser=new GeodeticObjectParser(symbols,(NumberFormat)getFormat(Number.class),(DateFormat)getFormat(Date.class),convention,false,getLocale(),factories);
  }
  return parser.parseObject(text.toString(),pos);
}
Program: 92152
Project: 92152
Buggy source:
/** 
 * Builds a coordinate system name from the given array of axes. This method expects a   {@code StringBuilder} pre-filled with the coordinate system name.The axis directions and abbreviations will be appended after the CS name. Examples: <ul> <li>Ellipsoidal CS: North (°), East (°).</li> <li>Cartesian CS: East (km), North (km).</li> <li>Compound CS: East (km), North (km), Up (m).</li> </ul>
 * @param buffer A buffer pre-filled with the name header.
 * @param axes The axes to append in the given buffer.
 * @return A name for the given coordinate system type and axes.
 * @since 0.6
 */
public static String appendTo(final StringBuilder buffer,final CoordinateSystemAxis[] axes){
  String separator="String_Node_Str";
  for (  final CoordinateSystemAxis axis : axes) {
    buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
    separator="String_Node_Str";
    final String symbol=Utilities.toString(axis.getUnit());
    if (symbol != null && !symbol.isEmpty()) {
      buffer.append("String_Node_Str").append(symbol).append(')');
    }
  }
  return buffer.append('.').toString();
}

Fixed version (ground truth):
/** 
 * Builds a coordinate system name from the given array of axes. This method expects a   {@code StringBuilder} pre-filled with the coordinate system name.The axis directions and abbreviations will be appended after the CS name. Examples: <ul> <li>Ellipsoidal CS: North (°), East (°).</li> <li>Cartesian CS: East (km), North (km).</li> <li>Compound CS: East (km), North (km), Up (m).</li> </ul>
 * @param buffer A buffer pre-filled with the name header.
 * @param axes The axes to append in the given buffer.
 * @return A name for the given coordinate system type and axes.
 * @since 0.6
 */
public static String appendTo(final StringBuilder buffer,final CoordinateSystemAxis[] axes){
  String separator="String_Node_Str";
  for (  final CoordinateSystemAxis axis : axes) {
    buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
    separator="String_Node_Str";
    final String symbol=PatchedUnitFormat.toString(axis.getUnit());
    if (symbol != null && !symbol.isEmpty()) {
      buffer.append("String_Node_Str").append(symbol).append(')');
    }
  }
  return buffer.append('.').toString();
}
Program: 92153
Project: 92153
Buggy source:
/** 
 * The standard three-dimensional Cartesian CS as defined by ISO 19111.
 */
private static CartesianCS standard(){
  return (CartesianCS)CommonCRS.WGS84.geocentric().getCoordinateSystem();
}

Fixed version (ground truth):
/** 
 * The standard three-dimensional Cartesian CS as defined by ISO 19111.
 * @param unit The linear unit of the desired coordinate system, or {@code null} for metres.
 * @return The ISO 19111 coordinate system.
 */
public static CartesianCS standard(final Unit<?> unit){
  return replaceUnit((CartesianCS)CommonCRS.WGS84.geocentric().getCoordinateSystem(),unit);
}
Program: 92154
Project: 92154
Buggy source:
/** 
 * Do not allow instantiation of this class.
 */
private Legacy(){
}

Fixed version (ground truth):
/** 
 * For internal usage by   {@link #replaceUnit(CartesianCS,Unit)} only.
 */
private Legacy(final Unit<?> unit){
  this.unit=unit;
}
Program: 92155
Project: 92155
Buggy source:
/** 
 * Returns the axes to use instead of the ones in the given coordinate system. If the coordinate system axes should be used as-is, returns   {@code cs}.
 * @param cs The coordinate system for which to compare the axis directions.
 * @param toLegacy {@code true} for replacing ISO directions by the legacy ones,or  {@code false} for the other way around.
 * @return The axes to use instead of the ones in the given CS,or  {@code cs} if the CS axes should be used as-is.
 */
public static CartesianCS forGeocentricCRS(final CartesianCS cs,final boolean toLegacy){
  final CartesianCS check=toLegacy ? standard() : LEGACY;
  final int dimension=check.getDimension();
  if (cs.getDimension() != dimension) {
    return cs;
  }
  for (int i=0; i < dimension; i++) {
    if (!cs.getAxis(i).getDirection().equals(check.getAxis(i).getDirection())) {
      return cs;
    }
  }
  return toLegacy ? LEGACY : standard();
}

Fixed version (ground truth):
/** 
 * Returns the axes to use instead of the ones in the given coordinate system. If the coordinate system axes should be used as-is, returns   {@code cs}.
 * @param cs The coordinate system for which to compare the axis directions.
 * @param toLegacy {@code true} for replacing ISO directions by the legacy ones,or  {@code false} for the other way around.
 * @return The axes to use instead of the ones in the given CS,or  {@code cs} if the CS axes should be used as-is.
 */
public static CartesianCS forGeocentricCRS(final CartesianCS cs,final boolean toLegacy){
  final CartesianCS check=toLegacy ? standard(null) : LEGACY;
  final int dimension=check.getDimension();
  if (cs.getDimension() != dimension) {
    return cs;
  }
  for (int i=0; i < dimension; i++) {
    if (!cs.getAxis(i).getDirection().equals(check.getAxis(i).getDirection())) {
      return cs;
    }
  }
  final Unit<?> unit=ReferencingUtilities.getUnit(cs);
  return toLegacy ? replaceUnit(LEGACY,unit) : standard(unit);
}
Program: 92156
Project: 92156
Buggy source:
/** 
 * Removes the unit previously added by a call to   {@code addContextualUnit(unit)}. If the given unit is null, then this method does nothing.
 * @param unit The contextual unit to remove, or {@code null} if none.
 */
public void removeContextualUnit(final Unit<?> unit){
  if (unit != null) {
    units.remove(unit.toSI());
  }
}

Fixed version (ground truth):
/** 
 * Removes the unit previously added by a call to   {@code addContextualUnit(unit)}. If the given unit is null, then this method does nothing.
 * @param unit The contextual unit to remove, or {@code null} if none.
 * @deprecated Replaced by {@link #restoreContextualUnit(Unit,Unit)}.
 */
@Deprecated public void removeContextualUnit(final Unit<?> unit){
  if (unit != null) {
    units.remove(unit.toSI());
  }
}
Program: 92157
Project: 92157
Buggy source:
/** 
 * Returns the unit to use instead than the given one, or   {@code null} if there is no replacementfor  {@code unit}. This method searches for a unit specified by   {@link #addContextualUnit(Unit)}which   {@linkplain Unit#isCompatible(Unit) is compatible} with the given unit.
 * @param < Q >  The quantity of the unit.
 * @param unit The unit to replace by the contextual unit, or {@code null}.
 * @return A contextual unit compatible with the given unit, or {@code unit}if no contextual unit has been found.
 */
public <Q extends Quantity>Unit<Q> toContextualUnit(final Unit<Q> unit){
  if (unit != null) {
    @SuppressWarnings("String_Node_Str") final Unit<Q> candidate=(Unit<Q>)units.get(unit.toSI());
    if (candidate != null) {
      return candidate;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Returns the unit to use instead than the given one, or   {@code unit} if there is no replacement.This method searches for a unit specified by  {@link #addContextualUnit(Unit)}which   {@linkplain Unit#isCompatible(Unit) is compatible} with the given unit.
 * @param < Q >  The quantity of the unit.
 * @param unit The unit to replace by the contextual unit, or {@code null}.
 * @return A contextual unit compatible with the given unit, or {@code unit}(which may be null) if no contextual unit has been found.
 */
public <Q extends Quantity>Unit<Q> toContextualUnit(final Unit<Q> unit){
  if (unit != null) {
    @SuppressWarnings("String_Node_Str") final Unit<Q> candidate=(Unit<Q>)units.get(unit.toSI());
    if (candidate != null) {
      return candidate;
    }
  }
  return unit;
}
Program: 92158
Project: 92158
Buggy source:
/** 
 * Adds a unit to use for the next measurements of the quantity   {@code Q}. The given unit will apply to all WKT elements containing a value of quantity   {@code Q} without their own {@code UNIT[…]} element,until the  {@link #removeContextualUnit(Unit)} method is invoked with a unit of the same quantity.<p>If the given unit is null, then this method does nothing and returns  {@code null}.</p> <div class="section">Special case</div> If the WKT conventions are   {@code WKT1_COMMON_UNITS}, then this method ignores the given unit and returns   {@code null}. See   {@link Convention#WKT1_COMMON_UNITS} javadoc for more information.
 * @param < Q >  The unit quantity.
 * @param unit The contextual unit to add, or {@code null} if none.
 * @return The previous contextual unit for quantity {@code Q}, or   {@code null} if none.
 */
@SuppressWarnings("String_Node_Str") public <Q extends Quantity>Unit<Q> addContextualUnit(final Unit<Q> unit){
  if (unit == null || convention.usesCommonUnits()) {
    return null;
  }
  hasContextualUnit|=1;
  return (Unit<Q>)units.put(unit.toSI(),unit);
}

Fixed version (ground truth):
/** 
 * Adds a unit to use for the next measurements of the quantity   {@code Q}. The given unit will apply to all WKT elements containing a value of quantity   {@code Q} without their own {@code UNIT[…]} element,until the  {@link #restoreContextualUnit(Unit,Unit)} method is invoked.<p>If the given unit is null, then this method does nothing and returns  {@code null}.</p> <div class="section">Special case</div> If the WKT conventions are   {@code WKT1_COMMON_UNITS}, then this method ignores the given unit and returns   {@code null}. See   {@link Convention#WKT1_COMMON_UNITS} javadoc for more information.
 * @param < Q >  The unit quantity.
 * @param unit The contextual unit to add, or {@code null} if none.
 * @return The previous contextual unit for quantity {@code Q}, or   {@code null} if none.
 */
@SuppressWarnings("String_Node_Str") public <Q extends Quantity>Unit<Q> addContextualUnit(final Unit<Q> unit){
  if (unit == null || convention.usesCommonUnits()) {
    return null;
  }
  hasContextualUnit|=1;
  return (Unit<Q>)units.put(unit.toSI(),unit);
}
Program: 92160
Project: 92160
Buggy source:
/** 
 * Returns the angular unit of the specified coordinate system. The preference will be given to the longitude axis, if found.
 * @param cs The coordinate system from which to get the angular unit, or {@code null}.
 * @return The angular unit, of {@link NonSI#DEGREE_ANGLE} if no angular unit was found.
 * @since 0.6
 */
public static Unit<Angle> getAngularUnit(final CoordinateSystem cs){
  Unit<Angle> unit=NonSI.DEGREE_ANGLE;
  if (cs != null) {
    for (int i=cs.getDimension(); --i >= 0; ) {
      final CoordinateSystemAxis axis=cs.getAxis(i);
      if (axis != null) {
        final Unit<?> candidate=axis.getUnit();
        if (Units.isAngular(candidate)) {
          unit=candidate.asType(Angle.class);
          if (AxisDirection.EAST.equals(AxisDirections.absolute(axis.getDirection()))) {
            break;
          }
        }
      }
    }
  }
  return unit;
}

Fixed version (ground truth):
/** 
 * Returns the angular unit of the specified coordinate system. The preference will be given to the longitude axis, if found.
 * @param cs The coordinate system from which to get the angular unit, or {@code null}.
 * @return The angular unit, of {@code null} if no angular unit was found.
 * @since 0.6
 */
public static Unit<Angle> getAngularUnit(final CoordinateSystem cs){
  Unit<Angle> unit=null;
  if (cs != null) {
    for (int i=cs.getDimension(); --i >= 0; ) {
      final CoordinateSystemAxis axis=cs.getAxis(i);
      if (axis != null) {
        final Unit<?> candidate=axis.getUnit();
        if (Units.isAngular(candidate)) {
          unit=candidate.asType(Angle.class);
          if (AxisDirection.EAST.equals(AxisDirections.absolute(axis.getDirection()))) {
            break;
          }
        }
      }
    }
  }
  return unit;
}
Program: 92163
Project: 92163
Buggy source:
/** 
 * Formats the given coordinate system. <p>In WKT 2 format, this method should not be invoked if   {@link #isBaseCRS(Formatter)} returned {@code true}because ISO 19162 excludes the coordinate system definition in base CRS. Note however that WKT 1 includes the coordinate systems.</p>
 * @param formatter The formatter where to append the coordinate system.
 * @param cs        The coordinate system to append.
 * @param isWKT1    {@code true} if formatting WKT 1, or {@code false} for WKT 2.
 */
final void formatCS(final Formatter formatter,final CoordinateSystem cs,final boolean isWKT1){
}

Fixed version (ground truth):
/** 
 * Formats the given coordinate system. <p>In WKT 2 format, this method should not be invoked if   {@link #isBaseCRS(Formatter)} returned {@code true}because ISO 19162 excludes the coordinate system definition in base CRS. Note however that WKT 1 includes the coordinate systems.</p> <div class="note"><b>Note:</b> the   {@code unit} and {@code isWKT1} arguments could be computed by this method,but are requested in order to avoid computing them twice, because the caller usually have them anyway.</div>
 * @param formatter The formatter where to append the coordinate system.
 * @param cs        The coordinate system to append.
 * @param unit      The value of {@code ReferencingUtilities.getUnit(cs)}.
 * @param isWKT1    {@code true} if formatting WKT 1, or {@code false} for WKT 2.
 */
final void formatCS(final Formatter formatter,final CoordinateSystem cs,final Unit<?> unit,final boolean isWKT1){
}
Program: 92164
Project: 92164
Buggy source:
/** 
 * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation of this CRS. The default implementation writes the following elements in WKT 2 format: <ul> <li>The object   {@linkplain #getName() name}.</li> <li>The datum, if any.</li> <li>All   {@linkplain #getCoordinateSystem() coordinate system}'s axis.</li> <li>The unit if all axes use the same unit, or nothing otherwise.</li> </ul> The WKT 1 format is similar to the WKT 2 one with two differences: <ul> <li>Units are formatted before the axes instead than after the axes.</li> <li>If no unit can be formatted because not all axes use the same unit, then the WKT is  {@linkplain Formatter#setInvalidWKT(IdentifiedObject,Exception) flagged as invalid}.</li> </ul>
 * @return {@inheritDoc}
 * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html">WKT 2 specification</a>
 * @see <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html">Legacy WKT 1</a>
 */
@Override protected String formatTo(final Formatter formatter){
  final String keyword=super.formatTo(formatter);
  formatter.newLine();
  formatter.append(toFormattable(getDatum()));
  formatter.newLine();
  final boolean isWKT1=formatter.getConvention().majorVersion() == 1;
  if (isWKT1 || !isBaseCRS(formatter)) {
    formatCS(formatter,getCoordinateSystem(),isWKT1);
  }
  return keyword;
}

Fixed version (ground truth):
/** 
 * Formats the inner part of the <cite>Well Known Text</cite> (WKT) representation of this CRS. The default implementation writes the following elements in WKT 2 format: <ul> <li>The object   {@linkplain #getName() name}.</li> <li>The datum, if any.</li> <li>All   {@linkplain #getCoordinateSystem() coordinate system}'s axis.</li> <li>The unit if all axes use the same unit, or nothing otherwise.</li> </ul> The WKT 1 format is similar to the WKT 2 one with two differences: <ul> <li>Units are formatted before the axes instead than after the axes.</li> <li>If no unit can be formatted because not all axes use the same unit, then the WKT is  {@linkplain Formatter#setInvalidWKT(IdentifiedObject,Exception) flagged as invalid}.</li> </ul>
 * @return {@inheritDoc}
 * @see <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html">WKT 2 specification</a>
 * @see <a href="http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html">Legacy WKT 1</a>
 */
@Override protected String formatTo(final Formatter formatter){
  final String keyword=super.formatTo(formatter);
  formatter.newLine();
  formatter.append(toFormattable(getDatum()));
  formatter.newLine();
  final boolean isWKT1=formatter.getConvention().majorVersion() == 1;
  if (isWKT1 || !isBaseCRS(formatter)) {
    final CoordinateSystem cs=getCoordinateSystem();
    formatCS(formatter,cs,ReferencingUtilities.getUnit(cs),isWKT1);
  }
  return keyword;
}
Program: 92165
Project: 92165
Buggy source:
/** 
 * Returns   {@code true} if the given formatter is in the process of formatting the base CRS of a{@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be formatted. <p>This method should return   {@code true} when {@code this} CRS is the value returned by{@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}). Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity (assuming that the user did not created some weird subclass).</p> <p>This method should be invoked for WKT 2 formatting only.</p>
 */
static boolean isBaseCRS(final Formatter formatter){
  return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS;
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if the given formatter is in the process of formatting the base CRS of an{@link AbstractDerivedCRS}. In such case, the coordinate system axes shall not be formatted. <p>This method should return   {@code true} when {@code this} CRS is the value returned by{@link GeneralDerivedCRS#getBaseCRS()} (typically {@link AbstractDerivedCRS#getBaseCRS()}). Since the base CRS is the only CRS enclosed in derived CRS, we should have no ambiguity (assuming that the user did not created some weird subclass).</p> <p>This method should be invoked for WKT 2 formatting only.</p>
 */
static boolean isBaseCRS(final Formatter formatter){
  return formatter.getEnclosingElement(1) instanceof GeneralDerivedCRS;
}
Program: 92169
Project: 92169
Buggy source:
@Override public Unit<?> getUnitReplacement(final Unit<?> unit){
  return unit;
}

Fixed version (ground truth):
@Override public Unit<?> getUnitReplacement(final Unit<?> unit){
  return linearUnit;
}
Program: 92170
Project: 92170
Buggy source:
/** 
 * Returns the coordinate system of a geocentric CRS using axes in the given unit of measurement.
 * @param unit The unit of measurement for the geocentric CRS axes.
 * @return The coordinate system for a geocentric CRS with axes using the given unit of measurement.
 * @since 0.6
 */
@Override public CartesianCS getGeocentricCS(final Unit<Length> unit){
  CartesianCS cs=(CartesianCS)CommonCRS.WGS84.geocentric().getCoordinateSystem();
  if (!SI.METRE.equals(unit)) {
    cs=(CartesianCS)CoordinateSystems.replaceAxes(cs,new AxisFilter(){
      @Override public Unit<?> getUnitReplacement(      final Unit<?> unit){
        return unit;
      }
    }
);
  }
  return cs;
}

Fixed version (ground truth):
/** 
 * Returns the coordinate system of a geocentric CRS using axes in the given unit of measurement.
 * @param linearUnit The unit of measurement for the geocentric CRS axes.
 * @return The coordinate system for a geocentric CRS with axes using the given unit of measurement.
 * @since 0.6
 */
@Override public CartesianCS getGeocentricCS(final Unit<Length> linearUnit){
  CartesianCS cs=(CartesianCS)CommonCRS.WGS84.geocentric().getCoordinateSystem();
  if (!SI.METRE.equals(linearUnit)) {
    cs=(CartesianCS)CoordinateSystems.replaceAxes(cs,new AxisFilter(){
      @Override public Unit<?> getUnitReplacement(      final Unit<?> unit){
        return linearUnit;
      }
    }
);
  }
  return cs;
}
Program: 92171
Project: 92171
Buggy source:
/** 
 * Returns the parameter values for this map projection.
 * @return The map projection parameters if they are an accurate description of this transform,or the generic affine parameters in case of doubt.
 */
@Override public ParameterValueGroup getParameterValues(){
  return isDefinitive ? parameters : super.getParameterValues();
}

Fixed version (ground truth):
/** 
 * Returns the parameter values for this map projection. <p><b>Hack:</b> this method normally returns the matrix parameters in case of doubt. However if  {@link Semaphores#PROJCS} is set, then this method returns the map projection parameters evenif they are not a complete description of this math transform. This internal hack shall be used only by  {@link org.apache.sis.referencing.operation.DefaultSingleOperation}.</p> <p><b>Use case of above hack:</b> consider an "Equidistant Cylindrical (Spherical)" map projection from a   {@code GeographiCRS} base using (latitude, longitude) axis order. We need to concatenate anaffine transform performing the axis swapping before the actual map projection. The concatenated transform is part of  {@code SingleOperation}, which is itself part of   {@code ProjecteCRS}. Consequently we have two conflicting needs:</p> <ul> <li>If this method is queried from a   {@code SingleOperation} instance (usually indirectly as part of a{@code ProjectedCRS}), then we want to return the "Equidistant Cylindrical (Spherical)" map projection parameters without bothering about axis swapping, because the later is described by the   {@code Axis["…"]}elements in the enclosing   {@code ProjectedCRS} instance.</li><li>But if this  {@code MathTransform} is formatted directly (not as a component of {@code ProjectedCRS}), then we want to format it as a matrix, otherwise the users would have no way to see that an axis swapping has been applied.</li> </ul> The   {@code Semaphores.PROJCS} flag is SIS internal mechanism for distinguish the two above-cited cases.
 * @return The map projection parameters if they are an accurate description of this transform,or the generic affine parameters in case of doubt.
 */
@Override public ParameterValueGroup getParameterValues(){
  return isDefinitive || Semaphores.query(Semaphores.PROJCS) ? parameters : super.getParameterValues();
}
Program: 92172
Project: 92172
Buggy source:
/** 
 * Compares this affine transform with the given object for equality. Parameters are compared only if the other object is also an instance of   {@code ParameterizedAffine}in order to preserve the   {@link AffineTransform#equals(Object)} <cite>symmetricity</cite> contract.
 * @param object The object to compare with this transform for equality.
 * @return {@code true} if the given object is of appropriate class (as explained in the{@link AffineTransform2D#equals(Object)} documentation) and the coefficients are the same.
 */
@Override public boolean equals(final Object object){
  if (super.equals(object)) {
    if (object instanceof ParameterizedAffine) {
      final ParameterizedAffine that=(ParameterizedAffine)object;
      return Objects.equals(this.parameters,that.parameters);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Compares this affine transform with the given object for equality. Parameters are compared only if the other object is also an instance of   {@code ParameterizedAffine}in order to preserve the   {@link AffineTransform#equals(Object)} <cite>symmetricity</cite> contract.
 * @param object The object to compare with this transform for equality.
 * @return {@code true} if the given object is of appropriate class (as explained in the{@link AffineTransform2D#equals(Object)} documentation) and the coefficients are the same.
 */
@Override public boolean equals(final Object object){
  if (super.equals(object)) {
    if (object instanceof ParameterizedAffine) {
      final ParameterizedAffine that=(ParameterizedAffine)object;
      return (this.isDefinitive == that.isDefinitive) && Objects.equals(this.parameters,that.parameters);
    }
    return true;
  }
  return false;
}
Program: 92173
Project: 92173
Buggy source:
/** 
 * Returns a name for a coordinate system. Examples: <ul> <li>Ellipsoidal CS: North (°), East (°).</li> <li>Cartesian CS: East (km), North (km).</li> <li>Compound CS: East (km), North (km), Up (m).</li> </ul>
 * @param buffer A buffer filled with the name header.
 * @param axes The axes.
 * @return A name for the given coordinate system type and axes.
 */
static String createName(final StringBuilder buffer,final CoordinateSystemAxis[] axes){
  String separator="String_Node_Str";
  for (  final CoordinateSystemAxis axis : axes) {
    buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
    separator="String_Node_Str";
    final Unit<?> unit=axis.getUnit();
    if (unit != null) {
      final String symbol=unit.toString();
      if (!symbol.isEmpty()) {
        buffer.append("String_Node_Str").append(symbol).append(')');
      }
    }
  }
  return buffer.append('.').toString();
}

Fixed version (ground truth):
/** 
 * Returns a name for a coordinate system. Examples: <ul> <li>Ellipsoidal CS: North (°), East (°).</li> <li>Cartesian CS: East (km), North (km).</li> <li>Compound CS: East (km), North (km), Up (m).</li> </ul>
 * @param buffer A buffer filled with the name header.
 * @param axes The axes.
 * @return A name for the given coordinate system type and axes.
 */
static String createName(final StringBuilder buffer,final CoordinateSystemAxis[] axes){
  String separator="String_Node_Str";
  for (  final CoordinateSystemAxis axis : axes) {
    buffer.append(separator).append(Types.getCodeLabel(axis.getDirection()));
    separator="String_Node_Str";
    final String symbol=Utilities.toString(axis.getUnit());
    if (symbol != null && !symbol.isEmpty()) {
      buffer.append("String_Node_Str").append(symbol).append(')');
    }
  }
  return buffer.append('.').toString();
}