nus-yam/ex-repair huggingface dataset:
Program: 91762
Project: 91762
Buggy source:
/** 
 * Creates a new map or return an existing map for the given attribute characteristics. <p>This method does not clone the   {@code characterizedBy} array. If that arrayis a user-provided argument, then cloning that array is caller responsibility.</p>
 * @param source  the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  characteristics of {@code source}. Should not be empty.
 * @return a map for this given characteristics.
 * @throws IllegalArgumentException if two characteristics have the same name.
 */
static CharacteristicTypeMap create(final AttributeType<?> source,final AttributeType<?>[] characterizedBy){
  CharacteristicTypeMap map;
synchronized (SHARED) {
    map=SHARED.get(characterizedBy);
    if (map == null) {
      map=new CharacteristicTypeMap(source,characterizedBy);
      SHARED.put(characterizedBy,map);
    }
  }
  return map;
}

Fixed version (ground truth):
/** 
 * Creates a new map or return an existing map for the given attribute characteristics. <p>This method does not clone the   {@code characterizedBy} array. If that arrayis a user-provided argument, then cloning that array is caller responsibility.</p>
 * @param source           the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  characteristics of {@code source}. Should not be empty.
 * @return a map for this given characteristics.
 * @throws IllegalArgumentException if two characteristics have the same name.
 */
static CharacteristicTypeMap create(final AttributeType<?> source,final AttributeType<?>[] characterizedBy){
  CharacteristicTypeMap map;
synchronized (SHARED) {
    map=SHARED.get(characterizedBy);
    if (map == null) {
      map=new CharacteristicTypeMap(source,characterizedBy);
      SHARED.put(characterizedBy,map);
    }
  }
  return map;
}
Program: 91764
Project: 91764
Buggy source:
/** 
 * Invoked on serialization for saving the   {@link #characteristics} field.
 * @param out The output stream where to serialize this attribute type.
 * @throws IOException If an I/O error occurred while writing.
 */
private void writeObject(final ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeObject(characteristics != null ? characteristics.characterizedBy : null);
}

Fixed version (ground truth):
/** 
 * Invoked on serialization for saving the   {@link #characteristics} field.
 * @param out The output stream where to serialize this attribute type.
 * @throws IOException if an I/O error occurred while writing.
 */
private void writeObject(final ObjectOutputStream out) throws IOException {
  out.defaultWriteObject();
  out.writeObject(characteristics != null ? characteristics.characterizedBy : null);
}
Program: 91765
Project: 91765
Buggy source:
/** 
 * Returns any feature operation, any feature attribute type and any feature association role that carries characteristics of a feature type. The returned collection will include the properties inherited from the   {@linkplain #getSuperTypes() super-types} only if {@code includeSuperTypes}is   {@code true}.
 * @param includeSuperTypes {@code true} for including the properties inherited from the super-types,or  {@code false} for returning only the properties defined explicitely in this type.
 * @return feature operation, attribute type and association role that carries characteristics of thisfeature type (not including parent types).
 */
@Override public Collection<PropertyType> getProperties(final boolean includeSuperTypes){
  return includeSuperTypes ? allProperties : properties;
}

Fixed version (ground truth):
/** 
 * Returns any feature operation, any feature attribute type and any feature association role that carries characteristics of a feature type. The returned collection will include the properties inherited from the   {@linkplain #getSuperTypes() super-types} only if {@code includeSuperTypes}is   {@code true}.
 * @param includeSuperTypes  {@code true} for including the properties inherited from the super-types,or  {@code false} for returning only the properties defined explicitely in this type.
 * @return feature operation, attribute type and association role that carries characteristics of thisfeature type (not including parent types).
 */
@Override public Collection<PropertyType> getProperties(final boolean includeSuperTypes){
  return includeSuperTypes ? allProperties : properties;
}
Program: 91766
Project: 91766
Buggy source:
/** 
 * Not yet supported.
 * @return Currently never return.
 * @throws ParseException currently always thrown.
 */
@Override public Object parse(final CharSequence text,final ParsePosition pos) throws ParseException {
  throw new ParseException(Errors.getResources(displayLocale).getString(Errors.Keys.UnsupportedOperation_1,"String_Node_Str"),0);
}

Fixed version (ground truth):
/** 
 * Not yet supported.
 * @return currently never return.
 * @throws ParseException currently always thrown.
 */
@Override public Object parse(final CharSequence text,final ParsePosition pos) throws ParseException {
  throw new ParseException(Errors.getResources(displayLocale).getString(Errors.Keys.UnsupportedOperation_1,"String_Node_Str"),0);
}
Program: 91768
Project: 91768
Buggy source:
/** 
 * Appends a string representation of the "formula" used for computing the result.
 * @param buffer where to format the "formula".
 */
@Override void formatResultFormula(final Appendable buffer) throws IOException {
  buffer.append(referentName);
}

Fixed version (ground truth):
/** 
 * Appends a string representation of the "formula" used for computing the result.
 * @param buffer  where to format the "formula".
 */
@Override void formatResultFormula(final Appendable buffer) throws IOException {
  buffer.append(referentName);
}
Program: 91769
Project: 91769
Buggy source:
/** 
 * Returns the feature, or   {@code null} if none.
 * @return The feature (may be {@code null}).
 * @throws MultiValuedPropertyException if this association contains more than one value.
 */
