nus-yam/ex-repair huggingface dataset:
Program: 92079
Project: 92079
Buggy source:
/** 
 * Verifies if the given property can be assigned to this feature.
 * @param name Shall be {@code property.getName().toString()}.
 * @param property The property to verify.
 */
final void verifyPropertyType(final String name,final Property property){
  final PropertyType pt, base=type.getProperty(name);
  if (property instanceof Attribute<?>) {
    pt=((Attribute<?>)property).getType();
  }
 else   if (property instanceof FeatureAssociation) {
    pt=((FeatureAssociation)property).getRole();
  }
 else {
    throw illegalPropertyType(base.getName(),property.getClass());
  }
  if (pt != base) {
    throw new IllegalArgumentException(base == null ? Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name) : Errors.format(Errors.Keys.MismatchedPropertyType_1,name));
  }
}

Fixed version (ground truth):
/** 
 * Verifies if the given property can be assigned to this feature.
 * @param name Shall be {@code property.getName().toString()}.
 * @param property The property to verify.
 */
final void verifyPropertyType(final String name,final Property property){
  final PropertyType pt, base=type.getProperty(name);
  if (property instanceof Attribute<?>) {
    pt=((Attribute<?>)property).getType();
  }
 else   if (property instanceof FeatureAssociation) {
    pt=((FeatureAssociation)property).getRole();
  }
 else {
    throw illegalPropertyType(base.getName(),property.getClass());
  }
  if (pt != base) {
    if (base == null) {
      throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
    }
 else {
      throw new InvalidPropertyValueException(Errors.format(Errors.Keys.MismatchedPropertyType_1,name));
    }
  }
}
Program: 92080
Project: 92080
Buggy source:
/** 
 * Returns the property (attribute, feature association or operation result) of the given name. If the property type is a parameterless   {@linkplain AbstractOperation operation}, then this method may return the result of   {@linkplain AbstractOperation#apply executing} the operationon this feature, at implementation choice. <div class="note"><b>Tip:</b> This method returns the property <em>instance</em>. If only the property <em>value</em> is desired, then  {@link #getPropertyValue(String)} is preferred since it gives to SIS achance to avoid the creation of  {@link AbstractAttribute} or {@link AbstractAssociation} instances.</div>
 * @param name The property name.
 * @return The property of the given name (never {@code null}).
 * @throws IllegalArgumentException If the given argument is not a property name of this feature.
 * @see #getPropertyValue(String)
 * @see DefaultFeatureType#getProperty(String)
 */
