nus-yam/ex-repair huggingface dataset:
Program: 91710
Project: 91710
Buggy source:
/** 
 * Verifies the regular expressions used by the script runner. This method tests the values returned by   {@link ScriptRunner#isSupported(StringBuilder)}
 * @param sr  the script runner to use for testing regular expressions.
 */
@TestStep public static void testRegularExpressions(final ScriptRunner sr){
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertTrue(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
}

Fixed version (ground truth):
/** 
 * Verifies the regular expressions used by the script runner. This method tests the values returned by   {@link ScriptRunner#isSupported(CharSequence)}
 * @param sr  the script runner to use for testing regular expressions.
 */
@TestStep public static void testRegularExpressions(final ScriptRunner sr){
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertTrue(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
  assertFalse(sr.isSupported("String_Node_Str"));
}
Program: 91711
Project: 91711
Buggy source:
/** 
 * Tests   {@link Element#pullElement(String)}. This implies testing   {@code Element} nesting.
 * @throws ParseException if an error occurred during the parsing.
 */
@Test @DependsOnMethod("String_Node_Str") public void testPullElement() throws ParseException {
  Element element=parse("String_Node_Str");
  assertEquals("String_Node_Str","String_Node_Str",element.keyword);
  assertEquals("String_Node_Str","String_Node_Str",element.pullString("String_Node_Str"));
  Element inner=element.pullElement(AbstractParser.MANDATORY,"String_Node_Str");
  assertEquals("String_Node_Str","String_Node_Str",inner.keyword);
  assertEquals("String_Node_Str",TestUtilities.date("String_Node_Str"),inner.pullDate("String_Node_Str"));
  inner.close(null);
  element.close(null);
}

Fixed version (ground truth):
/** 
 * Tests   {@link Element#pullElement(int,String)}. This implies testing   {@code Element} nesting.
 * @throws ParseException if an error occurred during the parsing.
 */
@Test @DependsOnMethod("String_Node_Str") public void testPullElement() throws ParseException {
  Element element=parse("String_Node_Str");
  assertEquals("String_Node_Str","String_Node_Str",element.keyword);
  assertEquals("String_Node_Str","String_Node_Str",element.pullString("String_Node_Str"));
  Element inner=element.pullElement(AbstractParser.MANDATORY,"String_Node_Str");
  assertEquals("String_Node_Str","String_Node_Str",inner.keyword);
  assertEquals("String_Node_Str",TestUtilities.date("String_Node_Str"),inner.pullDate("String_Node_Str"));
  inner.close(null);
  element.close(null);
}
Program: 91712
Project: 91712
Buggy source:
/** 
 * Tests   {@link Element#close()}.
 * @throws ParseException if an error occurred during the parsing.
 */
@Test public void testClose() throws ParseException {
  final Element element=parse("String_Node_Str");
  try {
    element.close(null);
    fail("String_Node_Str");
  }
 catch (  ParseException e) {
    assertEquals("String_Node_Str",e.getLocalizedMessage());
  }
}

Fixed version (ground truth):
/** 
 * Tests   {@link Element#close(Map)}.
 * @throws ParseException if an error occurred during the parsing.
 */
@Test public void testClose() throws ParseException {
  final Element element=parse("String_Node_Str");
  try {
    element.close(null);
    fail("String_Node_Str");
  }
 catch (  ParseException e) {
    assertEquals("String_Node_Str",e.getLocalizedMessage());
  }
}
Program: 91713
Project: 91713
Buggy source:
/** 
 * Tests (indirectly)   {@link Formatter#append(CodeList)}.
 */
@Test public void testAppendCodeList(){
  assertWktEquals(Convention.WKT2,"String_Node_Str",AxisDirection.NORTH_EAST);
  assertWktEquals(Convention.WKT1,"String_Node_Str",AxisDirection.NORTH_EAST);
}

Fixed version (ground truth):
/** 
 * Tests (indirectly)   {@link Formatter#append(ControlledVocabulary)}.
 */
@Test public void testAppendCodeList(){
  assertWktEquals(Convention.WKT2,"String_Node_Str",AxisDirection.NORTH_EAST);
  assertWktEquals(Convention.WKT1,"String_Node_Str",AxisDirection.NORTH_EAST);
}
Program: 91714
Project: 91714
Buggy source:
/** 
 * Tests (indirectly)   {@link Formatter#quote(String)}.
 */
@Test public void testQuote(){
  assertWktEquals(Convention.WKT2,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.INTERNAL,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.WKT2,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.INTERNAL,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Tests (indirectly)   {@link Formatter#quote(String,ElementKind)}.
 */
@Test public void testQuote(){
  assertWktEquals(Convention.WKT2,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.INTERNAL,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.WKT2,"String_Node_Str","String_Node_Str");
  assertWktEquals(Convention.INTERNAL,"String_Node_Str","String_Node_Str");
}
Program: 91715
Project: 91715
Buggy source:
/** 
 * Tests   {@link MetadataStandard#getAccessor(Class,boolean)}.
 */
@Test @DependsOnMethod("String_Node_Str") public void testGetAccessor(){
  standard=MetadataStandard.ISO_19115;
  assertEquals("String_Node_Str",Citation.class,getAccessor(DefaultCitation.class,true));
  assertEquals("String_Node_Str",Completeness.class,getAccessor(AbstractCompleteness.class,true));
  assertNull("String_Node_Str",getAccessor(SimpleIdentifiedObject.class,false));
  standard=MetadataStandard.ISO_19111;
  assertEquals("String_Node_Str",Citation.class,getAccessor(DefaultCitation.class,true));
  assertEquals("String_Node_Str",Completeness.class,getAccessor(AbstractCompleteness.class,true));
  assertEquals("String_Node_Str",IdentifiedObject.class,getAccessor(SimpleIdentifiedObject.class,true));
  testGetInterface();
}

Fixed version (ground truth):
/** 
 * Tests   {@link MetadataStandard#getAccessor(CacheKey,boolean)}.
 */
@Test @DependsOnMethod("String_Node_Str") public void testGetAccessor(){
  standard=MetadataStandard.ISO_19115;
  assertEquals("String_Node_Str",Citation.class,getAccessor(DefaultCitation.class,true));
  assertEquals("String_Node_Str",Completeness.class,getAccessor(AbstractCompleteness.class,true));
  assertNull("String_Node_Str",getAccessor(SimpleIdentifiedObject.class,false));
  standard=MetadataStandard.ISO_19111;
  assertEquals("String_Node_Str",Citation.class,getAccessor(DefaultCitation.class,true));
  assertEquals("String_Node_Str",Completeness.class,getAccessor(AbstractCompleteness.class,true));
  assertEquals("String_Node_Str",IdentifiedObject.class,getAccessor(SimpleIdentifiedObject.class,true));
  testGetInterface();
}
Program: 91716
Project: 91716
Buggy source:
/** 
 * Tests the   {@link PropertyAccessor#get(int,Object)} method on the {@link HardCodedCitations#ISO} constant.The metadata object read by this test is: {@preformat textDefaultCitation   ├─Title…………………………………… International Organization for Standardization   ├─Alternate title………… ISO 19111   ├─Identifier   │   ├─Code…………………………… 19111   │   └─Code space…………… ISO   └─Presentation form…… Document digital}
 */
@Test @DependsOnMethod("String_Node_Str") public void testGet(){
  final DefaultCitation instance=HardCodedCitations.ISO_19111;
  final PropertyAccessor accessor=createPropertyAccessor();
  final Object title=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertInstanceOf("String_Node_Str",InternationalString.class,title);
  assertEquals("String_Node_Str","String_Node_Str",title.toString());
  final Object alternateTitles=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertInstanceOf("String_Node_Str",Collection.class,alternateTitles);
  assertEquals("String_Node_Str","String_Node_Str",getSingleton((Collection<?>)alternateTitles).toString());
  final Object identifiers=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertEquals("String_Node_Str",getSingletonCode(identifiers));
}

Fixed version (ground truth):
/** 
 * Tests the   {@link PropertyAccessor#get(int,Object)} method on the {@link HardCodedCitations#ISO_19111} constant.The metadata object read by this test is: {@preformat textDefaultCitation   ├─Title…………………………………… International Organization for Standardization   ├─Alternate title………… ISO 19111   ├─Identifier   │   ├─Code…………………………… 19111   │   └─Code space…………… ISO   └─Presentation form…… Document digital}
 */
@Test @DependsOnMethod("String_Node_Str") public void testGet(){
  final DefaultCitation instance=HardCodedCitations.ISO_19111;
  final PropertyAccessor accessor=createPropertyAccessor();
  final Object title=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertInstanceOf("String_Node_Str",InternationalString.class,title);
  assertEquals("String_Node_Str","String_Node_Str",title.toString());
  final Object alternateTitles=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertInstanceOf("String_Node_Str",Collection.class,alternateTitles);
  assertEquals("String_Node_Str","String_Node_Str",getSingleton((Collection<?>)alternateTitles).toString());
  final Object identifiers=accessor.get(accessor.indexOf("String_Node_Str",true),instance);
  assertEquals("String_Node_Str",getSingletonCode(identifiers));
}
Program: 91717
Project: 91717
Buggy source:
/** 
 * Tests   {@link TreeNode#getElementType()} on a metadata with a hierarchy.
 */
@Test @DependsOnMethod("String_Node_Str") public void testGetElementType(){
  final DefaultCitation citation=metadataWithHierarchy();
  assertColumnContentEquals(create(citation,Citation.class,ValueExistencePolicy.NON_EMPTY),TableColumn.TYPE,Citation.class,InternationalString.class,InternationalString.class,InternationalString.class,InternationalString.class,Responsibility.class,Party.class,InternationalString.class,Role.class,Responsibility.class,Party.class,InternationalString.class,Contact.class,Address.class,String.class,Role.class,PresentationForm.class,PresentationForm.class,InternationalString.class);
}

Fixed version (ground truth):
/** 
 * Tests getting the value of   {@link TableColumn#TYPE} on a metadata with a hierarchy.
 */
@Test @DependsOnMethod("String_Node_Str") public void testGetElementType(){
  final DefaultCitation citation=metadataWithHierarchy();
  assertColumnContentEquals(create(citation,Citation.class,ValueExistencePolicy.NON_EMPTY),TableColumn.TYPE,Citation.class,InternationalString.class,InternationalString.class,InternationalString.class,InternationalString.class,Responsibility.class,Party.class,InternationalString.class,Role.class,Responsibility.class,Party.class,InternationalString.class,Contact.class,Address.class,String.class,Role.class,PresentationForm.class,PresentationForm.class,InternationalString.class);
}
Program: 91720
Project: 91720
Buggy source:
/** 
 * Verifies that   {@link Zoner#isNorway(double)} and {@link Zoner#isSvalbard(double)}are consistent with the latitude bands.
 */
@Test @DependsOnMethod("String_Node_Str") public void verifyZonerConsistency(){
  for (double φ=TransverseMercator.Zoner.SOUTH_BOUNDS; φ < TransverseMercator.Zoner.NORTH_BOUNDS; φ++) {
    final String latitude=String.valueOf(φ);
    final char band=MilitaryGridReferenceSystem.Encoder.latitudeBand(φ);
    assertTrue(latitude,band >= 'C' && band <= 'X');
    assertEquals(latitude,band == 'V',TransverseMercator.Zoner.isNorway(φ));
    assertEquals(latitude,band == 'X',TransverseMercator.Zoner.isSvalbard(φ));
  }
}

Fixed version (ground truth):
/** 
 * Verifies that   {@link TransverseMercator.Zoner#isNorway(double)} and{@link TransverseMercator.Zoner#isSvalbard(double)} are consistent with the latitude bands.
 */
@Test @DependsOnMethod("String_Node_Str") public void verifyZonerConsistency(){
  for (double φ=TransverseMercator.Zoner.SOUTH_BOUNDS; φ < TransverseMercator.Zoner.NORTH_BOUNDS; φ++) {
    final String latitude=String.valueOf(φ);
    final char band=MilitaryGridReferenceSystem.Encoder.latitudeBand(φ);
    assertTrue(latitude,band >= 'C' && band <= 'X');
    assertEquals(latitude,band == 'V',TransverseMercator.Zoner.isNorway(φ));
    assertEquals(latitude,band == 'X',TransverseMercator.Zoner.isSvalbard(φ));
  }
}
Program: 91723
Project: 91723
Buggy source:
/** 
 * Implementation of   {@link #tryAdvance(Consumer)} and {@link #forEachRemaining(Consumer)}.
 */
private boolean advance(final Consumer<? super String> action,final boolean all){
  final int digits=digits();
  final String separator=getSeparator();
  if (normalized == null) {
    normalized=new DirectPosition2D();
  }
  boolean found=false;
  try {
    do {
      cell.setRect(gridX,gridY,step,step);
      if (areaOfInterest.intersects(Shapes2D.transform(gridToAOI,cell,cell))) {
        int x=gridX;
        int y=gridY;
        normalized.setOrdinate(0,x);
        normalized.setOrdinate(1,y);
        final String ref=encoder.encode(this,normalized,false,separator,digits);
        if (ref != null) {
          action.accept(ref);
          found=true;
        }
      }
      if ((gridX+=step) >= xEnd) {
        gridX=xStart;
        if (encoder.crsZone >= 0) {
          if ((gridY+=step) >= yEnd)           break;
        }
 else {
          if ((gridY-=step) <= yEnd)           break;
        }
      }
    }
 while (all || !found);
  }
 catch (  FactoryException|TransformException e) {
    throw (ArithmeticException)new ArithmeticException(Errors.format(Errors.Keys.OutsideDomainOfValidity)).initCause(e);
  }
  return found;
}

Fixed version (ground truth):
/** 
 * Implementation of   {@link #tryAdvance(Consumer)} and {@link #forEachRemaining(Consumer)}. The   {@code all} argument specifies whether this method is invoked for a single element or for all remaining ones.
 */
private boolean advance(final Consumer<? super String> action,final boolean all){
  final int digits=digits();
  final String separator=getSeparator();
  if (normalized == null) {
    normalized=new DirectPosition2D();
  }
  boolean found=false;
  try {
    do {
      cell.setRect(gridX,gridY,step,step);
      if (areaOfInterest.intersects(Shapes2D.transform(gridToAOI,cell,cell))) {
        int x=gridX;
        if (x < xCenter) {
          x+=step - 1;
        }
        normalized.setOrdinate(0,x);
        normalized.setOrdinate(1,gridY);
        final String ref=encoder.encode(this,normalized,false,separator,digits);
        if (ref != null) {
          action.accept(ref);
          found=true;
        }
      }
 else       if (optimize) {
        if (gridX < xCenter) {
          xStart=gridX + step;
        }
 else {
          xEnd=gridX;
        }
      }
      if ((gridX+=step) >= xEnd) {
        gridX=xStart;
        if (!downward) {
          if ((gridY+=step) >= yEnd)           break;
        }
 else {
          if ((gridY-=step) <= yEnd)           break;
        }
      }
    }
 while (all || !found);
  }
 catch (  FactoryException|TransformException e) {
    throw (ArithmeticException)new ArithmeticException(Errors.format(Errors.Keys.OutsideDomainOfValidity)).initCause(e);
  }
  return found;
}
Program: 91727
Project: 91727
Buggy source:
/** 
 * Performs the given action for each remaining MGRS codes.
 */
@Override public void forEachRemaining(final Consumer<? super String> action){
  advance(action,true);
}

Fixed version (ground truth):
/** 
 * Performs the given action for each remaining MGRS codes.
 */
@Override public void forEachRemaining(final Consumer<? super String> action){
  advance(action,true);
  if (pending != null) {
    action.accept(pending);
    pending=null;
  }
}
Program: 91728
Project: 91728
Buggy source:
/** 
 * If this iterator is backed by only one worker iterator, returns that worker iterator. Otherwise returns   {@code this}. This method should be invoked after construction.
 */
final Spliterator<String> simplify(){
  return (iterators.length == 1) ? iterators[0] : this;
}

Fixed version (ground truth):
/** 
 * If this iterator is backed by only one worker iterator, returns that worker iterator. Otherwise returns   {@code this}. This method should be invoked after construction.
 */
final Spliterator<String> simplify(){
  return (upper - index == 1) ? iterators[index] : this;
}
Program: 91729
Project: 91729
Buggy source:
/** 
 * Adds all locations in the given area of interest.
 * @param coder           the encoder to use for computing locations and their envelopes.
 * @param areaOfInterest  the geographic or projected area where to get locations.
 * @throws FactoryException if a transformation to the display CRS can not be obtained.
 * @throws TransformException if an error occurred while transforming an envelope.
 */
public void addLocations(final MilitaryGridReferenceSystem.Coder coder,final Envelope areaOfInterest) throws FactoryException, TransformException {
  final Iterator<String> it=coder.encode(areaOfInterest);
  while (it.hasNext()) {
    final String code=it.next();
    addLocation(code,coder.decode(code));
  }
}

Fixed version (ground truth):
/** 
 * Adds all locations in the given area of interest.
 * @param coder           the encoder to use for computing locations and their envelopes.
 * @param areaOfInterest  the geographic or projected area where to get locations.
 * @throws FactoryException if a transformation to the display CRS can not be obtained.
 * @throws TransformException if an error occurred while transforming an envelope.
 */
public void addLocations(final MilitaryGridReferenceSystem.Coder coder,final Envelope areaOfInterest) throws FactoryException, TransformException {
  final Iterator<String> it=coder.encode(areaOfInterest);
  while (it.hasNext()) {
    final String code=it.next();
    addLocation(code,coder.decode(code));
    System.out.print("String_Node_Str" + code + "String_Node_Str");
  }
  envelope=((MathTransform2D)CRS.findOperation(areaOfInterest.getCoordinateReferenceSystem(),displayCRS,null).getMathTransform()).createTransformedShape(new IntervalRectangle(areaOfInterest));
}
Program: 91730
Project: 91730
Buggy source:
/** 
 * Creates a new, initially empty, viewer. Locations must be added by calls to   {@code addLocation(…)} methodsbefore the widget can be show.
 * @param displayCRS  the coordinate reference system to use for displaying the location shapes.
 */
public LocationViewer(final CoordinateReferenceSystem displayCRS){
  this.displayCRS=displayCRS;
  this.locations=new LinkedHashMap<>();
  setBackground(Color.BLACK);
}

Fixed version (ground truth):
/** 
 * Creates a new, initially empty, viewer. Locations must be added by calls to   {@code addLocation(…)} methodsbefore the widget can be show.
 * @param displayCRS  the coordinate reference system to use for displaying the location shapes.
 */
public LocationViewer(final SingleCRS displayCRS){
  this.displayCRS=displayCRS;
  this.locations=new LinkedHashMap<>();
  setBackground(Color.BLACK);
}
Program: 91731
Project: 91731
Buggy source:
/** 
 * Shows all locations in the given area of interest.
 * @param coder           the encoder to use for computing locations and their envelopes.
 * @param areaOfInterest  the geographic or projected area where to get locations.
 * @param displayCRS      the CRS to use for displaying the location shapes, or {@code null} for the envelope CRS.
 * @throws FactoryException if a transformation to the display CRS can not be obtained.
 * @throws TransformException if an error occurred while transforming an envelope.
 */
public static void show(final MilitaryGridReferenceSystem.Coder coder,final Envelope areaOfInterest,CoordinateReferenceSystem displayCRS) throws FactoryException, TransformException {
  if (displayCRS == null) {
    displayCRS=areaOfInterest.getCoordinateReferenceSystem();
  }
  final LocationViewer viewer=new LocationViewer(displayCRS);
  viewer.addLocations(coder,areaOfInterest);
  final JFrame frame=new JFrame("String_Node_Str");
  frame.getContentPane().add(viewer);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(600,600);
  frame.setVisible(true);
}

Fixed version (ground truth):
/** 
 * Shows all locations in the given area of interest.
 * @param coder           the encoder to use for computing locations and their envelopes.
 * @param areaOfInterest  the geographic or projected area where to get locations.
 * @param displayCRS      the CRS to use for displaying the location shapes, or {@code null} for the envelope CRS.
 * @throws FactoryException if a transformation to the display CRS can not be obtained.
 * @throws TransformException if an error occurred while transforming an envelope.
 */
public static void show(final MilitaryGridReferenceSystem.Coder coder,final Envelope areaOfInterest,SingleCRS displayCRS) throws FactoryException, TransformException {
  if (displayCRS == null) {
    displayCRS=CRS.getHorizontalComponent(areaOfInterest.getCoordinateReferenceSystem());
  }
  final LocationViewer viewer=new LocationViewer(displayCRS);
  viewer.addLocations(coder,areaOfInterest);
  final JFrame frame=new JFrame("String_Node_Str");
  frame.getContentPane().add(viewer);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(600,600);
  frame.setVisible(true);
}
Program: 91732
Project: 91732
Buggy source:
/** 
 * Invoked by Swing for painting this widget.
 * @param g  the graphic context where to paint.
 */
@Override protected void paintComponent(final Graphics g){
  super.paintComponent(g);
  final Graphics2D gr=(Graphics2D)g;
  final AffineTransform oldTr=gr.getTransform();
  final AffineTransform tr=AffineTransform.getScaleInstance(getWidth() / bounds.getWidth(),-getHeight() / bounds.getHeight());
  tr.translate(-bounds.getMinX(),-bounds.getMaxY());
  gr.transform(tr);
  gr.setColor(Color.YELLOW);
  gr.setStroke(new BasicStroke(0));
  for (  final Shape location : locations.values()) {
    gr.draw(location);
  }
  gr.setTransform(oldTr);
  gr.setColor(Color.CYAN);
  final Point2D.Double p=new Point2D.Double();
  for (  final Map.Entry<String,Shape> entry : locations.entrySet()) {
    final Rectangle2D b=entry.getValue().getBounds2D();
    p.x=b.getCenterX();
    p.y=b.getCenterY();
    final Point2D pt=tr.transform(p,p);
    final String label=entry.getKey();
    gr.drawString(label,(float)(pt.getX() - 4.5 * label.length()),(float)pt.getY());
  }
}

Fixed version (ground truth):
/** 
 * Invoked by Swing for painting this widget.
 * @param g  the graphic context where to paint.
 */
@Override protected void paintComponent(final Graphics g){
  super.paintComponent(g);
  final Graphics2D gr=(Graphics2D)g;
  final AffineTransform oldTr=gr.getTransform();
  final AffineTransform tr=AffineTransform.getScaleInstance(getWidth() / bounds.getWidth(),-getHeight() / bounds.getHeight());
  tr.translate(-bounds.getMinX(),-bounds.getMaxY());
  gr.transform(tr);
  gr.setStroke(new BasicStroke(0));
  if (envelope != null) {
    gr.setColor(Color.RED);
    gr.draw(envelope);
  }
  gr.setColor(Color.YELLOW);
  for (  final Shape location : locations.values()) {
    gr.draw(location);
  }
  gr.setTransform(oldTr);
  gr.setColor(Color.CYAN);
  final Point2D.Double p=new Point2D.Double();
  for (  final Map.Entry<String,Shape> entry : locations.entrySet()) {
    final Rectangle2D b=entry.getValue().getBounds2D();
    p.x=b.getCenterX();
    p.y=b.getCenterY();
    final Point2D pt=tr.transform(p,p);
    final String label=entry.getKey();
    gr.drawString(label,(float)(pt.getX() - 4.5 * label.length()),(float)pt.getY());
  }
}
Program: 91733
Project: 91733
Buggy source:
/** 
 * Returns a coder instance to test.
 */
private MilitaryGridReferenceSystem.Coder coder(){
  return new MilitaryGridReferenceSystem().createCoder();
}

Fixed version (ground truth):
/** 
 * Returns a coder instance to test.
 */
private static MilitaryGridReferenceSystem.Coder coder(){
  return new MilitaryGridReferenceSystem().createCoder();
}
Program: 91735
Project: 91735
Buggy source:
/** 
 * Tests if the interior of this shape intersects the interior of a specified rectangle.
 * @param rect  the specified rectangle.
 * @return {@code true} if this shape and the specified rectangle intersect each other.
 */
@Override public final boolean intersects(final Rectangle2D rect){
  if (!(xmin < xmax && ymin < ymax)) {
    return false;
  }
 else {
    final double xmin2=rect.getMinX();
    final double xmax2=rect.getMaxX();
    if (!(xmax2 > xmin2))     return false;
    final double ymin2=rect.getMinY();
    final double ymax2=rect.getMaxY();
    if (!(ymax2 > ymin2))     return false;
    return (xmin2 < xmax && ymin2 < ymax && xmax2 > xmin && ymax2 > ymin);
  }
}

Fixed version (ground truth):
/** 
 * Tests if the interior of this shape intersects the interior of a specified rectangle. The edges are considered exclusive; this method returns   {@code false} if the two rectanglesjust touch to each other.
 * @param rect  the specified rectangle.
 * @return {@code true} if this shape and the specified rectangle intersect each other.
 */
@Override public final boolean intersects(final Rectangle2D rect){
  if (!(xmin < xmax && ymin < ymax)) {
    return false;
  }
 else {
    final double xmin2=rect.getMinX();
    final double xmax2=rect.getMaxX();
    if (!(xmax2 > xmin2))     return false;
    final double ymin2=rect.getMinY();
    final double ymax2=rect.getMaxY();
    if (!(ymax2 > ymin2))     return false;
    return (xmin2 < xmax && ymin2 < ymax && xmax2 > xmin && ymax2 > ymin);
  }
}
Program: 91738
Project: 91738
Buggy source:
/** 
 * Encode random coordinates, decode them and verifies that the results are approximatively equals to the original coordinates.
 * @throws TransformException if an error occurred while computing the coordinate.
 */
@DependsOnMethod({"String_Node_Str","String_Node_Str"}) public void verifyConsistency() throws TransformException {
  final Random random=TestUtilities.createRandomNumberGenerator();
  final MilitaryGridReferenceSystem.Coder coder=coder();
  final DirectPosition2D expected=new DirectPosition2D();
  final DirectPosition2D position=new DirectPosition2D(CommonCRS.WGS84.geographic());
  for (int i=0; i < 100; i++) {
    position.x=random.nextDouble() * 160 - 80;
    position.y=random.nextDouble() * 358 - 179;
    final String reference=coder.encode(position);
    final DirectPosition r=coder.decode(reference);
    final ProjectedCRS crs=(ProjectedCRS)r.getCoordinateReferenceSystem();
    assertSame(expected,crs.getConversionFromBase().getMathTransform().transform(position,expected));
    final double distance=expected.distance(r.getOrdinate(0),r.getOrdinate(1));
    if (!(distance < 1.5)) {
      final String lineSeparator=System.lineSeparator();
      fail("String_Node_Str" + position.x + "String_Node_Str"+ position.y+ lineSeparator+ "String_Node_Str"+ reference+ lineSeparator+ "String_Node_Str"+ r+ lineSeparator+ "String_Node_Str"+ expected+ lineSeparator+ "String_Node_Str"+ distance+ lineSeparator);
    }
  }
}

Fixed version (ground truth):
/** 
 * Encode random coordinates, decode them and verifies that the results are approximatively equals to the original coordinates.
 * @throws TransformException if an error occurred while computing the coordinate.
 */
@Test @DependsOnMethod({"String_Node_Str","String_Node_Str"}) public void verifyConsistency() throws TransformException {
  final Random random=TestUtilities.createRandomNumberGenerator();
  final MilitaryGridReferenceSystem.Coder coder=coder();
  final DirectPosition2D expected=new DirectPosition2D();
  final DirectPosition2D position=new DirectPosition2D(CommonCRS.WGS84.geographic());
  for (int i=0; i < 100; i++) {
    position.x=random.nextDouble() * 160 - 80;
    position.y=random.nextDouble() * 358 - 179;
    final String reference=coder.encode(position);
    final DirectPosition r=coder.decode(reference);
    final ProjectedCRS crs=(ProjectedCRS)r.getCoordinateReferenceSystem();
    assertSame(expected,crs.getConversionFromBase().getMathTransform().transform(position,expected));
    final double distance=expected.distance(r.getOrdinate(0),r.getOrdinate(1));
    if (!(distance < 1.5)) {
      final String lineSeparator=System.lineSeparator();
      fail("String_Node_Str" + position.x + "String_Node_Str"+ position.y+ lineSeparator+ "String_Node_Str"+ reference+ lineSeparator+ "String_Node_Str"+ r+ lineSeparator+ "String_Node_Str"+ expected+ lineSeparator+ "String_Node_Str"+ distance+ lineSeparator);
    }
  }
}
Program: 91740
Project: 91740
Buggy source:
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >    the type of attribute values.
 * @param type   information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value  the initial value (may be {@code null}).
 * @return The new attribute.
 */
static <V>AbstractAttribute<V> create(final DefaultAttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}

Fixed version (ground truth):
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >    the type of attribute values.
 * @param type   information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value  the initial value (may be {@code null}).
 * @return the new attribute.
 */
static <V>AbstractAttribute<V> create(final DefaultAttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}
Program: 91741
Project: 91741
Buggy source:
/** 
 * Creates an initially empty map of attribute characteristics.
 * @param source  the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  description of the characteristics of {@code source}.
 */
CharacteristicMap(final AbstractAttribute<?> source,final CharacteristicTypeMap types){
  this.source=source;
  this.types=types;
}

Fixed version (ground truth):
/** 
 * Creates an initially empty map of attribute characteristics.
 * @param source           the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  description of the characteristics of {@code source}.
 */
CharacteristicMap(final AbstractAttribute<?> source,final CharacteristicTypeMap types){
  this.source=source;
  this.types=types;
}
Program: 91742
Project: 91742
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 DefaultAttributeType<?> source,final DefaultAttributeType<?>[] 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 DefaultAttributeType<?> source,final DefaultAttributeType<?>[] characterizedBy){
  CharacteristicTypeMap map;
synchronized (SHARED) {
    map=SHARED.get(characterizedBy);
    if (map == null) {
      map=new CharacteristicTypeMap(source,characterizedBy);
      SHARED.put(characterizedBy,map);
    }
  }
  return map;
}
Program: 91744
Project: 91744
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: 91745
Project: 91745
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}. <div class="warning"><b>Warning:</b> The type of list elements will be changed to   {@code PropertyType} if and when such interfacewill be defined in GeoAPI.</div>
 * @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<AbstractIdentifiedType> 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}. <div class="warning"><b>Warning:</b> The type of list elements will be changed to   {@code PropertyType} if and when such interfacewill be defined in GeoAPI.</div>
 * @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<AbstractIdentifiedType> getProperties(final boolean includeSuperTypes){
  return includeSuperTypes ? allProperties : properties;
}
Program: 91746
Project: 91746
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: 91748
Project: 91748
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: 91749
Project: 91749
Buggy source:
/** 
 * Returns the feature, or   {@code null} if none.
 * @return The feature (may be {@code null}).
 * @throws IllegalStateException if this association contains more than one value.
 */
@Override public AbstractFeature getValue(){
switch (values.size()) {
case 0:
    return null;
case 1:
  return values.get(0);
default :
throw new IllegalStateException(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 IllegalStateException if this association contains more than one value.
 */
@Override public AbstractFeature getValue(){
switch (values.size()) {
case 0:
    return null;
case 1:
  return values.get(0);
default :
throw new IllegalStateException(Resources.format(Resources.Keys.NotASingleton_1,getName()));
}
}
Program: 91750
Project: 91750
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<AbstractFeature> 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<AbstractFeature> getValues(){
  return values;
}
Program: 91751
Project: 91751
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 AbstractFeature> newValues){
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("String_Node_Str",newValues);
    final DefaultFeatureType base=role.getValueType();
    values.clear();
    for (    final AbstractFeature 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 AbstractFeature> newValues){
  if (newValues != values) {
    ArgumentChecks.ensureNonNull("String_Node_Str",newValues);
    final DefaultFeatureType base=role.getValueType();
    values.clear();
    for (    final AbstractFeature value : newValues) {
      ensureValid(base,value.getType());
      values.add(value);
    }
  }
}
Program: 91752
Project: 91752
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: 91753
Project: 91753
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 AbstractFeature 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 AbstractFeature value){
  values.clear();
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
    values.add(value);
  }
}
Program: 91754
Project: 91754
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<AbstractFeature>)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<AbstractFeature>)clone.values.clone();
  return clone;
}
Program: 91755
Project: 91755
Buggy source:
/** 
 * Returns the associated feature.
 * @return The associated feature (may be {@code null}).
 */