@Override public Feature getValue(){
switch (values.size()) {
case 0:
    return null;
case 1:
  return values.get(0);
default :
throw new MultiValuedPropertyException(Resources.format(Resources.Keys.NotASingleton_1,getName()));
}
}

Fixed version (ground truth):
/** 
 * Returns the feature, or   {@code null} if none.
 * @return the feature (may be {@code null}).
 * @throws MultiValuedPropertyException if this association contains more than one value.
 */
@Override public Feature getValue(){
switch (values.size()) {
case 0:
    return null;
case 1:
  return values.get(0);
default :
throw new MultiValuedPropertyException(Resources.format(Resources.Keys.NotASingleton_1,getName()));
}
}
Program: 91770
Project: 91770
Buggy source:
/** 
 * Returns all features, or an empty collection if none. The returned collection is <cite>live</cite>: changes in the returned collection will be reflected immediately in this   {@code Association} instance, and conversely.
 * @return The features in a <cite>live</cite> collection.
 */
@Override @SuppressWarnings("String_Node_Str") public Collection<Feature> getValues(){
  return values;
}

Fixed version (ground truth):
/** 
 * Returns all features, or an empty collection if none. The returned collection is <cite>live</cite>: changes in the returned collection will be reflected immediately in this   {@code Association} instance, and conversely.
 * @return the features in a <cite>live</cite> collection.
 */
@Override @SuppressWarnings("String_Node_Str") public Collection<Feature> getValues(){
  return values;
}
Program: 91771
Project: 91771
Buggy source:
/** 
 * Sets the feature values. All previous values are replaced by the given collection.
 * @param newValues The new values.
 */
@Override public void setValues(final Collection<? extends Feature> newValues){
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("String_Node_Str",newValues);
    final FeatureType base=role.getValueType();
    values.clear();
    for (    final Feature value : newValues) {
      ensureValid(base,value.getType());
      values.add(value);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the feature values. All previous values are replaced by the given collection.
 * @param newValues  the new values.
 */
@Override public void setValues(final Collection<? extends Feature> newValues){
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("String_Node_Str",newValues);
    final FeatureType base=role.getValueType();
    values.clear();
    for (    final Feature value : newValues) {
      ensureValid(base,value.getType());
      values.add(value);
    }
  }
}
Program: 91772
Project: 91772
Buggy source:
/** 
 * Returns a hash code value for this association.
 * @return A hash code value.
 */
@Override public int hashCode(){
  return role.hashCode() + values.hashCode();
}

Fixed version (ground truth):
/** 
 * Returns a hash code value for this association.
 * @return a hash code value.
 */
@Override public int hashCode(){
  return role.hashCode() + values.hashCode();
}
Program: 91773
Project: 91773
Buggy source:
/** 
 * Sets the feature.
 * @param value The new value, or {@code null} for removing all values from this association.
 */
@Override public void setValue(final Feature value){
  values.clear();
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
    values.add(value);
  }
}

Fixed version (ground truth):
/** 
 * Sets the feature.
 * @param value  the new value, or {@code null} for removing all values from this association.
 */
@Override public void setValue(final Feature value){
  values.clear();
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
    values.add(value);
  }
}
Program: 91774
Project: 91774
Buggy source:
/** 
 * Returns a copy of this association. This implementation returns a <em>shallow</em> copy: the association   {@linkplain #getValues() values} are <strong>not</strong> cloned.
 * @return A clone of this association.
 * @throws CloneNotSupportedException if this association can not be cloned.
 */
@Override @SuppressWarnings("String_Node_Str") public MultiValuedAssociation clone() throws CloneNotSupportedException {
  final MultiValuedAssociation clone=(MultiValuedAssociation)super.clone();
  clone.values=(CheckedArrayList<Feature>)clone.values.clone();
  return clone;
}

Fixed version (ground truth):
/** 
 * Returns a copy of this association. This implementation returns a <em>shallow</em> copy: the association   {@linkplain #getValues() values} are <strong>not</strong> cloned.
 * @return a clone of this association.
 * @throws CloneNotSupportedException if this association can not be cloned.
 */
@Override @SuppressWarnings("String_Node_Str") public MultiValuedAssociation clone() throws CloneNotSupportedException {
  final MultiValuedAssociation clone=(MultiValuedAssociation)super.clone();
  clone.values=(CheckedArrayList<Feature>)clone.values.clone();
  return clone;
}
Program: 91775
Project: 91775
Buggy source:
/** 
 * Returns the associated feature.
 * @return The associated feature (may be {@code null}).
 */
@Override public Feature getValue(){
  return value;
}

Fixed version (ground truth):
/** 
 * Returns the associated feature.
 * @return the associated feature (may be {@code null}).
 */
@Override public Feature getValue(){
  return value;
}
Program: 91776
Project: 91776
Buggy source:
/** 
 * Creates a new association of the given role initialized to the given value.
 * @param role  Information about the association.
 * @param value The initial value (may be {@code null}).
 */
SingletonAssociation(final FeatureAssociationRole role,final Feature value){
}

Fixed version (ground truth):
/** 
 * Creates a new association of the given role initialized to the given value.
 * @param role   information about the association.
 * @param value  the initial value (may be {@code null}).
 */
SingletonAssociation(final FeatureAssociationRole role,final Feature value){
}
Program: 91777
Project: 91777
Buggy source:
/** 
 * Returns a hash code value for this association.
 * @return A hash code value.
 */
@Override public int hashCode(){
  return role.hashCode() + Objects.hashCode(value);
}