@Override public abstract Property getProperty(final String name) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Returns the property (attribute, feature association or operation result) of the given name. If the property type is a parameterless   {@linkplain AbstractOperation operation}, then this method may return the result of   {@linkplain AbstractOperation#apply executing} the operationon this feature, at implementation choice. <div class="note"><b>Tip:</b> This method returns the property <em>instance</em>. If only the property <em>value</em> is desired, then  {@link #getPropertyValue(String)} is preferred since it gives to SIS achance to avoid the creation of  {@link AbstractAttribute} or {@link AbstractAssociation} instances.</div>
 * @param name The property name.
 * @return The property of the given name (never {@code null}).
 * @throws PropertyNotFoundException if the given argument is not a property name of this feature.
 * @see #getPropertyValue(String)
 * @see DefaultFeatureType#getProperty(String)
 */
@Override public abstract Property getProperty(final String name) throws PropertyNotFoundException ;
Program: 92081
Project: 92081
Buggy source:
/** 
 * Returns the exception for a property type which neither an attribute or an association. This method is invoked after a   {@link PropertyType} has been found for the user-supplied name,but that property can not be stored in a  {@link Property} instance.
 */
static IllegalArgumentException unsupportedPropertyType(final GenericName name){
  return new IllegalArgumentException(Errors.format(Errors.Keys.CanNotInstantiate_1,name));
}

Fixed version (ground truth):
/** 
 * Returns the exception for a property type which is neither an attribute or an association. This method is invoked after a   {@link PropertyType} has been found for the user-supplied name,but that property can not be stored in or extracted from a  {@link Property} instance.
 */
static IllegalArgumentException unsupportedPropertyType(final GenericName name){
  return new IllegalArgumentException(Errors.format(Errors.Keys.CanNotInstantiate_1,name));
}
Program: 92083
Project: 92083
Buggy source:
/** 
 * Sets the property (attribute or feature association). The given property shall comply to the following conditions: <ul> <li>It must be non-null.</li> <li>Its   {@linkplain Property#getName() name} shall be the name of the property to set in this feature.</li><li>Its type shall be the same instance than the  {@linkplain DefaultFeatureType#getProperty(String) property type} defined by the feature type for the above name.In other words, the following condition shall hold:</li> </ul> {@preformat javaassert property.getType() == getType().getProperty(property.getName());}<div class="note"><b>Note:</b> This method is useful for storing non-default   {@code Attribute} or{@code FeatureAssociation} implementations in this feature. When default implementations are sufficient,the  {@link #setPropertyValue(String,Object)} method is preferred.</div>
 * @param property The property to set.
 * @throws IllegalArgumentException if the type of the given property is not one of the typesknown to this feature, or if the property can not be set of an other reason.
 * @see #setPropertyValue(String,Object)
 */
@Override public abstract void setProperty(final Property property) throws IllegalArgumentException ;

Fixed version (ground truth):
/** 
 * Sets the property (attribute or feature association). The given property shall comply to the following conditions: <ul> <li>It must be non-null.</li> <li>Its   {@linkplain Property#getName() name} shall be the name of the property to set in this feature.</li><li>Its type shall be the same instance than the  {@linkplain DefaultFeatureType#getProperty(String) property type} defined by the feature type for the above name.In other words, the following condition shall hold:</li> </ul> {@preformat javaassert property.getType() == getType().getProperty(property.getName());}<div class="note"><b>Note:</b> This method is useful for storing non-default   {@code Attribute} or{@code FeatureAssociation} implementations in this feature. When default implementations are sufficient,the  {@link #setPropertyValue(String,Object)} method is preferred.</div>
 * @param property The property to set.
 * @throws PropertyNotFoundException if the name of the given property is not a property name of this feature.
 * @throws InvalidPropertyValueException if the value of the given property is not valid.
 * @throws IllegalArgumentException if the property can not be set for another reason.
 * @see #setPropertyValue(String,Object)
 */
@Override public abstract void setProperty(final Property property) throws IllegalArgumentException ;
Program: 92084
Project: 92084
Buggy source:
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws IllegalArgumentException If the given argument is not the name of an attribute orfeature association of this feature.
 */
final Property createProperty(final String name) throws IllegalArgumentException {
  final PropertyType pt=type.getProperty(name);
  if (pt instanceof AttributeType<?>) {
    return ((AttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof FeatureAssociationRole) {
    return ((FeatureAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}

Fixed version (ground truth):
/** 
 * Creates a new property initialized to its default value.
 * @param name The name of the property to create.
 * @return A {@code Property} of the given name.
 * @throws PropertyNotFoundException if the given argument is not the name of an attribute orfeature association of this feature.
 */
final Property createProperty(final String name) throws PropertyNotFoundException {
  final PropertyType pt=type.getProperty(name);
  if (pt instanceof AttributeType<?>) {
    return ((AttributeType<?>)pt).newInstance();
  }
 else   if (pt instanceof FeatureAssociationRole) {
    return ((FeatureAssociationRole)pt).newInstance();
  }
 else {
    throw unsupportedPropertyType(pt.getName());
  }
}
Program: 92085
Project: 92085
Buggy source:
/** 
 * Returns the exception for a property value (usually a feature) of wrong type.
 */
private static IllegalArgumentException illegalPropertyType(final GenericName name,final Object value){
  return new IllegalArgumentException(Errors.format(Errors.Keys.IllegalPropertyClass_2,name,value));
}

Fixed version (ground truth):
/** 
 * Returns the exception for a property value (usually a feature) of wrong type.
 */
private static InvalidPropertyValueException illegalPropertyType(final GenericName name,final Object value){
  return new InvalidPropertyValueException(Errors.format(Errors.Keys.IllegalPropertyClass_2,name,value));
}
Program: 92086
Project: 92086
Buggy source:
/** 
 * Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then an   {@link IllegalArgumentException}will be thrown with an error message formatted using the name of expected and given types.
 * @param index Index of the expected attribute type.
 * @param type  The actual attribute type.
 */
final void verifyAttributeType(final int index,final AttributeType<?> type){
  final AttributeType<?> expected=types.characterizedBy[index];
  if (!expected.equals(type)) {
    final GenericName en=expected.getName();
    final GenericName an=type.getName();
    throw new IllegalArgumentException(String.valueOf(en).equals(String.valueOf(an)) ? Errors.format(Errors.Keys.MismatchedPropertyType_1,en) : Errors.format(Errors.Keys.CanNotAssign_2,en.push(source.getName()),an));
  }
}

Fixed version (ground truth):
/** 
 * Ensures that the given attribute type is the instance that we expect at the given index. If the given instance is not the expected one, then an   {@link IllegalArgumentException}will be thrown with an error message formatted using the name of expected and given types.
 * @param index Index of the expected attribute type.
 * @param type  The actual attribute type.
 */
final void verifyAttributeType(final int index,final AttributeType<?> type){
  final AttributeType<?> expected=types.characterizedBy[index];
  if (!expected.equals(type)) {
    final GenericName en=expected.getName();
    final GenericName an=type.getName();
    throw new InvalidPropertyValueException(String.valueOf(en).equals(String.valueOf(an)) ? Errors.format(Errors.Keys.MismatchedPropertyType_1,en) : Errors.format(Errors.Keys.CanNotAssign_2,en.push(source.getName()),an));
  }
}
Program: 92087
Project: 92087
Buggy source:
/** 
 * Returns the index for the characteristic of the given name.
 * @param key The name for which to get the characteristic index.
 * @return The index for the characteristic of the given name.
 * @throws IllegalArgumentException if the given key is not the name of a characteristic in this map.
 */
private int indexOf(final String key){
  ArgumentChecks.ensureNonNull("String_Node_Str",key);
  final Integer index=types.indices.get(key);
  if (index == null) {
    throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,source.getName(),key));
  }
  return index;
}

Fixed version (ground truth):
/** 
 * Returns the index for the characteristic of the given name.
 * @param key The name for which to get the characteristic index.
 * @return The index for the characteristic of the given name.
 * @throws PropertyNotFoundException if the given key is not the name of a characteristic in this map.
 */
private int indexOf(final String key){
  ArgumentChecks.ensureNonNull("String_Node_Str",key);
  final Integer index=types.indices.get(key);
  if (index == null) {
    throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,source.getName(),key));
  }
  return index;
}
Program: 92088
Project: 92088
Buggy source:
/** 
 * Returns the attribute, operation or association role for the given name.
 * @param name The name of the property to search.
 * @return The property for the given name, or {@code null} if none.
 * @throws IllegalArgumentException If the given argument is not a property name of this feature.
 * @see AbstractFeature#getProperty(String)
 */
@Override public PropertyType getProperty(final String name) throws IllegalArgumentException {
  final PropertyType pt=byName.get(name);
  if (pt != null) {
    return pt;
  }
  throw new IllegalArgumentException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}

Fixed version (ground truth):
/** 
 * Returns the attribute, operation or association role for the given name.
 * @param name The name of the property to search.
 * @return The property for the given name, or {@code null} if none.
 * @throws PropertyNotFoundException If the given argument is not a property name of this feature.
 * @see AbstractFeature#getProperty(String)
 */
@Override public PropertyType getProperty(final String name) throws PropertyNotFoundException {
  final PropertyType pt=byName.get(name);
  if (pt != null) {
    return pt;
  }
  throw new PropertyNotFoundException(Errors.format(Errors.Keys.PropertyNotFound_2,getName(),name));
}
Program: 92089
Project: 92089
Buggy source:
/** 
 * Creates a new feature instance of this type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} and {@code Feature} to {@link Object} in the Java language,then this method is equivalent to  {@link Class#newInstance()}.</div>
 * @return A new feature instance.
 * @throws IllegalStateException if this feature type {@linkplain #isAbstract() is abstract}.
 */
@Override public Feature newInstance() throws IllegalStateException {
  if (isAbstract) {
    throw new IllegalStateException(Errors.format(Errors.Keys.AbstractType_1,getName()));
  }
  return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}

Fixed version (ground truth):
/** 
 * Creates a new feature instance of this type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} and {@code Feature} to {@link Object} in the Java language,then this method is equivalent to  {@link Class#newInstance()}.</div>
 * @return A new feature instance.
 * @throws FeatureInstantiationException if this feature type {@linkplain #isAbstract() is abstract}.
 */
@Override public Feature newInstance() throws FeatureInstantiationException {
  if (isAbstract) {
    throw new FeatureInstantiationException(Errors.format(Errors.Keys.AbstractType_1,getName()));
  }
  return isSparse ? new SparseFeature(this) : new DenseFeature(this);
}
Program: 92090
Project: 92090
Buggy source:
/** 
 * Returns   {@code true} if this type is same or a super-type of the given type.The check is based mainly on the feature type  {@linkplain #getName() name}, which should be unique. However as a safety, this method also checks that all properties in this feature type is assignable from a property of the same name in the given type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} in the Java language, then this method is equivalentto  {@link Class#isAssignableFrom(Class)}.</div>
 * @param type The type to be checked.
 * @return {@code true} if instances of the given type can be assigned to association of this type.
 */
@Override public boolean isAssignableFrom(final FeatureType type){
  if (type == this) {
    return true;
  }
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  if (!maybeAssignableFrom(this,type)) {
    return false;
  }
  for (  final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
    final PropertyType other;
    try {
      other=type.getProperty(entry.getKey());
    }
 catch (    IllegalArgumentException e) {
      return false;
    }
    if (!isAssignableIgnoreName(entry.getValue(),other)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if this type is same or a super-type of the given type.The check is based mainly on the feature type  {@linkplain #getName() name}, which should be unique. However as a safety, this method also checks that all properties in this feature type is assignable from a property of the same name in the given type. <div class="note"><b>Analogy:</b> if we compare   {@code FeatureType} to {@link Class} in the Java language, then this method is equivalentto  {@link Class#isAssignableFrom(Class)}.</div>
 * @param type The type to be checked.
 * @return {@code true} if instances of the given type can be assigned to association of this type.
 */
@Override public boolean isAssignableFrom(final FeatureType type){
  if (type == this) {
    return true;
  }
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  if (!maybeAssignableFrom(this,type)) {
    return false;
  }
  for (  final Map.Entry<String,PropertyType> entry : byName.entrySet()) {
    final PropertyType other;
    try {
      other=type.getProperty(entry.getKey());
    }
 catch (    PropertyNotFoundException e) {
      return false;
    }
    if (!isAssignableIgnoreName(entry.getValue(),other)) {
      return false;
    }
  }
  return true;
}
Program: 92091
Project: 92091
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: 92092
Project: 92092
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: 92093
Project: 92093
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: 92094
Project: 92094
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: 92095
Project: 92095
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: 92096
Project: 92096
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: 92097
Project: 92097
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: 92098
Project: 92098
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: 92099
Project: 92099
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: 92100
Project: 92100
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: 92101
Project: 92101
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: 92102
Project: 92102
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: 92104
Project: 92104
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: 92107
Project: 92107
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: 92108
Project: 92108
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: 92109
Project: 92109
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: 92112
Project: 92112
Buggy source:
/** 
 * Parses a   {@code "LOCAL_CS"} element.This element has the following pattern: {@preformat text}LOCAL_CS["<name>", <local datum>, <unit>, <axis>,  ,<axis>}* {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "LOCAL_CS"} element as an {@link EngineeringCRS} object.
 * @throws ParseException if the {@code "LOCAL_CS"} element can not be parsed.
 * @todo The coordinate system used is always a SIS implementation, since we don'tknow which method to invokes in the  {@link CSFactory} (is it a Cartesiancoordinate system? a spherical one? etc.).
 */
private EngineeringCRS parseLocalCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.Local_CS);
  final String name=element.pullString("String_Node_Str");
  final EngineeringDatum datum=parseLocalDatum(element);
  final Unit<Length> linearUnit=parseUnit(element,SI.METRE);
  CoordinateSystemAxis axis=parseAxis(element,linearUnit,true);
  final List<CoordinateSystemAxis> list=new ArrayList<CoordinateSystemAxis>();
  do {
    list.add(axis);
    axis=parseAxis(element,linearUnit,false);
  }
 while (axis != null);
  final CoordinateSystem cs=referencing.createAbstractCS(list.toArray(new CoordinateSystemAxis[list.size()]));
  try {
    return crsFactory.createEngineeringCRS(parseAuthorityAndClose(element,name),datum,cs);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}

Fixed version (ground truth):
/** 
 * Parses a   {@code "LOCAL_CS"} element.This element has the following pattern: {@preformat text}LOCAL_CS["<name>", <local datum>, <unit>, <axis>,  ,<axis>}* {,<authority>}] }
 * @param parent The parent element.
 * @return The {@code "LOCAL_CS"} element as an {@link EngineeringCRS} object.
 * @throws ParseException if the {@code "LOCAL_CS"} element can not be parsed.
 * @todo The coordinate system used is always a SIS implementation, since we don'tknow which method to invokes in the  {@link CSFactory} (is it a Cartesiancoordinate system? a spherical one? etc.).
 */
private EngineeringCRS parseLocalCS(final Element parent) throws ParseException {
  final Element element=parent.pullElement(WKTKeywords.Local_CS);
  final String name=element.pullString("String_Node_Str");
  final EngineeringDatum datum=parseLocalDatum(element);
  final Unit<Length> linearUnit=parseUnit(element,SI.METRE);
  CoordinateSystemAxis axis=parseAxis(element,false,linearUnit,true);
  final List<CoordinateSystemAxis> list=new ArrayList<CoordinateSystemAxis>();
  do {
    list.add(axis);
    axis=parseAxis(element,false,linearUnit,false);
  }
 while (axis != null);
  final CoordinateSystem cs=referencing.createAbstractCS(list.toArray(new CoordinateSystemAxis[list.size()]));
  try {
    return crsFactory.createEngineeringCRS(parseAuthorityAndClose(element,name),datum,cs);
  }
 catch (  FactoryException exception) {
    throw element.parseFailed(exception);
  }
}