@Override public AbstractFeature getValue(){
  return value;
}

Fixed version (ground truth):
/** 
 * Returns the associated feature.
 * @return the associated feature (may be {@code null}).
 */
@Override public AbstractFeature getValue(){
  return value;
}
Program: 91756
Project: 91756
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 DefaultAssociationRole role,final AbstractFeature 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 DefaultAssociationRole role,final AbstractFeature value){
}
Program: 91757
Project: 91757
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: 91758
Project: 91758
Buggy source:
/** 
 * Sets the associated feature.
 * @param value The new value, or {@code null}.
 * @throws IllegalArgumentException If the given feature is not valid for this association.
 */
@Override public void setValue(final AbstractFeature value) throws IllegalArgumentException {
  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 AbstractFeature value) throws IllegalArgumentException {
  if (value != null) {
    ensureValid(role.getValueType(),value.getType());
  }
  this.value=value;
}
Program: 91759
Project: 91759
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: 91760
Project: 91760
Buggy source:
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >    the type of attribute values.
 * @param type   information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value  the initial value (may be {@code null}).
 * @return The new attribute.
 */
static <V>AbstractAttribute<V> create(final AttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}

Fixed version (ground truth):
/** 
 * Creates a new attribute of the given type initialized to the given value. Note that a   {@code null} value may not be the same as the default value.
 * @param < V >    the type of attribute values.
 * @param type   information about the attribute (base Java class, domain of values, <i>etc.</i>).
 * @param value  the initial value (may be {@code null}).
 * @return the new attribute.
 */
static <V>AbstractAttribute<V> create(final AttributeType<V> type,final Object value){
  ArgumentChecks.ensureNonNull("String_Node_Str",type);
  return isSingleton(type.getMaximumOccurs()) ? new SingletonAttribute<>(type,value) : new MultiValuedAttribute<>(type,value);
}
Program: 91761
Project: 91761
Buggy source:
/** 
 * Creates an initially empty map of attribute characteristics.
 * @param source  the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  description of the characteristics of {@code source}.
 */
CharacteristicMap(final Attribute<?> source,final CharacteristicTypeMap types){
  this.source=source;
  this.types=types;
}

Fixed version (ground truth):
/** 
 * Creates an initially empty map of attribute characteristics.
 * @param source           the attribute which is characterized by {@code characterizedBy}.
 * @param characterizedBy  description of the characteristics of {@code source}.
 */
CharacteristicMap(final Attribute<?> source,final CharacteristicTypeMap types){
  this.source=source;
  this.types=types;
}