Fixed version (ground truth):
/** 
 * Returns a hash code value for this association.
 * @return a hash code value.
 */
@Override public int hashCode(){
  return role.hashCode() + Objects.hashCode(value);
}
Program: 91778
Project: 91778
Buggy source:
/** 
 * Sets the associated feature.
 * @param value The new value, or {@code null}.
 * @throws InvalidPropertyValueException If the given feature is not valid for this association.
 */
@Override public void setValue(final Feature value) throws InvalidPropertyValueException {
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
  }
  this.value=value;
}

Fixed version (ground truth):
/** 
 * Sets the associated feature.
 * @param value  the new value, or {@code null}.
 * @throws InvalidPropertyValueException if the given feature is not valid for this association.
 */
@Override public void setValue(final Feature value) throws InvalidPropertyValueException {
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
  }
  this.value=value;
}
Program: 91779
Project: 91779
Buggy source:
/** 
 * Appends a string representation of the "formula" used for computing the result.
 * @param buffer where to format the "formula".
 */
@Override void formatResultFormula(final Appendable buffer) throws IOException {
  if (prefix != null)   buffer.append(prefix);
  for (int i=0; i < attributeNames.length; i++) {
    if (i != 0)     buffer.append(delimiter);
    buffer.append(attributeNames[i]);
  }
  if (suffix != null)   buffer.append(suffix);
}

Fixed version (ground truth):
/** 
 * Appends a string representation of the "formula" used for computing the result.
 * @param buffer  where to format the "formula".
 */
@Override void formatResultFormula(final Appendable buffer) throws IOException {
  if (prefix != null)   buffer.append(prefix);
  for (int i=0; i < attributeNames.length; i++) {
    if (i != 0)     buffer.append(delimiter);
    buffer.append(attributeNames[i]);
  }
  if (suffix != null)   buffer.append(suffix);
}
Program: 91780
Project: 91780
Buggy source:
/** 
 * Provides temporal component of the extent of the referring object.
 * @return The temporal extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<TemporalExtent> getTemporalElements(){
  return temporalElements=nonNullCollection(temporalElements,TemporalExtent.class);
}

Fixed version (ground truth):
/** 
 * Provides temporal component of the extent of the referring object.
 * @return the temporal extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<TemporalExtent> getTemporalElements(){
  return temporalElements=nonNullCollection(temporalElements,TemporalExtent.class);
}
Program: 91781
Project: 91781
Buggy source:
/** 
 * Provides geographic component of the extent of the referring object
 * @return The geographic extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<GeographicExtent> getGeographicElements(){
  return geographicElements=nonNullCollection(geographicElements,GeographicExtent.class);
}

Fixed version (ground truth):
/** 
 * Provides geographic component of the extent of the referring object
 * @return the geographic extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<GeographicExtent> getGeographicElements(){
  return geographicElements=nonNullCollection(geographicElements,GeographicExtent.class);
}
Program: 91782
Project: 91782
Buggy source:
/** 
 * Sets geographic component of the extent of the referring object.
 * @param newValues The new geographic elements.
 */
public void setGeographicElements(final Collection<? extends GeographicExtent> newValues){
  geographicElements=writeCollection(newValues,geographicElements,GeographicExtent.class);
}

Fixed version (ground truth):
/** 
 * Sets geographic component of the extent of the referring object.
 * @param newValues  the new geographic elements.
 */
public void setGeographicElements(final Collection<? extends GeographicExtent> newValues){
  geographicElements=writeCollection(newValues,geographicElements,GeographicExtent.class);
}
Program: 91783
Project: 91783
Buggy source:
/** 
 * Returns a SIS metadata implementation with the values of the given arbitrary implementation. This method performs the first applicable action in the following choices: <ul> <li>If the given object is   {@code null}, then this method returns   {@code null}.</li> <li>Otherwise if the given object is already an instance of  {@code DefaultExtent}, then it is returned unchanged.</li> <li>Otherwise a new   {@code DefaultExtent} instance is created using the{@linkplain #DefaultExtent(Extent) copy constructor}and returned. Note that this is a <cite>shallow</cite> copy operation, since the other metadata contained in the given object are not recursively copied.</li> </ul>
 * @param object The object to get as a SIS implementation, or {@code null} if none.
 * @return A SIS implementation containing the values of the given object (may be thegiven object itself), or  {@code null} if the argument was null.
 */
public static DefaultExtent castOrCopy(final Extent object){
  if (object == null || object instanceof DefaultExtent) {
    return (DefaultExtent)object;
  }
  return new DefaultExtent(object);
}

Fixed version (ground truth):
/** 
 * Returns a SIS metadata implementation with the values of the given arbitrary implementation. This method performs the first applicable action in the following choices: <ul> <li>If the given object is   {@code null}, then this method returns   {@code null}.</li> <li>Otherwise if the given object is already an instance of  {@code DefaultExtent}, then it is returned unchanged.</li> <li>Otherwise a new   {@code DefaultExtent} instance is created using the{@linkplain #DefaultExtent(Extent) copy constructor}and returned. Note that this is a <cite>shallow</cite> copy operation, since the other metadata contained in the given object are not recursively copied.</li> </ul>
 * @param object  the object to get as a SIS implementation, or {@code null} if none.
 * @return a SIS implementation containing the values of the given object (may be thegiven object itself), or  {@code null} if the argument was null.
 */
public static DefaultExtent castOrCopy(final Extent object){
  if (object == null || object instanceof DefaultExtent) {
    return (DefaultExtent)object;
  }
  return new DefaultExtent(object);
}
Program: 91784
Project: 91784
Buggy source:
/** 
 * Constructs a new instance initialized with the values from the specified metadata object. This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the given object are not recursively copied.
 * @param object The metadata to copy values from, or {@code null} if none.
 * @see #castOrCopy(Extent)
 */
public DefaultExtent(final Extent object){
  super(object);
  if (object != null) {
    description=object.getDescription();
    geographicElements=copyCollection(object.getGeographicElements(),GeographicExtent.class);
    temporalElements=copyCollection(object.getTemporalElements(),TemporalExtent.class);
    verticalElements=copyCollection(object.getVerticalElements(),VerticalExtent.class);
  }
}

Fixed version (ground truth):
/** 
 * Constructs a new instance initialized with the values from the specified metadata object. This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the given object are not recursively copied.
 * @param object  the metadata to copy values from, or {@code null} if none.
 * @see #castOrCopy(Extent)
 */
public DefaultExtent(final Extent object){
  super(object);
  if (object != null) {
    description=object.getDescription();
    geographicElements=copyCollection(object.getGeographicElements(),GeographicExtent.class);
    temporalElements=copyCollection(object.getTemporalElements(),TemporalExtent.class);
    verticalElements=copyCollection(object.getVerticalElements(),VerticalExtent.class);
  }
}
Program: 91785
Project: 91785
Buggy source:
/** 
 * Adds geographic, vertical or temporal extents inferred from the given envelope. This method inspects the   {@linkplain Envelope#getCoordinateReferenceSystem() envelope CRS}and creates a   {@link GeographicBoundingBox},   {@link VerticalExtent} or {@link TemporalExtent}elements as needed. <p><b>Note:</b> this method is available only if the referencing module is on the classpath.</p>
 * @param envelope The envelope to use for inferring the additional extents.
 * @throws UnsupportedOperationException if the referencing module is not on the classpath.
 * @throws TransformException if a coordinate transformation was required and failed.
 * @see DefaultGeographicBoundingBox#setBounds(Envelope)
 * @see DefaultVerticalExtent#setBounds(Envelope)
 * @see DefaultTemporalExtent#setBounds(Envelope)
 */
public void addElements(final Envelope envelope) throws TransformException {
  checkWritePermission();
  ReferencingServices.getInstance().addElements(envelope,this);
}

Fixed version (ground truth):
/** 
 * Adds geographic, vertical or temporal extents inferred from the given envelope. This method inspects the   {@linkplain Envelope#getCoordinateReferenceSystem() envelope CRS}and creates a   {@link GeographicBoundingBox},   {@link VerticalExtent} or {@link TemporalExtent}elements as needed. <p><b>Note:</b> this method is available only if the referencing module is on the classpath.</p>
 * @param envelope  the envelope to use for inferring the additional extents.
 * @throws UnsupportedOperationException if the referencing module is not on the classpath.
 * @throws TransformException if a coordinate transformation was required and failed.
 * @see DefaultGeographicBoundingBox#setBounds(Envelope)
 * @see DefaultVerticalExtent#setBounds(Envelope)
 * @see DefaultTemporalExtent#setBounds(Envelope)
 */
public void addElements(final Envelope envelope) throws TransformException {
  checkWritePermission();
  ReferencingServices.getInstance().addElements(envelope,this);
}
Program: 91786
Project: 91786
Buggy source:
/** 
 * Provides vertical component of the extent of the referring object.
 * @return The vertical extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<VerticalExtent> getVerticalElements(){
  return verticalElements=nonNullCollection(verticalElements,VerticalExtent.class);
}

Fixed version (ground truth):
/** 
 * Provides vertical component of the extent of the referring object.
 * @return the vertical extent, or an empty set if none.
 */
@Override @XmlElement(name="String_Node_Str") public Collection<VerticalExtent> getVerticalElements(){
  return verticalElements=nonNullCollection(verticalElements,VerticalExtent.class);
}
Program: 91787
Project: 91787
Buggy source:
/** 
 * Sets temporal component of the extent of the referring object.
 * @param newValues The new temporal elements.
 */
public void setTemporalElements(final Collection<? extends TemporalExtent> newValues){
  temporalElements=writeCollection(newValues,temporalElements,TemporalExtent.class);
}

Fixed version (ground truth):
/** 
 * Sets temporal component of the extent of the referring object.
 * @param newValues  the new temporal elements.
 */
public void setTemporalElements(final Collection<? extends TemporalExtent> newValues){
  temporalElements=writeCollection(newValues,temporalElements,TemporalExtent.class);
}
Program: 91788
Project: 91788
Buggy source:
/** 
 * Sets the spatial and temporal extent for the referring object.
 * @param newValue The new description.
 */
public void setDescription(final InternationalString newValue){
  checkWritePermission();
  description=newValue;
}

Fixed version (ground truth):
/** 
 * Sets the spatial and temporal extent for the referring object.
 * @param newValue  the new description.
 */
public void setDescription(final InternationalString newValue){
  checkWritePermission();
  description=newValue;
}
Program: 91789
Project: 91789
Buggy source:
/** 
 * Returns the spatial and temporal extent for the referring object.
 * @return The spatial and temporal extent, or {@code null} in none.
 */
@Override @XmlElement(name="String_Node_Str") public InternationalString getDescription(){
  return description;
}

Fixed version (ground truth):
/** 
 * Returns the spatial and temporal extent for the referring object.
 * @return the spatial and temporal extent, or {@code null} in none.
 */
@Override @XmlElement(name="String_Node_Str") public InternationalString getDescription(){
  return description;
}
Program: 91790
Project: 91790
Buggy source:
/** 
 * Sets vertical component of the extent of the referring object.
 * @param newValues The new vertical elements.
 */
public void setVerticalElements(final Collection<? extends VerticalExtent> newValues){
  verticalElements=writeCollection(newValues,verticalElements,VerticalExtent.class);
}

Fixed version (ground truth):
/** 
 * Sets vertical component of the extent of the referring object.
 * @param newValues  the new vertical elements.
 */
public void setVerticalElements(final Collection<? extends VerticalExtent> newValues){
  verticalElements=writeCollection(newValues,verticalElements,VerticalExtent.class);
}
Program: 91792
Project: 91792
Buggy source:
/** 
 * Returns the geographic CRS on which the map projection is applied. This CRS defines the   {@linkplain #getDatum() datum} of this CRS and (at least implicitly)the  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source}of the   {@linkplain #getConversionFromBase() conversion from base}.
 * @return The base coordinate reference system, which must be geographic.
 */
@Override @XmlElement(name="String_Node_Str",required=true) public GeographicCRS getBaseCRS(){
  final Projection projection=super.getConversionFromBase();
  return (projection != null) ? projection.getSourceCRS() : null;
}

Fixed version (ground truth):
/** 
 * Returns the geographic CRS on which the map projection is applied. This CRS defines the   {@linkplain #getDatum() datum} of this CRS and (at least implicitly)the  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source}of the   {@linkplain #getConversionFromBase() conversion from base}.
 * @return the base coordinate reference system, which must be geographic.
 */
@Override @XmlElement(name="String_Node_Str",required=true) public GeographicCRS getBaseCRS(){
  final Projection projection=super.getConversionFromBase();
  return (projection != null) ? projection.getSourceCRS() : null;
}
Program: 91793
Project: 91793
Buggy source:
/** 
 * Returns a SIS coordinate reference system implementation with the same values than the given arbitrary implementation. If the given object is   {@code null}, then this method returns   {@code null}. Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
 * @param object The object to get as a SIS implementation, or {@code null} if none.
 * @return A SIS implementation containing the values of the given object (may be thegiven object itself), or  {@code null} if the argument was null.
 */
public static DefaultProjectedCRS castOrCopy(final ProjectedCRS object){
  return (object == null) || (object instanceof DefaultProjectedCRS) ? (DefaultProjectedCRS)object : new DefaultProjectedCRS(object);
}

Fixed version (ground truth):
/** 
 * Returns a SIS coordinate reference system implementation with the same values than the given arbitrary implementation. If the given object is   {@code null}, then this method returns   {@code null}. Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. Otherwise a new SIS implementation is created and initialized to the attribute values of the given object.
 * @param object  the object to get as a SIS implementation, or {@code null} if none.
 * @return a SIS implementation containing the values of the given object (may be thegiven object itself), or  {@code null} if the argument was null.
 */
public static DefaultProjectedCRS castOrCopy(final ProjectedCRS object){
  return (object == null) || (object instanceof DefaultProjectedCRS) ? (DefaultProjectedCRS)object : new DefaultProjectedCRS(object);
}
Program: 91794
Project: 91794
Buggy source:
/** 
 * Returns the map projection from the   {@linkplain #getBaseCRS() base CRS} to this CRS.In Apache SIS, the conversion source and target CRS are set to the following values: <ul> <li>The conversion  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source CRS} is the {@linkplain #getBaseCRS() base CRS} of {@code this} CRS.</li><li>The conversion  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getTargetCRS() target CRS} is {@code this} CRS.</ul> <div class="note"><b>Note:</b> This is different than ISO 19111, which allows source and target CRS to be  {@code null}.</div>
 * @return The map projection from base CRS to this CRS.
 */
@Override public Projection getConversionFromBase(){
  return super.getConversionFromBase();
}

Fixed version (ground truth):
/** 
 * Returns the map projection from the   {@linkplain #getBaseCRS() base CRS} to this CRS.In Apache SIS, the conversion source and target CRS are set to the following values: <ul> <li>The conversion  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getSourceCRS() source CRS} is the {@linkplain #getBaseCRS() base CRS} of {@code this} CRS.</li><li>The conversion  {@linkplain org.apache.sis.referencing.operation.DefaultConversion#getTargetCRS() target CRS} is {@code this} CRS.</ul> <div class="note"><b>Note:</b> This is different than ISO 19111, which allows source and target CRS to be  {@code null}.</div>
 * @return the map projection from base CRS to this CRS.
 */
@Override public Projection getConversionFromBase(){
  return super.getConversionFromBase();
}
Program: 91795
Project: 91795
Buggy source:
/** 
 * Returns the datum of the   {@linkplain #getBaseCRS() base CRS}.
 * @return The datum of the base CRS.
 */
@Override public GeodeticDatum getDatum(){
  return getBaseCRS().getDatum();
}

Fixed version (ground truth):
/** 
 * Returns the datum of the   {@linkplain #getBaseCRS() base CRS}.
 * @return the datum of the base CRS.
 */
@Override public GeodeticDatum getDatum(){
  return getBaseCRS().getDatum();
}
Program: 91796
Project: 91796
Buggy source:
/** 
 * Compares this coordinate reference system with the specified object for equality. In addition to the metadata documented in the  {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#equals(Object,ComparisonMode) parent class}, this method considers coordinate system axes of the   {@linkplain #getBaseCRS() base CRS} as metadata.This means that if the given  {@code ComparisonMode} is {@code IGNORE_METADATA} or {@code APPROXIMATIVE}, then axis order of the base geographic CRS are ignored (but <strong>not</strong> axis order of <strong>this</strong> projected CRS).
 * @param object The object to compare to {@code this}.
 * @param mode {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing only propertiesrelevant to coordinate transformations.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object object,final ComparisonMode mode){
  return super.equals(object,mode);
}

Fixed version (ground truth):
/** 
 * Compares this coordinate reference system with the specified object for equality. In addition to the metadata documented in the  {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#equals(Object,ComparisonMode) parent class}, this method considers coordinate system axes of the   {@linkplain #getBaseCRS() base CRS} as metadata.This means that if the given  {@code ComparisonMode} is {@code IGNORE_METADATA} or {@code APPROXIMATIVE}, then axis order of the base geographic CRS are ignored (but <strong>not</strong> axis order of <strong>this</strong> projected CRS).
 * @param object  the object to compare to {@code this}.
 * @param mode    {@link ComparisonMode#STRICT STRICT} for performing a strict comparison, or{@link ComparisonMode#IGNORE_METADATA IGNORE_METADATA} for comparing onlyproperties relevant to coordinate transformations.
 * @return {@code true} if both objects are equal.
 */
@Override public boolean equals(final Object object,final ComparisonMode mode){
  return super.equals(object,mode);
}
Program: 91798
Project: 91798
Buggy source:
/** 
 * Returns a message for unspecified data source. The message will depend on whether a JNDI context exists or not. This message can be used for constructing an exception when   {@link #getDataSource()} returned {@code null}.
 * @param locale The locale for the message to produce, or {@code null} for the default one.
 * @return Message for unspecified data source.
 */
public static String unspecified(final Locale locale){
  final short key;
  final String value;
  if (hasJNDI()) {
    key=Messages.Keys.JNDINotSpecified_1;
    value="String_Node_Str" + DATABASE;
  }
 else {
    key=Messages.Keys.DataDirectoryNotSpecified_1;
    value=DataDirectory.ENV;
  }
  return Messages.getResources(locale).getString(key,value);
}

Fixed version (ground truth):
/** 
 * Returns a message for unspecified data source. The message will depend on whether a JNDI context exists or not. This message can be used for constructing an exception when   {@link #getDataSource()} returned {@code null}.
 * @param locale  the locale for the message to produce, or {@code null} for the default one.
 * @return message for unspecified data source.
 */
public static String unspecified(final Locale locale){
  final short key;
  final String value;
  if (hasJNDI()) {
    key=Messages.Keys.JNDINotSpecified_1;
    value="String_Node_Str" + DATABASE;
  }
 else {
    key=Messages.Keys.DataDirectoryNotSpecified_1;
    value=DataDirectory.ENV;
  }
  return Messages.getResources(locale).getString(key,value);
}
Program: 91799
Project: 91799
Buggy source:
/** 
 * Invoked for populating an initially empty database.
 * @param connection Connection to the empty database.
 * @throws SQLException if an error occurred while populating the database.
 */
protected abstract void createSchema(Connection connection) throws SQLException ;

Fixed version (ground truth):
/** 
 * Invoked for populating an initially empty database.
 * @param connection  connection to the empty database.
 * @throws SQLException if an error occurred while populating the database.
 */
protected abstract void createSchema(Connection connection) throws SQLException ;
Program: 91800
Project: 91800
Buggy source:
/** 
 * Returns   {@code true} if the given exception is the one that we expect in successful shutdown of a Derby database.
 * @param e The exception thrown by Derby.
 * @return {@code true} if the exception indicates a successful shutdown.
 */
static boolean isSuccessfulShutdown(final SQLException e){
  final String state=e.getSQLState();
  return "String_Node_Str".equals(state) || "String_Node_Str".equals(state);
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if the given exception is the one that we expect in successful shutdown of a Derby database.
 * @param e  the exception thrown by Derby.
 * @return {@code true} if the exception indicates a successful shutdown.
 */
static boolean isSuccessfulShutdown(final SQLException e){
  final String state=e.getSQLState();
  return "String_Node_Str".equals(state) || "String_Node_Str".equals(state);
}
Program: 91801
Project: 91801
Buggy source:
/** 
 * Invoked when the data source associated to   {@code "jdbc/SpatialMetadata"} changed.This method clears the  {@link Initializer#source}, unregisters this listener and notifies other SIS modules.
 * @param event Ignored. May be null.
 */
@Override public void objectChanged(NamingEvent event){
  try {
synchronized (Initializer.class) {
      source=null;
      Shutdown.unregister(this);
      context.removeNamingListener(this);
    }
  }
 catch (  NamingException e) {
    Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),Listener.class,"String_Node_Str",e);
  }
  for (  Initializer init : DefaultFactories.createServiceLoader(Initializer.class)) {
    init.dataSourceChanged();
  }
}

Fixed version (ground truth):
/** 
 * Invoked when the data source associated to   {@code "jdbc/SpatialMetadata"} changed.This method clears the  {@link Initializer#source}, unregisters this listener and notifies other SIS modules.
 * @param event  ignored. Can be null.
 */
@Override public void objectChanged(NamingEvent event){
  try {
synchronized (Initializer.class) {
      source=null;
      connected=false;
      Shutdown.unregister(this);
      context.removeNamingListener(this);
    }
  }
 catch (  NamingException e) {
    Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM),Listener.class,"String_Node_Str",e);
  }
  for (  Initializer init : DefaultFactories.createServiceLoader(Initializer.class)) {
    init.dataSourceChanged();
  }
}
Program: 91802
Project: 91802
Buggy source:
/** 
 * Invoked when the JVM is shutting down, or when the Servlet or OSGi bundle is uninstalled. This method shutdowns the Derby database.
 * @throws ReflectiveOperationException if an error occurred whilesetting the shutdown property on the Derby data source.
 */
private static synchronized void shutdown() throws ReflectiveOperationException {
  final DataSource ds=source;
  if (ds != null) {
    source=null;
    ds.getClass().getMethod("String_Node_Str",String.class).invoke(ds,"String_Node_Str");
    try {
      ds.getConnection().close();
    }
 catch (    SQLException e) {
      final LogRecord record=new LogRecord(Level.FINE,e.getLocalizedMessage());
      if (!isSuccessfulShutdown(e)) {
        record.setLevel(Level.WARNING);
        record.setThrown(e);
      }
      record.setLoggerName(Loggers.SQL);
      Logging.log(Initializer.class,"String_Node_Str",record);
    }
  }
}

Fixed version (ground truth):
/** 
 * Invoked when the JVM is shutting down, or when the Servlet or OSGi bundle is uninstalled. This method shutdowns the Derby database.
 * @throws ReflectiveOperationException if an error occurred whilesetting the shutdown property on the Derby data source.
 */
private static synchronized void shutdown() throws ReflectiveOperationException {
  final DataSource ds=source;
  if (ds != null) {
    source=null;
    connected=false;
    ds.getClass().getMethod("String_Node_Str",String.class).invoke(ds,"String_Node_Str");
    try {
      ds.getConnection().close();
    }
 catch (    SQLException e) {
      final LogRecord record=new LogRecord(Level.FINE,e.getLocalizedMessage());
      if (!isSuccessfulShutdown(e)) {
        record.setLevel(Level.WARNING);
        record.setThrown(e);
      }
      record.setLoggerName(Loggers.SQL);
      Logging.log(Initializer.class,"String_Node_Str",record);
    }
  }
}
Program: 91803
Project: 91803
Buggy source:
/** 
 * Returns a string like the given string but with all characters that are not letter or digit replaced by the wildcard % character. <p>This method avoid to put a % symbol as the first character, since it prevent some databases to use their index.</p>
 * @param identifier The identifier to get as a SQL LIKE pattern.
 * @return The given identifier as a SQL LIKE pattern.
 */
public static String toLikePattern(final String identifier){
  boolean isLetterOrDigit=false;
  final StringBuilder buffer=new StringBuilder(identifier.length());
  for (int c, i=0; i < identifier.length(); i+=Character.charCount(c)) {
    c=identifier.codePointAt(i);
    if (Character.isLetterOrDigit(c)) {
      buffer.appendCodePoint(c);
      isLetterOrDigit=true;
    }
 else     if (isLetterOrDigit) {
      isLetterOrDigit=false;
      buffer.append('%');
    }
 else {
      final int p=buffer.length();
      if (p == 0 || buffer.charAt(p - 1) != '%') {
        buffer.appendCodePoint(c != '%' ? c : '_');
      }
    }
  }
  return buffer.toString();
}

Fixed version (ground truth):
/** 
 * Returns a string like the given string but with all characters that are not letter or digit replaced by the wildcard % character. <p>This method avoid to put a % symbol as the first character, since it prevent some databases to use their index.</p>
 * @param identifier the identifier to get as a SQL LIKE pattern.
 * @return the given identifier as a SQL LIKE pattern.
 */
public static String toLikePattern(final String identifier){
  boolean isLetterOrDigit=false;
  final StringBuilder buffer=new StringBuilder(identifier.length());
  for (int c, i=0; i < identifier.length(); i+=Character.charCount(c)) {
    c=identifier.codePointAt(i);
    if (Character.isLetterOrDigit(c)) {
      buffer.appendCodePoint(c);
      isLetterOrDigit=true;
    }
 else     if (isLetterOrDigit) {
      isLetterOrDigit=false;
      buffer.append('%');
    }
 else {
      final int p=buffer.length();
      if (p == 0 || buffer.charAt(p - 1) != '%') {
        buffer.appendCodePoint(c != '%' ? c : '_');
      }
    }
  }
  return buffer.toString();
}
Program: 91804
Project: 91804
Buggy source:
/** 
 * Returns a simplified form of the URL (truncated before the first   {@code ?} or {@code ;} character),for logging or informative purpose only.
 * @param metadata The metadata of the database.
 * @return A simplified version of database URL.
 * @throws SQLException if an error occurred while fetching the URL.
 */
public static String getSimplifiedURL(final DatabaseMetaData metadata) throws SQLException {
  String url=metadata.getURL();
  int s1=url.indexOf('?');
  if (s1 < 0)   s1=url.length();
  int s2=url.indexOf(';');
  if (s2 < 0)   s2=url.length();
  return url.substring(0,Math.min(s1,s2));
}

Fixed version (ground truth):
/** 
 * Returns a simplified form of the URL (truncated before the first   {@code ?} or {@code ;} character),for logging or informative purpose only.
 * @param metadata  the metadata of the database.
 * @return a simplified version of database URL.
 * @throws SQLException if an error occurred while fetching the URL.
 */
public static String getSimplifiedURL(final DatabaseMetaData metadata) throws SQLException {
  String url=metadata.getURL();
  int s1=url.indexOf('?');
  if (s1 < 0)   s1=url.length();
  int s2=url.indexOf(';');
  if (s2 < 0)   s2=url.length();
  return url.substring(0,Math.min(s1,s2));
}
Program: 91805
Project: 91805
Buggy source:
/** 
 * Workaround for what seems to be a Derby 10.11 bug, which seems to behave as if the LIKE pattern had a trailing % wildcard. This can be verified with the following query on the EPSG database:  {@preformat sqlSELECT COORD_REF_SYS_CODE, COORD_REF_SYS_NAME FROM EPSG."Coordinate Reference System" WHERE COORD_REF_SYS_NAME LIKE 'NTF%Paris%Lambert%zone%I'}which returns "NTF (Paris) / Lambert zone I" as expected but also zones II and III.
 * @param expected The string to search.
 * @param actual The string found in the database.
 * @return {@code true} if the given string can be accepted.
 */
@Workaround(library="String_Node_Str",version="String_Node_Str") public static boolean filterFalsePositive(final String expected,final String actual){
  return CharSequences.equalsFiltered(expected,actual,Characters.Filter.LETTERS_AND_DIGITS,false);
}

Fixed version (ground truth):
/** 
 * Workaround for what seems to be a Derby 10.11 bug, which seems to behave as if the LIKE pattern had a trailing % wildcard. This can be verified with the following query on the EPSG database:  {@preformat sqlSELECT COORD_REF_SYS_CODE, COORD_REF_SYS_NAME FROM EPSG."Coordinate Reference System" WHERE COORD_REF_SYS_NAME LIKE 'NTF%Paris%Lambert%zone%I'}which returns "NTF (Paris) / Lambert zone I" as expected but also zones II and III.
 * @param expected  the string to search.
 * @param actual    the string found in the database.
 * @return {@code true} if the given string can be accepted.
 */
@Workaround(library="String_Node_Str",version="String_Node_Str") public static boolean filterFalsePositive(final String expected,final String actual){
  return CharSequences.equalsFiltered(expected,actual,Characters.Filter.LETTERS_AND_DIGITS,false);
}
Program: 91807
Project: 91807
Buggy source:
/** 
 * Returns a message for unspecified data source. The message will depend on whether a JNDI context exists or not. This message can be used for constructing an exception when   {@link #getDataSource()} returned {@code null}.
 * @param locale The locale for the message to produce, or {@code null} for the default one.
 * @return Message for unspecified data source.
 */
public static String unspecified(final Locale locale){
  final short key;
  final String value;
  if (hasJNDI()) {
    key=Messages.Keys.JNDINotSpecified_1;
    value="String_Node_Str" + DATABASE;
  }
 else {
    key=Messages.Keys.DataDirectoryNotSpecified_1;
    value=DataDirectory.ENV;
  }
  return Messages.getResources(locale).getString(key,value);
}

Fixed version (ground truth):
/** 
 * Returns a message for unspecified data source. The message will depend on whether a JNDI context exists or not. This message can be used for constructing an exception when   {@link #getDataSource()} returned {@code null}.
 * @param locale  the locale for the message to produce, or {@code null} for the default one.
 * @return message for unspecified data source.
 */
public static String unspecified(final Locale locale){
  final short key;
  final String value;
  if (hasJNDI()) {
    key=Messages.Keys.JNDINotSpecified_1;
    value="String_Node_Str" + DATABASE;
  }
 else {
    key=Messages.Keys.DataDirectoryNotSpecified_1;
    value=DataDirectory.ENV;
  }
  return Messages.getResources(locale).getString(key,value);
}
Program: 91808
Project: 91808
Buggy source:
/** 
 * Invoked for populating an initially empty database.
 * @param connection Connection to the empty database.
 * @throws SQLException if an error occurred while populating the database.
 */
protected abstract void createSchema(Connection connection) throws SQLException ;

Fixed version (ground truth):
/** 
 * Invoked for populating an initially empty database.
 * @param connection  connection to the empty database.
 * @throws SQLException if an error occurred while populating the database.
 */
protected abstract void createSchema(Connection connection) throws SQLException ;
Program: 91809
Project: 91809
Buggy source:
/** 
 * Returns   {@code true} if the given exception is the one that we expect in successful shutdown of a Derby database.
 * @param e The exception thrown by Derby.
 * @return {@code true} if the exception indicates a successful shutdown.
 */
static boolean isSuccessfulShutdown(final SQLException e){
  final String state=e.getSQLState();
  return "String_Node_Str".equals(state) || "String_Node_Str".equals(state);
}

Fixed version (ground truth):
/** 
 * Returns   {@code true} if the given exception is the one that we expect in successful shutdown of a Derby database.
 * @param e  the exception thrown by Derby.
 * @return {@code true} if the exception indicates a successful shutdown.
 */
static boolean isSuccessfulShutdown(final SQLException e){
  final String state=e.getSQLState();
  return "String_Node_Str".equals(state) || "String_Node_Str".equals(state);
}