Dataset Viewer
Auto-converted to Parquet Duplicate
before
stringlengths
290
5.46k
after
stringlengths
114
5.17k
loc
int64
7
184
repo
stringclasses
5 values
public String find() throws Exception { logger.info( "Starting find()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Customer.class ); criteria.add( Example.create( this.customer ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.customer.getId() != null ) { criteria.add( Restrictions.idEq( this.customer.getId() ) ); } @SuppressWarnings("unchecked") List<Customer> l = (List<Customer>) criteria.list(); request.put( "list", l ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; logger.info( "Finishing find()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Customer.class ); criteria.add( Example.create( this.customer ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.customer.getId() != null ) { criteria.add( Restrictions.idEq( this.customer.getId() ) ); } @SuppressWarnings("unchecked") List<Customer> l = (List<Customer>) criteria.list(); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
20
MyWebMarket
public String save() throws Exception { logger.info( "Starting save()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.save( this.customer ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "saveSuccessful", new String[]{"customer"}) ); logger.info( "Finishing save()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.save( this.customer ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String update() throws Exception { logger.info( "Starting update()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.update( this.customer ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "updateSuccessful", new String[]{"customer"}) ); logger.info( "Finishing update()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.update( this.customer ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String delete() throws Exception { logger.info( "Starting delete()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.customer ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; this.addActionMessage( this.getText( "deleteSuccessful", new String[]{"customer"}) ); logger.info( "Finishing delete()" ); return this.input(); }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.customer ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String edit() throws Exception { logger.info( "Starting edit()" ); Integer id = Integer.valueOf( this.parameters.get( "id" )[0] ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Customer c = (Customer) sess.get( Customer.class, id ); this.setCustomer( c ); t.commit(); sess.close(); logger.info( "Finishing edit()" ); this.task = SystemConstants.UD_MODE; return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Customer c = (Customer) sess.get( Customer.class, id ); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
16
MyWebMarket
public String execute() throws Exception { logger.info( "Starting execute()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( User.class ); criteria.add( Restrictions.idEq( this.user.getUsername() ) ); criteria.add( Restrictions.eq( "password", this.user.getPassword() ) ); User user = (User) criteria.uniqueResult(); t.commit(); sess.close(); if ( user != null ) { ActionContext.getContext().getSession().put( SystemConstants.AUTHENTICATED_USER, user ); logger.info( "Finishing execute() -- Success" ); return SUCCESS; } this.addActionError( this.getText( "login.failure" ) ); logger.info( "Finishing execute() -- Failure" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( User.class ); criteria.add( Restrictions.idEq( this.user.getUsername() ) ); criteria.add( Restrictions.eq( "password", this.user.getPassword() ) ); User user = (User) criteria.uniqueResult(); t.commit(); sess.close(); </DeepExtract>
23
MyWebMarket
public String find() throws Exception { logger.info( "Starting find()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.add( Example.create( this.product ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.product.getId() != null ) { criteria.add( Restrictions.idEq( this.product.getId() ) ); } @SuppressWarnings("unchecked") List<Product> l = (List<Product>) criteria.list(); request.put( "list", l ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; logger.info( "Finishing find()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.add( Example.create( this.product ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.product.getId() != null ) { criteria.add( Restrictions.idEq( this.product.getId() ) ); } @SuppressWarnings("unchecked") List<Product> l = (List<Product>) criteria.list(); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
20
MyWebMarket
public String save() throws Exception { logger.info( "Starting save()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.save( this.product ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "saveSuccessful", new String[]{"product"}) ); logger.info( "Finishing save()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.save( this.product ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String update() throws Exception { logger.info( "Starting update()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.update( this.product ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "updateSuccessful", new String[]{"product"}) ); logger.info( "Finishing update()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.update( this.product ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String delete() throws Exception { logger.info( "Starting delete()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.product ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; this.addActionMessage( this.getText( "deleteSuccessful", new String[]{"product"}) ); logger.info( "Finishing delete()" ); return this.input(); }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.product ); t.commit(); sess.close(); </DeepExtract>
14
MyWebMarket
public String edit() throws Exception { logger.info( "Starting edit()" ); Integer id = Integer.valueOf( this.parameters.get( "id" )[0] ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Product p = (Product) sess.get( Product.class, id ); this.setProduct( p ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; logger.info( "Finishing edit()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Product p = (Product) sess.get( Product.class, id ); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
16
MyWebMarket
public String input() throws Exception { logger.info( "Starting input()" ); this.task = SystemConstants.CR_MODE; this.purchaseOrder = null; Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Customer.class ); @SuppressWarnings("unchecked") List<Customer> lc = (List<Customer>) criteria.list(); ActionContext.getContext().getSession().put( "listCustomer", lc ); criteria = sess.createCriteria( Product.class ); @SuppressWarnings("unchecked") List<Product> lp = (List<Product>) criteria.list(); ActionContext.getContext().getSession().put( "listProduct", lp ); t.commit(); sess.close(); logger.info( "Finishing input()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); </DeepExtract> <DeepExtract> Criteria criteria = sess.createCriteria( Customer.class ); @SuppressWarnings("unchecked") List<Customer> lc = (List<Customer>) criteria.list(); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
23
MyWebMarket
public String find() throws Exception { logger.info( "Starting find()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( PurchaseOrder.class ); criteria.add( Example.create( this.purchaseOrder ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.purchaseOrder.getId() != null ) { criteria.add( Restrictions.idEq( this.purchaseOrder.getId() ) ); } if ( this.purchaseOrder.getCustomer().getId() != null ) { criteria.add( Restrictions.eq( "customer", this.purchaseOrder.getCustomer() ) ); } criteria.setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY ); @SuppressWarnings("unchecked") List<PurchaseOrder> l = (List<PurchaseOrder>) criteria.list(); request.put( "list", l ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; logger.info( "Finishing input()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( PurchaseOrder.class ); criteria.add( Example.create( this.purchaseOrder ).excludeZeroes().ignoreCase().enableLike( MatchMode.ANYWHERE ) ); if ( this.purchaseOrder.getId() != null ) { criteria.add( Restrictions.idEq( this.purchaseOrder.getId() ) ); } if ( this.purchaseOrder.getCustomer().getId() != null ) { criteria.add( Restrictions.eq( "customer", this.purchaseOrder.getCustomer() ) ); } criteria.setResultTransformer( Criteria.DISTINCT_ROOT_ENTITY ); @SuppressWarnings("unchecked") List<PurchaseOrder> l = (List<PurchaseOrder>) criteria.list(); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
25
MyWebMarket
public String save() throws Exception { logger.info( "Starting save()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); this.purchaseOrder.setOrderDate( new Date() ); for (PurchaseOrderItem item : this.purchaseOrder.getPurchaseOrderItems()) { item.setPurchaseOrder( this.purchaseOrder ); } sess.save( this.purchaseOrder ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "saveSuccessful", new String[] { "order" } ) ); logger.info( "Finishing save()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); </DeepExtract> <DeepExtract> sess.save( this.purchaseOrder ); t.commit(); sess.close(); </DeepExtract>
20
MyWebMarket
public String update() throws Exception { logger.info( "Starting update()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); for (PurchaseOrderItem item : this.purchaseOrder.getPurchaseOrderItems()){ item.setPurchaseOrder( this.purchaseOrder ); } sess.update( this.purchaseOrder ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; this.addActionMessage( this.getText( "updateSuccessful", new String[] { "order" } ) ); logger.info( "Finishing update()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); </DeepExtract> <DeepExtract> sess.update( this.purchaseOrder ); t.commit(); sess.close(); </DeepExtract>
18
MyWebMarket
public String delete() throws Exception { logger.info( "Starting delete()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.purchaseOrder ); t.commit(); sess.close(); this.task = SystemConstants.CR_MODE; this.addActionMessage( this.getText( "deleteSuccessful", new String[] { "order" } ) ); logger.info( "Finishing delete()" ); return this.input(); }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); sess.delete( this.purchaseOrder ); t.commit(); sess.close(); </DeepExtract>
13
MyWebMarket
public String edit() throws Exception { logger.info( "Starting edit()" ); Integer id = Integer.valueOf( this.parameters.get( "id" )[0] ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); PurchaseOrder po = (PurchaseOrder) sess.get( PurchaseOrder.class, id ); this.setPurchaseOrder( po ); t.commit(); sess.close(); this.task = SystemConstants.UD_MODE; logger.info( "Finishing edit()" ); return INPUT; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); PurchaseOrder po = (PurchaseOrder) sess.get( PurchaseOrder.class, id ); </DeepExtract> <DeepExtract> t.commit(); sess.close(); </DeepExtract>
16
MyWebMarket
public Double getProductPrice(Integer idProduct){ logger.info( "Starting getProductPrice()" ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.setProjection( Projections.property( "price" ) ); criteria.add( Restrictions.eq( "id", idProduct ) ); Double price = (Double) criteria.uniqueResult(); t.commit(); sess.close(); logger.info( "Finishing getProductPrice()" ); return price; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.setProjection( Projections.property( "price" ) ); criteria.add( Restrictions.eq( "id", idProduct ) ); Double price = (Double) criteria.uniqueResult(); t.commit(); sess.close(); </DeepExtract>
17
MyWebMarket
public String productReport() throws Exception { logger.info( "Starting productReport()" ); ActionContext ac = ActionContext.getContext(); ServletContext sc = (ServletContext) ac.get( StrutsStatics.SERVLET_CONTEXT ); JasperReport jasperReport = JasperCompileManager.compileReport( sc.getResourceAsStream( "/WEB-INF/classes/ProductReport.xml" ) ); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put( "ReportTitle", "List of Products" ); parameters.put( "DataFile", new Date().toString() ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.setProjection( Projections.projectionList().add( Projections.property( "id" ) ).add( Projections.property( "name" ) ).add( Projections.property( "price" ) ) ); @SuppressWarnings("unchecked") List<Object[]> l = (List<Object[]>) criteria.list(); t.commit(); sess.close(); HibernateQueryResultDataSource ds = new HibernateQueryResultDataSource(l, new String[] { "Id", "Name", "Price" }); JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, ds ); byte b[] = JasperExportManager.exportReportToPdf( jasperPrint ); this.inputStream = new ByteArrayInputStream( b ); logger.info( "Finishing productReport()" ); return "download"; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.setProjection( Projections.projectionList().add( Projections.property( "id" ) ).add( Projections.property( "name" ) ).add( Projections.property( "price" ) ) ); @SuppressWarnings("unchecked") List<Object[]> l = (List<Object[]>) criteria.list(); t.commit(); sess.close(); </DeepExtract>
35
MyWebMarket
public String customerReport() throws Exception { logger.info( "Starting customerReport()" ); ActionContext ac = ActionContext.getContext(); ServletContext sc = (ServletContext) ac.get( StrutsStatics.SERVLET_CONTEXT ); JasperReport jasperReport = JasperCompileManager.compileReport( sc.getResourceAsStream( "/WEB-INF/classes/CustomerReport.xml" ) ); Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put( "ReportTitle", "List of Customers" ); parameters.put( "DataFile", new Date().toString() ); Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Customer.class ); criteria.setProjection( Projections.projectionList().add( Projections.property( "id" ) ).add( Projections.property( "name" ) ).add( Projections.property( "phone" ) ) ); @SuppressWarnings("unchecked") List<Object[]> l = (List<Object[]>) criteria.list(); t.commit(); sess.close(); HibernateQueryResultDataSource ds = new HibernateQueryResultDataSource(l, new String[] { "Id", "Name", "Phone" }); JasperPrint jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, ds ); byte b[] = JasperExportManager.exportReportToPdf( jasperPrint ); this.inputStream = new ByteArrayInputStream( b ); logger.info( "Finishing customerReport()" ); return "download"; }
<DeepExtract> Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Customer.class ); criteria.setProjection( Projections.projectionList().add( Projections.property( "id" ) ).add( Projections.property( "name" ) ).add( Projections.property( "phone" ) ) ); @SuppressWarnings("unchecked") List<Object[]> l = (List<Object[]>) criteria.list(); t.commit(); sess.close(); </DeepExtract>
35
MyWebMarket
public String input() throws Exception { logger.info( "Starting input()" ); SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sc = sf.getScheduler(); JobDetail job = sc.getJobDetail( JobKey.jobKey( "supplyMailJob", "group" ) ); if ( job != null ) { this.timeInterval = job.getJobDataMap().getIntValue( "timeInterval" ); } logger.info( "Finishing input()" ); return super.input(); }
<DeepExtract> SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sc = sf.getScheduler(); JobDetail job = sc.getJobDetail( JobKey.jobKey( "supplyMailJob", "group" ) ); if ( job != null ) { this.timeInterval = job.getJobDataMap().getIntValue( "timeInterval" ); } </DeepExtract>
12
MyWebMarket
public String schedule() throws Exception { logger.info( "Starting schedule()" ); SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sc = sf.getScheduler(); JobDetail job = sc.getJobDetail( JobKey.jobKey( "supplyMailJob", "group" ) ); if ( job != null ) { sc.deleteJob( JobKey.jobKey( "supplyMailJob", "group" ) ); } job = newJob( SupplyMailJob.class ).withIdentity( "supplyMailJob", "group" ).build(); job.getJobDataMap().put( "timeInterval", this.timeInterval ); Trigger trigger = newTrigger().withIdentity( "supplyMailTrigger", "group" ).startNow().withSchedule( CronScheduleBuilder.cronSchedule( "0 0/" + (this.timeInterval * 60) + " * * * ?" ) ).build(); sc.scheduleJob( job, trigger ); logger.info( "Finishing schedule()" ); return INPUT; } }
<DeepExtract> SchedulerFactory sf = new StdSchedulerFactory(); Scheduler sc = sf.getScheduler(); JobDetail job = sc.getJobDetail( JobKey.jobKey( "supplyMailJob", "group" ) ); if ( job != null ) { sc.deleteJob( JobKey.jobKey( "supplyMailJob", "group" ) ); } job = newJob( SupplyMailJob.class ).withIdentity( "supplyMailJob", "group" ).build(); job.getJobDataMap().put( "timeInterval", this.timeInterval ); Trigger trigger = newTrigger().withIdentity( "supplyMailTrigger", "group" ).startNow().withSchedule( CronScheduleBuilder.cronSchedule( "0 0/" + (this.timeInterval * 60) + " * * * ?" ) ).build(); sc.scheduleJob( job, trigger ); </DeepExtract>
21
MyWebMarket
public void execute( JobExecutionContext context ) throws JobExecutionException { logger.info( "Starting execute() in job" ); org.hibernate.Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.add( Restrictions.lt( "supply", 5 ) ); @SuppressWarnings("unchecked") List<Product> l = (List<Product>) criteria.list(); t.commit(); sess.close(); if ( !l.isEmpty() ) { StringBuilder str = new StringBuilder(); str.append( "The following products are getting over:\n" ); Properties props = new Properties(); props.setProperty( "mail.smtp.submitter", "terra" ); props.setProperty( "mail.smtp.auth", "false" ); props.setProperty( "mail.smtp.host", this.host ); props.setProperty( "mail.smtp.port", "25" ); javax.mail.Session session = javax.mail.Session.getInstance( props ); try { Message msg = new MimeMessage( session ); msg.setFrom( new InternetAddress( this.from ) ); InternetAddress[] address = { new InternetAddress( this.to ) }; msg.setRecipients( Message.RecipientType.TO, address ); msg.setSubject( "Low Supply of Products" ); msg.setSentDate( new Date() ); for ( Product p : l ) { str.append( p.getName() + "\t\t" + p.getSupply() + "\n" ); } msg.setText( str.toString() ); Transport.send( msg ); } catch (MessagingException mex) { mex.printStackTrace(); } } logger.info( "Finishing execute() in job" ); }
<DeepExtract> org.hibernate.Session sess = HibernateUtil.getSessionFactory().openSession(); Transaction t = sess.beginTransaction(); Criteria criteria = sess.createCriteria( Product.class ); criteria.add( Restrictions.lt( "supply", 5 ) ); @SuppressWarnings("unchecked") List<Product> l = (List<Product>) criteria.list(); t.commit(); sess.close(); </DeepExtract> <DeepExtract> Properties props = new Properties(); props.setProperty( "mail.smtp.submitter", "terra" ); props.setProperty( "mail.smtp.auth", "false" ); props.setProperty( "mail.smtp.host", this.host ); props.setProperty( "mail.smtp.port", "25" ); javax.mail.Session session = javax.mail.Session.getInstance( props ); try { Message msg = new MimeMessage( session ); msg.setFrom( new InternetAddress( this.from ) ); InternetAddress[] address = { new InternetAddress( this.to ) }; msg.setRecipients( Message.RecipientType.TO, address ); msg.setSubject( "Low Supply of Products" ); msg.setSentDate( new Date() ); </DeepExtract> <DeepExtract> msg.setText( str.toString() ); Transport.send( msg ); </DeepExtract>
47
MyWebMarket
public void writeStorable(Storable storable) { if (storable == null) { fStream.print("NULL"); space(); return; } if (mapped(storable)) { int ref = fMap.indexOf(storable); fStream.print("REF"); space(); fStream.print(ref); space(); return; } incrementIndent(); startNewLine(); map(storable); fStream.print(storable.getClass().getName()); space(); storable.write(this); space(); decrementIndent(); }
<DeepExtract> int ref = fMap.indexOf(storable); fStream.print("REF"); space(); fStream.print(ref); space(); </DeepExtract>
24
JHotDraw5.2
public String store(String fileName, Drawing saveDrawing) throws IOException { FileOutputStream stream = new FileOutputStream(adjustFileName(fileName)); StorableOutput output = new StorableOutput(stream); output.writeStorable(saveDrawing); output.close(); if (!hasCorrectFileExtension(fileName)) { return fileName + "." + getFileExtension(); } else { return fileName; } }
<DeepExtract> if (!hasCorrectFileExtension(fileName)) { return fileName + "." + getFileExtension(); } else { return fileName; } </DeepExtract>
10
JHotDraw5.2
public Image getImage(String filename) { Image image = basicGetImage(filename); if (image != null) return image; loadRegisteredImages(fComponent); if (fMap.containsKey(filename)) return (Image) fMap.get(filename); return null; } private Image basicGetImage(String filename) {
<DeepExtract> if (fMap.containsKey(filename)) return (Image) fMap.get(filename); return null; </DeepExtract>
10
JHotDraw5.2
static public Point angleToPoint(Rectangle r, double angle) { double si = Math.sin(angle); double co = Math.cos(angle); double e = 0.0001; int x= 0, y= 0; if (Math.abs(si) > e) { x= (int) ((1.0 + co/Math.abs(si))/2.0 * r.width); int max = r.width; int value = x; if (value < 0) value = 0; if (value > max) value = max; x= value; } else if (co >= 0.0) x= r.width; if (Math.abs(co) > e) { y= (int) ((1.0 + si/Math.abs(co))/2.0 * r.height); y= range(0, r.height, y); } else if (si >= 0.0) y= r.height; return new Point(r.x + x, r.y + y); }
<DeepExtract> int max = r.width; int value = x; if (value < 0) value = 0; if (value > max) value = max; x= value; </DeepExtract>
22
JHotDraw5.2
public void setDrawing(Drawing d) { if (fDrawing != null) { clearSelection(); fDrawing.removeDrawingChangeListener(this); } fDrawing = d; if (fDrawing != null) fDrawing.addDrawingChangeListener(this); FigureEnumeration k = drawing().figures(); Dimension d1 = new Dimension(0, 0); while (k.hasMoreElements()) { Rectangle r = k.nextFigure().displayBox(); d1.width = Math.max(d1.width, r.x+r.width); d1.height = Math.max(d1.height, r.y+r.height); } if (fViewSize.height < d1.height || fViewSize.width < d1.width) { fViewSize.height = d1.height+10; fViewSize.width = d1.width+10; setSize(fViewSize); } repaint(); }
<DeepExtract> FigureEnumeration k = drawing().figures(); Dimension d1 = new Dimension(0, 0); while (k.hasMoreElements()) { Rectangle r = k.nextFigure().displayBox(); d1.width = Math.max(d1.width, r.x+r.width); d1.height = Math.max(d1.height, r.y+r.height); } if (fViewSize.height < d1.height || fViewSize.width < d1.width) { fViewSize.height = d1.height+10; fViewSize.width = d1.width+10; setSize(fViewSize); } </DeepExtract>
22
JHotDraw5.2
public Handle findHandle(int x, int y) { Handle handle; if (fSelectionHandles == null) { fSelectionHandles = new Vector(); FigureEnumeration k1 = selectionElements(); while (k1.hasMoreElements()) { Figure figure = k1.nextFigure(); Enumeration kk = figure.handles().elements(); while (kk.hasMoreElements()) fSelectionHandles.addElement(kk.nextElement()); } } Enumeration k = fSelectionHandles.elements(); while (k.hasMoreElements()) { handle = (Handle) k.nextElement(); if (handle.containsPoint(x, y)) return handle; } return null; }
<DeepExtract> if (fSelectionHandles == null) { fSelectionHandles = new Vector(); FigureEnumeration k1 = selectionElements(); while (k1.hasMoreElements()) { Figure figure = k1.nextFigure(); Enumeration kk = figure.handles().elements(); while (kk.hasMoreElements()) fSelectionHandles.addElement(kk.nextElement()); } } Enumeration k = fSelectionHandles.elements(); </DeepExtract>
19
JHotDraw5.2
protected Point constrainPoint(Point p) { Dimension size = getSize(); int max = size.width; int value = p.x; if (value < 1) value = 1; if (value > max) value = max; p.x = value; p.y = Geom.range(1, size.height, p.y); if (fConstrainer != null ) return fConstrainer.constrainPoint(p); return p; }
<DeepExtract> int max = size.width; int value = p.x; if (value < 1) value = 1; if (value > max) value = max; p.x = value; </DeepExtract>
15
JHotDraw5.2
public void execute() { Point lastClick = fView.lastClick(); FigureSelection selection = (FigureSelection)Clipboard.getClipboard().getContents(); if (selection != null) { Vector figures = (Vector)selection.getData(FigureSelection.TYPE); if (figures.size() == 0) return; Enumeration k = figures.elements(); Rectangle r1 = ((Figure) k.nextElement()).displayBox(); while (k.hasMoreElements()) r1.add(((Figure) k.nextElement()).displayBox()); Rectangle r = r1; fView.clearSelection(); insertFigures(figures, lastClick.x-r.x, lastClick.y-r.y); fView.checkDamage(); } }
<DeepExtract> Enumeration k = figures.elements(); Rectangle r1 = ((Figure) k.nextElement()).displayBox(); while (k.hasMoreElements()) r1.add(((Figure) k.nextElement()).displayBox()); Rectangle r = r1; </DeepExtract>
17
JHotDraw5.2
protected EventListener remove(EventListener oldl) { if (oldl == a) return b; if (oldl == b) return a; EventListener a2 = removeInternal((FigureChangeListener)a, oldl); EventListener b2 = removeInternal((FigureChangeListener)b, oldl); if (a2 == a && b2 == b) return this; else { FigureChangeListener a1 = (FigureChangeListener)a2; FigureChangeListener b1 = (FigureChangeListener)b2; if (a1 == null) return b1; if (b1 == null) return a1; return new FigureChangeEventMulticaster(a1, b1); } }
<DeepExtract> FigureChangeListener a1 = (FigureChangeListener)a2; FigureChangeListener b1 = (FigureChangeListener)b2; if (a1 == null) return b1; if (b1 == null) return a1; return new FigureChangeEventMulticaster(a1, b1); </DeepExtract>
16
JHotDraw5.2
public void mouseDrag(MouseEvent e, int x, int y) { Point p = new Point(e.getX(), e.getY()); if (fConnection != null) { Figure c = null; if (fStartConnector == null) c = findSource(x, y, drawing()); else c = findTarget(x, y, drawing()); if (c != fTarget) { if (fTarget != null) fTarget.connectorVisibility(false); fTarget = c; if (fTarget != null) fTarget.connectorVisibility(true); } Connector cc = null; if (c != null) cc = findConnector(e.getX(), e.getY(), c); if (cc != fConnectorTarget) fConnectorTarget = cc; view().checkDamage(); if (fConnectorTarget != null) p = Geom.center(fConnectorTarget.displayBox()); fConnection.endPoint(p.x, p.y); } else if (fEditedConnection != null) { Point pp = new Point(x, y); fEditedConnection.setPointAt(pp, fSplitPoint); } }
<DeepExtract> Figure c = null; if (fStartConnector == null) c = findSource(x, y, drawing()); else c = findTarget(x, y, drawing()); if (c != fTarget) { if (fTarget != null) fTarget.connectorVisibility(false); fTarget = c; if (fTarget != null) fTarget.connectorVisibility(true); } Connector cc = null; if (c != null) cc = findConnector(e.getX(), e.getY(), c); if (cc != fConnectorTarget) fConnectorTarget = cc; view().checkDamage(); </DeepExtract>
33
JHotDraw5.2
public Figure findFigureWithout(int x, int y, Figure without) { if (without == null) { FigureEnumeration k1 = figuresReverse(); while (k1.hasMoreElements()) { Figure figure1 = k1.nextFigure(); if (figure1.containsPoint(x, y)) return figure1; } return null; } FigureEnumeration k = figuresReverse(); while (k.hasMoreElements()) { Figure figure = k.nextFigure(); if (figure.containsPoint(x, y) && !figure.includes(without)) return figure; } return null; }
<DeepExtract> FigureEnumeration k1 = figuresReverse(); while (k1.hasMoreElements()) { Figure figure1 = k1.nextFigure(); if (figure1.containsPoint(x, y)) return figure1; } return null; </DeepExtract>
16
JHotDraw5.2
public Figure findFigure(Rectangle r, Figure without) { if (without == null) { FigureEnumeration k1 = figuresReverse(); while (k1.hasMoreElements()) { Figure figure1 = k1.nextFigure(); Rectangle fr1 = figure1.displayBox(); if (r.intersects(fr1)) return figure1; } return null; } FigureEnumeration k = figuresReverse(); while (k.hasMoreElements()) { Figure figure = k.nextFigure(); Rectangle fr = figure.displayBox(); if (r.intersects(fr) && !figure.includes(without)) return figure; } return null; } /**
<DeepExtract> FigureEnumeration k1 = figuresReverse(); while (k1.hasMoreElements()) { Figure figure1 = k1.nextFigure(); Rectangle fr1 = figure1.displayBox(); if (r.intersects(fr1)) return figure1; } return null; </DeepExtract>
19
JHotDraw5.2
static public void addHandles(Figure f, Vector handles) { handles.addElement(southEast(f)); handles.addElement(southWest(f)); handles.addElement(northEast(f)); handles.addElement(northWest(f)); handles.addElement(south(f)); handles.addElement(north(f)); handles.addElement(east(f)); handles.addElement(west(f)); }
<DeepExtract> handles.addElement(southEast(f)); handles.addElement(southWest(f)); handles.addElement(northEast(f)); handles.addElement(northWest(f)); </DeepExtract>
8
JHotDraw5.2
public void update(FigureChangeEvent e) { if (e.getFigure() == figureAt(1)) { int newEnd = start()+duration(); if (newEnd != end()) { setEnd(newEnd); notifyPostTasks(); } } if (needsLayout()) { layout(); changed(); } }
<DeepExtract> int newEnd = start()+duration(); if (newEnd != end()) { setEnd(newEnd); notifyPostTasks(); } </DeepExtract>
11
JHotDraw5.2
public void updateDurations() { int newEnd = start()+duration(); if (newEnd != end()) { setEnd(newEnd); Enumeration i = fPostTasks.elements(); while (i.hasMoreElements()) ((PertFigure) i.nextElement()).updateDurations(); } }
<DeepExtract> Enumeration i = fPostTasks.elements(); while (i.hasMoreElements()) ((PertFigure) i.nextElement()).updateDurations(); </DeepExtract>
7
JHotDraw5.2
public void write(StorableOutput dw) { super.write(dw); dw.writeInt(fDisplayBox.x); dw.writeInt(fDisplayBox.y); dw.writeInt(fDisplayBox.width); dw.writeInt(fDisplayBox.height); dw.writeInt(fPreTasks.size()); Enumeration i = fPreTasks.elements(); while (i.hasMoreElements()) dw.writeStorable((Storable) i.nextElement()); writeTasks(dw, fPostTasks); }
<DeepExtract> dw.writeInt(fPreTasks.size()); Enumeration i = fPreTasks.elements(); while (i.hasMoreElements()) dw.writeStorable((Storable) i.nextElement()); </DeepExtract>
11
JHotDraw5.2
public void read(StorableInput dr) throws IOException { super.read(dr); fDisplayBox = new Rectangle( dr.readInt(), dr.readInt(), dr.readInt(), dr.readInt()); layout(); int size = dr.readInt(); Vector v = new Vector(size); for (int i=0; i<size; i++) v.addElement((Figure)dr.readStorable()); fPreTasks = v; fPostTasks = readTasks(dr); }
<DeepExtract> int size = dr.readInt(); Vector v = new Vector(size); for (int i=0; i<size; i++) v.addElement((Figure)dr.readStorable()); fPreTasks = v; </DeepExtract>
13
JHotDraw5.2
private void initialize() { setText("node"); Font fb = new Font("Helvetica", Font.BOLD, 12); setFont(fb); fConnectors = new Vector(4); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.north()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.south()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.west()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.east()) ); } }
<DeepExtract> fConnectors = new Vector(4); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.north()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.south()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.west()) ); fConnectors.addElement(new LocatorConnector(this, RelativeLocator.east()) ); </DeepExtract>
8
JHotDraw5.2
public void mouseDown(MouseEvent e, int x, int y) { Figure pressedFigure; pressedFigure = drawing().findFigureInside(x, y); if (pressedFigure != null) { if (fTextField == null) { fTextField = new FloatingTextField(); fTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { endAction(event); } } ); } if (pressedFigure != fURLTarget && fURLTarget != null) endEdit(); if (pressedFigure != fURLTarget) { fTextField.createOverlay((Container)view()); fTextField.setBounds(fieldBounds(pressedFigure), getURL(pressedFigure)); fURLTarget = pressedFigure; } return; } endEdit(); }
<DeepExtract> if (fTextField == null) { fTextField = new FloatingTextField(); fTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { endAction(event); } } ); } if (pressedFigure != fURLTarget && fURLTarget != null) endEdit(); if (pressedFigure != fURLTarget) { fTextField.createOverlay((Container)view()); fTextField.setBounds(fieldBounds(pressedFigure), getURL(pressedFigure)); fURLTarget = pressedFigure; } </DeepExtract>
25
JHotDraw5.2
private void beginEdit(Figure figure) { if (fTextField == null) { fTextField = new FloatingTextField(); fTextField.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { endAction(event); } } ); } if (figure != fURLTarget && fURLTarget != null){ if (fURLTarget != null) { setURL(fURLTarget, fTextField.getText()); fURLTarget = null; fTextField.endOverlay(); }} if (figure != fURLTarget) { fTextField.createOverlay((Container)view()); fTextField.setBounds(fieldBounds(figure), getURL(figure)); fURLTarget = figure; } }
<DeepExtract> if (fURLTarget != null) { setURL(fURLTarget, fTextField.getText()); fURLTarget = null; fTextField.endOverlay(); }} </DeepExtract>
22
JHotDraw5.2
public void init() { getContentPane().setLayout(new BorderLayout()); fView = new StandardDrawingView(this, 400, 370); getContentPane().add("Center", fView); fTool = new FollowURLTool(view(), this); fIconkit = new Iconkit(this); String filename = getParameter("Drawing"); if (filename != null) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); StorableInput reader = new StorableInput(stream); fDrawing = (Drawing)reader.readStorable(); } catch (IOException e) { fDrawing = new StandardDrawing(); System.out.println("Error when Loading: " + e); showStatus("Error when Loading: " + e); } fView.setDrawing(fDrawing); } else showStatus("Unable to load drawing"); }
<DeepExtract> try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); StorableInput reader = new StorableInput(stream); fDrawing = (Drawing)reader.readStorable(); } catch (IOException e) { fDrawing = new StandardDrawing(); System.out.println("Error when Loading: " + e); showStatus("Error when Loading: " + e); } </DeepExtract>
22
JHotDraw5.2
protected void createButtons(JPanel panel) { super.createButtons(panel); fAnimationButton = new JButton("Start Animation"); fAnimationButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (fAnimator != null) endAnimation(); else startAnimation(); } } ); panel.add(fAnimationButton); }
<DeepExtract> if (fAnimator != null) endAnimation(); else startAnimation(); </DeepExtract>
13
JHotDraw5.2
protected JMenu createAnimationMenu() { JMenu menu = new JMenu("Animation"); JMenuItem mi = new JMenuItem("Start Animation"); mi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { if (drawing() instanceof Animatable && fAnimator == null) { fAnimator = new Animator((Animatable)drawing(), view()); fAnimator.start(); } } } ); menu.add(mi); mi = new JMenuItem("Stop Animation"); mi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { endAnimation(); } } ); menu.add(mi); return menu; }
<DeepExtract> if (drawing() instanceof Animatable && fAnimator == null) { fAnimator = new Animator((Animatable)drawing(), view()); fAnimator.start(); } </DeepExtract>
24
JHotDraw5.2
public void mouseDown(MouseEvent e, int x, int y) { TextHolder textHolder = null; Figure pressedFigure = drawing().findFigureInside(x, y); if (pressedFigure instanceof TextHolder) { textHolder = (TextHolder) pressedFigure; if (!textHolder.acceptsTyping()) textHolder = null; } if (textHolder != null) { if (fTextField == null) fTextField = new FloatingTextField(); if (textHolder != getTypingTarget() && getTypingTarget() != null) endEdit(); fTextField.createOverlay((Container)view(), textHolder.getFont()); fTextField.setBounds(fieldBounds(textHolder), textHolder.getText()); setTypingTarget(textHolder); view().checkDamage(); return; } if (getTypingTarget() != null) { editor().toolDone(); endEdit(); } else { super.mouseDown(e, x, y); textHolder = (TextHolder)createdFigure(); beginEdit(textHolder); } }
<DeepExtract> if (fTextField == null) fTextField = new FloatingTextField(); if (textHolder != getTypingTarget() && getTypingTarget() != null) endEdit(); fTextField.createOverlay((Container)view(), textHolder.getFont()); fTextField.setBounds(fieldBounds(textHolder), textHolder.getText()); setTypingTarget(textHolder); view().checkDamage(); </DeepExtract>
30
JHotDraw5.2
protected void beginEdit(TextHolder figure) { if (fTextField == null) fTextField = new FloatingTextField(); if (figure != getTypingTarget() && getTypingTarget() != null){ if (getTypingTarget() != null) { if (fTextField.getText().length() > 0) getTypingTarget().setText(fTextField.getText()); else { drawing().remove((Figure)getTypingTarget()); } setTypingTarget(null); fTextField.endOverlay(); view().checkDamage(); } } fTextField.createOverlay((Container)view(), figure.getFont()); fTextField.setBounds(fieldBounds(figure), figure.getText()); setTypingTarget(figure); view().checkDamage(); }
<DeepExtract> if (getTypingTarget() != null) { if (fTextField.getText().length() > 0) getTypingTarget().setText(fTextField.getText()); else { drawing().remove((Figure)getTypingTarget()); } setTypingTarget(null); fTextField.endOverlay(); view().checkDamage(); } </DeepExtract>
20
JHotDraw5.2
public void setAttribute(String name, Object value) { Font font = getFont(); if (name.equals("FontSize")) { Integer s = (Integer)value; willChange(); fFont = new Font(font.getName(), font.getStyle(), s.intValue()); markDirty(); changed(); } else if (name.equals("FontStyle")) { Integer s = (Integer)value; int style = font.getStyle(); if (s.intValue() == Font.PLAIN) style = font.PLAIN; else style = style ^ s.intValue(); setFont(new Font(font.getName(), style, font.getSize()) ); } else if (name.equals("FontName")) { String n = (String)value; setFont(new Font(n, font.getStyle(), font.getSize()) ); } else super.setAttribute(name, value); }
<DeepExtract> willChange(); fFont = new Font(font.getName(), font.getStyle(), s.intValue()); markDirty(); changed(); </DeepExtract>
23
JHotDraw5.2
public void connect(Figure figure) { if (fObservedFigure != null) fObservedFigure.removeFigureChangeListener(this); fObservedFigure = figure; fLocator = new OffsetLocator(figure.connectedTextLocator(this)); fObservedFigure.addFigureChangeListener(this); if (fLocator != null) { Point p = fLocator.locate(fObservedFigure); p.x -= size().width/2 + fOriginX; p.y -= size().height/2 + fOriginY; if (p.x != 0 || p.y != 0) { willChange(); basicMoveBy(p.x, p.y); changed(); } } }
<DeepExtract> if (fLocator != null) { Point p = fLocator.locate(fObservedFigure); p.x -= size().width/2 + fOriginX; p.y -= size().height/2 + fOriginY; if (p.x != 0 || p.y != 0) { willChange(); basicMoveBy(p.x, p.y); changed(); } } </DeepExtract>
17
JHotDraw5.2
public void mouseDown(MouseEvent e, int x, int y) { if (e.getClickCount() >= 2) { fScribble = null; editor().toolDone(); } else { int x1 = e.getX(); int y1 = e.getY(); if (fScribble == null) { fScribble = new PolyLineFigure(x1, y1); view().add(fScribble); } else if (fLastX != x1 || fLastY != y1) fScribble.addPoint(x1, y1); fLastX = x1; fLastY = y1; } }
<DeepExtract> int x1 = e.getX(); int y1 = e.getY(); if (fScribble == null) { fScribble = new PolyLineFigure(x1, y1); view().add(fScribble); } else if (fLastX != x1 || fLastY != y1) fScribble.addPoint(x1, y1); fLastX = x1; fLastY = y1; </DeepExtract>
19
JHotDraw5.2
public void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view) { int dx = x-anchorX; int dy = y-anchorY; Rectangle r = fOwner.displayBox(); int max = r.width; int value = 2*(fRadius.x + dx); if (value < 0) value = 0; if (value > max) value = max; int rx = value; int ry = Geom.range(0, r.height, 2*(fRadius.y + dy)); fOwner.setArc(rx, ry); }
<DeepExtract> int max = r.width; int value = 2*(fRadius.x + dx); if (value < 0) value = 0; if (value > max) value = max; int rx = value; </DeepExtract>
12
JHotDraw5.2
public void draw(Graphics g) { g.setColor(getFrameColor()); Point p1, p2; for (int i = 0; i < fPoints.size()-1; i++) { p1 = (Point) fPoints.elementAt(i); p2 = (Point) fPoints.elementAt(i+1); drawLine(g, p1.x, p1.y, p2.x, p2.y); } if (getStartDecoration() != null) { Point p11 = (Point)fPoints.elementAt(0); Point p21 = (Point)fPoints.elementAt(1); getStartDecoration().draw(g, p11.x, p11.y, p21.x, p21.y); } if (getEndDecoration() != null) { Point p3 = (Point)fPoints.elementAt(fPoints.size()-2); Point p4 = (Point)fPoints.elementAt(fPoints.size()-1); getEndDecoration().draw(g, p4.x, p4.y, p3.x, p3.y); } }
<DeepExtract> if (getStartDecoration() != null) { Point p11 = (Point)fPoints.elementAt(0); Point p21 = (Point)fPoints.elementAt(1); getStartDecoration().draw(g, p11.x, p11.y, p21.x, p21.y); } if (getEndDecoration() != null) { Point p3 = (Point)fPoints.elementAt(fPoints.size()-2); Point p4 = (Point)fPoints.elementAt(fPoints.size()-1); getEndDecoration().draw(g, p4.x, p4.y, p3.x, p3.y); } </DeepExtract>
17
JHotDraw5.2
public void write(StorableOutput dw) { super.write(dw); dw.writeInt(fPoints.size()); Enumeration k = fPoints.elements(); while (k.hasMoreElements()) { Point p = (Point) k.nextElement(); dw.writeInt(p.x); dw.writeInt(p.y); } dw.writeStorable(fStartDecoration); dw.writeStorable(fEndDecoration); dw.writeInt(fFrameColor.getRed()); dw.writeInt(fFrameColor.getGreen()); dw.writeInt(fFrameColor.getBlue()); }
<DeepExtract> dw.writeInt(fFrameColor.getRed()); dw.writeInt(fFrameColor.getGreen()); dw.writeInt(fFrameColor.getBlue()); </DeepExtract>
13
JHotDraw5.2
public void execute() { Iconkit r = Iconkit.instance(); r.registerImage(fImage); r.loadRegisteredImages((Component)fView); Image image = r.getImage(fImage); ImageFigure figure = new ImageFigure(image, fImage, fView.lastClick()); fView.add(figure); fView.clearSelection(); fView.addToSelection(figure); fView.checkDamage(); }
<DeepExtract> Iconkit r = Iconkit.instance(); r.registerImage(fImage); r.loadRegisteredImages((Component)fView); Image image = r.getImage(fImage); </DeepExtract>
9
JHotDraw5.2
public void execute() { Vector selected = fView.selectionZOrdered(); Drawing drawing = fView.drawing(); if (selected.size() > 0) { fView.clearSelection(); drawing.orphanAll(selected); GroupFigure group = new GroupFigure(); Enumeration k = selected.elements(); while (k.hasMoreElements()) group.add((Figure) k.nextElement()); fView.addToSelection(drawing.add(group)); } fView.checkDamage(); }
<DeepExtract> Enumeration k = selected.elements(); while (k.hasMoreElements()) group.add((Figure) k.nextElement()); </DeepExtract>
13
JHotDraw5.2
public void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view) { LineConnection line = ownerConnection(); Point p1 = line.pointAt(fSegment); Point p2 = line.pointAt(fSegment+1); int ddx = x - fLastX; int ddy = y - fLastY; Point np1; Point np2; if (isVertical(p1, p2)) { int x1 = p1.x + ddx; LineConnection line1 = ownerConnection(); Figure startFigure = line1.start().owner(); Figure endFigure = line1.end().owner(); Rectangle start = startFigure.displayBox(); Rectangle end = endFigure.displayBox(); Insets i1 = startFigure.connectionInsets(); Insets i2 = endFigure.connectionInsets(); int r1x, r1width, r2x, r2width; r1x = start.x + i1.left; r1width = start.width - i1.left - i1.right-1; r2x = end.x + i2.left; r2width = end.width - i2.left - i2.right-1; if (fSegment == 0) x1 = Geom.range(r1x, r1x + r1width, x1); if (fSegment == line1.pointCount()-2) x1 = Geom.range(r2x, r2x + r2width, x1); int cx = x1; np1 = new Point(cx, p1.y); np2 = new Point(cx, p2.y); } else { int cy = constrainY(p1.y + ddy); np1 = new Point(p1.x, cy); np2 = new Point(p2.x, cy); } line.setPointAt(np1, fSegment); line.setPointAt(np2, fSegment+1); fLastX = x; fLastY = y; }
<DeepExtract> int x1 = p1.x + ddx; LineConnection line1 = ownerConnection(); Figure startFigure = line1.start().owner(); Figure endFigure = line1.end().owner(); Rectangle start = startFigure.displayBox(); Rectangle end = endFigure.displayBox(); Insets i1 = startFigure.connectionInsets(); Insets i2 = endFigure.connectionInsets(); int r1x, r1width, r2x, r2width; r1x = start.x + i1.left; r1width = start.width - i1.left - i1.right-1; r2x = end.x + i2.left; r2width = end.width - i2.left - i2.right-1; if (fSegment == 0) x1 = Geom.range(r1x, r1x + r1width, x1); if (fSegment == line1.pointCount()-2) x1 = Geom.range(r2x, r2x + r2width, x1); int cx = x1; </DeepExtract>
41
JHotDraw5.2
private int constrainX(int x) { LineConnection line = ownerConnection(); Figure startFigure = line.start().owner(); Figure endFigure = line.end().owner(); Rectangle start = startFigure.displayBox(); Rectangle end = endFigure.displayBox(); Insets i1 = startFigure.connectionInsets(); Insets i2 = endFigure.connectionInsets(); int r1x, r1width, r2x, r2width; r1x = start.x + i1.left; r1width = start.width - i1.left - i1.right-1; r2x = end.x + i2.left; r2width = end.width - i2.left - i2.right-1; if (fSegment == 0) { int max = r1x + r1width; int value = x; if (value < r1x) value = r1x; if (value > max) value = max; x = value; } if (fSegment == line.pointCount()-2) x = Geom.range(r2x, r2x + r2width, x); return x; }
<DeepExtract> int max = r1x + r1width; int value = x; if (value < r1x) value = r1x; if (value > max) value = max; x = value; </DeepExtract>
27
JHotDraw5.2
private int constrainY(int y) { LineConnection line = ownerConnection(); Figure startFigure = line.start().owner(); Figure endFigure = line.end().owner(); Rectangle start = startFigure.displayBox(); Rectangle end = endFigure.displayBox(); Insets i1 = startFigure.connectionInsets(); Insets i2 = endFigure.connectionInsets(); int r1y, r1height, r2y, r2height; r1y = start.y + i1.top; r1height = start.height - i1.top - i1.bottom-1; r2y = end.y + i2.top; r2height = end.height - i2.top - i2.bottom-1; if (fSegment == 0) { int max = r1y + r1height; int value = y; if (value < r1y) value = r1y; if (value > max) value = max; y = value; } if (fSegment == line.pointCount()-2) y = Geom.range(r2y, r2y + r2height, y); return y; }
<DeepExtract> int max = r1y + r1height; int value = y; if (value < r1y) value = r1y; if (value > max) value = max; y = value; </DeepExtract>
26
JHotDraw5.2
protected void updatePoints() { willChange(); Point start = startPoint(); Point end = endPoint(); fPoints.removeAllElements(); fPoints.addElement(start); if (start.x == end.x || start.y == end.y) { fPoints.addElement(end); } else { Rectangle r1 = start().owner().displayBox(); Rectangle r2 = end().owner().displayBox(); int x1, y1, x2, y2; int direction = 0; int vx = r2.x + r2.width/2 - (r1.x + r1.width/2); int vy = r2.y + r2.height/2 - (r1.y + r1.height/2); if (vy < vx && vx > -vy) direction = Geom.EAST; else if (vy > vx && vy > -vx) direction = Geom.NORTH; else if (vx < vy && vx < -vy) direction = Geom.WEST; else direction = Geom.SOUTH; int dir = direction; if (dir == Geom.NORTH || dir == Geom.SOUTH) { fPoints.addElement(new Point(start.x, (start.y + end.y)/2)); fPoints.addElement(new Point(end.x, (start.y + end.y)/2)); } else { fPoints.addElement(new Point((start.x + end.x)/2, start.y)); fPoints.addElement(new Point((start.x + end.x)/2, end.y)); } fPoints.addElement(end); } changed(); } }
<DeepExtract> int direction = 0; int vx = r2.x + r2.width/2 - (r1.x + r1.width/2); int vy = r2.y + r2.height/2 - (r1.y + r1.height/2); if (vy < vx && vx > -vy) direction = Geom.EAST; else if (vy > vx && vy > -vx) direction = Geom.NORTH; else if (vx < vy && vx < -vy) direction = Geom.WEST; else direction = Geom.SOUTH; int dir = direction; </DeepExtract>
38
JHotDraw5.2
public Object getAttribute(String name) { if (fAttributes != null) { if (fAttributes.hasDefined(name)) return fAttributes.get(name); } if (fgDefaultAttributes == null) initializeAttributes(); return fgDefaultAttributes.get(name); }
<DeepExtract> if (fgDefaultAttributes == null) initializeAttributes(); return fgDefaultAttributes.get(name); </DeepExtract>
7
JHotDraw5.2
public void write(StorableOutput dw) { if (getFillColor() != null) { Color color = getFillColor(); if (color != null) { dw.writeString("FillColor"); dw.writeInt(color.getRed()); dw.writeInt(color.getGreen()); dw.writeInt(color.getBlue()); } } else { dw.writeString("noFillColor"); } if (getBorderColor() != null) { FigureAttributes.writeColor(dw, "BorderColor", getBorderColor()); } else { dw.writeString("noBorderColor"); } }
<DeepExtract> Color color = getFillColor(); if (color != null) { dw.writeString("FillColor"); dw.writeInt(color.getRed()); dw.writeInt(color.getGreen()); dw.writeInt(color.getBlue()); } </DeepExtract>
19
JHotDraw5.2
protected JComponent createContents(StandardDrawingView view) { createLeftComponent(view); createRightComponent(view); if ((getLeftComponent() == null) && (getRightComponent() == null)) { return super.createContents(view); } else if (getLeftComponent() == null) { return getRightComponent(); } else if (getRightComponent() == null) { return getLeftComponent(); } else { JSplitPane dividedContents = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getLeftComponent(), getRightComponent()); dividedContents.setAlignmentX(LEFT_ALIGNMENT); dividedContents.setOneTouchExpandable(true); return dividedContents; } }
<DeepExtract> JSplitPane dividedContents = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, getLeftComponent(), getRightComponent()); dividedContents.setAlignmentX(LEFT_ALIGNMENT); dividedContents.setOneTouchExpandable(true); return dividedContents; </DeepExtract>
18
JHotDraw5.2
public void mouseDown(MouseEvent e, int x, int y) { x = e.getX(); y = e.getY(); if (e.getClickCount() >= 2) { if (fPolygon != null) { fPolygon.smoothPoints(); editor().toolDone(); } fPolygon = null; } else { int x1 = e.getX(); int y1 = e.getY(); if (fPolygon == null) { fPolygon = new PolygonFigure(x1, y1); view().add(fPolygon); fPolygon.addPoint(x1, y1); } else if (fLastX != x1 || fLastY != y1) fPolygon.addPoint(x1, y1); fLastX = x1; fLastY = y1; } }
<DeepExtract> int x1 = e.getX(); int y1 = e.getY(); if (fPolygon == null) { fPolygon = new PolygonFigure(x1, y1); view().add(fPolygon); fPolygon.addPoint(x1, y1); } else if (fLastX != x1 || fLastY != y1) fPolygon.addPoint(x1, y1); fLastX = x1; fLastY = y1; </DeepExtract>
26
JHotDraw5.2
public void scaleRotate(Point anchor, Polygon originalPolygon, Point p) { willChange(); long sx = 0; long sy = 0; int n1 = originalPolygon.npoints; for (int i1 = 0; i1 < n1; i1++) { sx += originalPolygon.xpoints[i1]; sy += originalPolygon.ypoints[i1]; } Point ctr = new Point((int)(sx/n1), (int)(sy/n1)); double anchorLen = Geom.length(ctr.x, ctr.y, anchor.x, anchor.y); if (anchorLen > 0.0) { double newLen = Geom.length(ctr.x, ctr.y, p.x, p.y); double ratio = newLen / anchorLen; double anchorAngle = Math.atan2(anchor.y - ctr.y, anchor.x - ctr.x); double newAngle = Math.atan2(p.y - ctr.y, p.x - ctr.x); double rotation = newAngle - anchorAngle; int n = originalPolygon.npoints; int[] xs = new int[n]; int[] ys = new int[n]; for (int i = 0; i < n; ++i) { int x = originalPolygon.xpoints[i]; int y = originalPolygon.ypoints[i]; double l = Geom.length(ctr.x, ctr.y, x, y) * ratio; double a = Math.atan2(y - ctr.y, x - ctr.x) + rotation; xs[i] = (int)(ctr.x + l * Math.cos(a) + 0.5); ys[i] = (int)(ctr.y + l * Math.sin(a) + 0.5); } fPoly = new Polygon(xs, ys, n); } changed(); }
<DeepExtract> long sx = 0; long sy = 0; int n1 = originalPolygon.npoints; for (int i1 = 0; i1 < n1; i1++) { sx += originalPolygon.xpoints[i1]; sy += originalPolygon.ypoints[i1]; } Point ctr = new Point((int)(sx/n1), (int)(sy/n1)); </DeepExtract>
36
JHotDraw5.2
public int splitSegment(int x, int y) { double dist = TOO_CLOSE; int best = -1; for (int i1 = 0; i1 < fPoly.npoints; i1++) { int n = (i1 + 1) % fPoly.npoints; double d = distanceFromLine(fPoly.xpoints[i1], fPoly.ypoints[i1], fPoly.xpoints[n], fPoly.ypoints[n], x, y); if (d < dist) { dist = d; best = i1; } } int i = best; if (i != -1) { insertPointAt(new Point(x, y), i+1); return i + 1; } else return -1; }
<DeepExtract> double dist = TOO_CLOSE; int best = -1; for (int i1 = 0; i1 < fPoly.npoints; i1++) { int n = (i1 + 1) % fPoly.npoints; double d = distanceFromLine(fPoly.xpoints[i1], fPoly.ypoints[i1], fPoly.xpoints[n], fPoly.ypoints[n], x, y); if (d < dist) { dist = d; best = i1; } } int i = best; </DeepExtract>
20
JHotDraw5.2
public static Point chop(Polygon poly, Point p) { long sx = 0; long sy = 0; int n = poly.npoints; for (int i1 = 0; i1 < n; i1++) { sx += poly.xpoints[i1]; sy += poly.ypoints[i1]; } Point ctr = new Point((int)(sx/n), (int)(sy/n)); int cx = -1; int cy = -1; long len = Long.MAX_VALUE; for (int i = 0; i < poly.npoints; ++i) { int nxt = (i + 1) % poly.npoints; Point chop = Geom.intersect(poly.xpoints[i], poly.ypoints[i], poly.xpoints[nxt], poly.ypoints[nxt], p.x, p.y, ctr.x, ctr.y); if (chop != null) { long cl = Geom.length2(chop.x, chop.y, p.x, p.y); if (cl < len) { len = cl; cx = chop.x; cy = chop.y; } } } { for (int i = 0; i < poly.npoints; ++i) { long l = Geom.length2(poly.xpoints[i], poly.ypoints[i], p.x, p.y); if (l < len) { len = l; cx = poly.xpoints[i]; cy = poly.ypoints[i]; } } } return new Point(cx, cy); } }
<DeepExtract> long sx = 0; long sy = 0; int n = poly.npoints; for (int i1 = 0; i1 < n; i1++) { sx += poly.xpoints[i1]; sy += poly.ypoints[i1]; } Point ctr = new Point((int)(sx/n), (int)(sy/n)); </DeepExtract>
48
JHotDraw5.2
public void draw(Graphics g) { Rectangle r = displayBox(); Polygon p1 = new Polygon(); p1.addPoint(r.x, r.y+r.height/2); p1.addPoint(r.x+r.width/2, r.y); p1.addPoint(r.x+r.width, r.y+r.height/2); p1.addPoint(r.x+r.width/2, r.y+r.height); Polygon p = p1; g.setColor(getFillColor()); g.fillPolygon(p); g.setColor(getFrameColor()); g.drawPolygon(p); }
<DeepExtract> Rectangle r = displayBox(); Polygon p1 = new Polygon(); p1.addPoint(r.x, r.y+r.height/2); p1.addPoint(r.x+r.width/2, r.y); p1.addPoint(r.x+r.width, r.y+r.height/2); p1.addPoint(r.x+r.width/2, r.y+r.height); Polygon p = p1; </DeepExtract>
11
JHotDraw5.2
public void mouseDown(MouseEvent e, int x, int y) { if (e.isPopupTrigger()) { Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } } else { super.mouseDown(e, x, y); handleMouseDown(e, x, y); } }
<DeepExtract> Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } </DeepExtract>
16
JHotDraw5.2
public void mouseUp(MouseEvent e, int x, int y) { if (e.isPopupTrigger()) { Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } } else if (e.getClickCount() == 2) { handleMouseDoubleClick(e, x, y); } else { super.mouseUp(e, x, y); handleMouseUp(e, x, y); handleMouseClick(e, x, y); } }
<DeepExtract> Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } </DeepExtract>
20
JHotDraw5.2
protected void handlePopupMenu(MouseEvent e, int x, int y) { Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { Component comp = e.getComponent(); Object attribute1 = figure.getAttribute(Figure.POPUP_MENU); if ((attribute1 != null) && (attribute1 instanceof JPopupMenu)) { JPopupMenu popup = (JPopupMenu)attribute1; if (popup instanceof PopupMenuFigureSelection) { ((PopupMenuFigureSelection)popup).setSelectedFigure(figure); } Point newLocation = new Point(e.getX(), e.getY()); adjustOffsets(comp.getParent(), newLocation); popup.setLocation(newLocation); popup.setInvoker(comp); popup.setVisible(true); } } } }
<DeepExtract> Component comp = e.getComponent(); Object attribute1 = figure.getAttribute(Figure.POPUP_MENU); if ((attribute1 != null) && (attribute1 instanceof JPopupMenu)) { JPopupMenu popup = (JPopupMenu)attribute1; if (popup instanceof PopupMenuFigureSelection) { ((PopupMenuFigureSelection)popup).setSelectedFigure(figure); } Point newLocation = new Point(e.getX(), e.getY()); adjustOffsets(comp.getParent(), newLocation); popup.setLocation(newLocation); popup.setInvoker(comp); popup.setVisible(true); } </DeepExtract>
23
JHotDraw5.2
public void promptOpen() { toolDone(); JFileChooser openDialog = createOpenFileChooser(); getStorageFormatManager().registerFileFilters(openDialog); if (openDialog.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { StorageFormat foundFormat = getStorageFormatManager().findStorageFormat(openDialog.getFileFilter()); if (foundFormat != null) { String file = openDialog.getSelectedFile().getAbsolutePath(); try { Drawing restoredDrawing = foundFormat.restore(file); if (restoredDrawing != null) { newWindow(); setDrawing(restoredDrawing); setDrawingTitle(file); } else { showStatus("Unknown file type: could not open file '" + file + "'"); } } catch (IOException e) { showStatus("Error: " + e); } } else { showStatus("Not a valid file format: " + openDialog.getFileFilter().getDescription()); } } }
<DeepExtract> String file = openDialog.getSelectedFile().getAbsolutePath(); try { Drawing restoredDrawing = foundFormat.restore(file); if (restoredDrawing != null) { newWindow(); setDrawing(restoredDrawing); setDrawingTitle(file); } else { showStatus("Unknown file type: could not open file '" + file + "'"); } } catch (IOException e) { showStatus("Error: " + e); } </DeepExtract>
25
JHotDraw5.2
public void promptSaveAs() { toolDone(); JFileChooser saveDialog1 = new JFileChooser(); saveDialog1.setDialogTitle("Save File..."); JFileChooser saveDialog = saveDialog1; getStorageFormatManager().registerFileFilters(saveDialog); if (saveDialog.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { StorageFormat foundFormat = getStorageFormatManager().findStorageFormat(saveDialog.getFileFilter()); if (foundFormat != null) { saveDrawing(foundFormat, saveDialog.getSelectedFile().getAbsolutePath()); } else { showStatus("Not a valid file format: " + saveDialog.getFileFilter().getDescription()); } } }
<DeepExtract> JFileChooser saveDialog1 = new JFileChooser(); saveDialog1.setDialogTitle("Save File..."); JFileChooser saveDialog = saveDialog1; </DeepExtract>
15
JHotDraw5.2
public void init() { fIconkit = new Iconkit(this); getContentPane().setLayout(new BorderLayout()); fView = createDrawingView(); JPanel attributes = createAttributesPanel(); attributes.add(new JLabel("Fill")); fFillColor = createColorChoice("FillColor"); attributes.add(fFillColor); attributes.add(new JLabel("Text")); fTextColor = createColorChoice("TextColor"); attributes.add(fTextColor); attributes.add(new JLabel("Pen")); fFrameColor = createColorChoice("FrameColor"); attributes.add(fFrameColor); attributes.add(new JLabel("Arrow")); CommandChoice choice = new CommandChoice(); fArrowChoice = choice; choice.addItem(new ChangeAttributeCommand("none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), fView)); choice.addItem(new ChangeAttributeCommand("at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), fView)); choice.addItem(new ChangeAttributeCommand("at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), fView)); choice.addItem(new ChangeAttributeCommand("at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), fView)); attributes.add(fArrowChoice); attributes.add(new JLabel("Font")); fFontChoice = createFontChoice(); attributes.add(fFontChoice); getContentPane().add("North", attributes); JPanel toolPanel = createToolPalette(); createTools(toolPanel); getContentPane().add("West", toolPanel); getContentPane().add("Center", fView); JPanel buttonPalette = createButtonPanel(); createButtons(buttonPalette); getContentPane().add("South", buttonPalette); initDrawing(); setupAttributes(); }
<DeepExtract> attributes.add(new JLabel("Fill")); fFillColor = createColorChoice("FillColor"); attributes.add(fFillColor); attributes.add(new JLabel("Text")); fTextColor = createColorChoice("TextColor"); attributes.add(fTextColor); attributes.add(new JLabel("Pen")); fFrameColor = createColorChoice("FrameColor"); attributes.add(fFrameColor); attributes.add(new JLabel("Arrow")); CommandChoice choice = new CommandChoice(); fArrowChoice = choice; choice.addItem(new ChangeAttributeCommand("none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), fView)); choice.addItem(new ChangeAttributeCommand("at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), fView)); choice.addItem(new ChangeAttributeCommand("at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), fView)); choice.addItem(new ChangeAttributeCommand("at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), fView)); attributes.add(fArrowChoice); attributes.add(new JLabel("Font")); fFontChoice = createFontChoice(); attributes.add(fFontChoice); </DeepExtract>
46
JHotDraw5.2
protected void createAttributeChoices(JPanel panel) { panel.add(new JLabel("Fill")); fFillColor = createColorChoice("FillColor"); panel.add(fFillColor); panel.add(new JLabel("Text")); fTextColor = createColorChoice("TextColor"); panel.add(fTextColor); panel.add(new JLabel("Pen")); fFrameColor = createColorChoice("FrameColor"); panel.add(fFrameColor); panel.add(new JLabel("Arrow")); CommandChoice choice = new CommandChoice(); fArrowChoice = choice; choice.addItem(new ChangeAttributeCommand("none", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_NONE), fView)); choice.addItem(new ChangeAttributeCommand("at Start", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_START), fView)); choice.addItem(new ChangeAttributeCommand("at End", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_END), fView)); choice.addItem(new ChangeAttributeCommand("at Both", "ArrowMode", new Integer(PolyLineFigure.ARROW_TIP_BOTH), fView)); panel.add(fArrowChoice); panel.add(new JLabel("Font")); CommandChoice choice1 = new CommandChoice(); String fonts[] = Toolkit.getDefaultToolkit().getFontList(); for (int i = 0; i < fonts.length; i++) choice1.addItem(new ChangeAttributeCommand(fonts[i], "FontName", fonts[i], fView)); fFontChoice = choice1; panel.add(fFontChoice); }
<DeepExtract> CommandChoice choice1 = new CommandChoice(); String fonts[] = Toolkit.getDefaultToolkit().getFontList(); for (int i = 0; i < fonts.length; i++) choice1.addItem(new ChangeAttributeCommand(fonts[i], "FontName", fonts[i], fView)); fFontChoice = choice1; </DeepExtract>
28
JHotDraw5.2
protected void loadDrawing(String param) { if (param == fgUntitled) { fDrawing.release(); initDrawing(); return; } String filename = getParameter(param); if (filename != null) { toolDone(); String type = guessType(filename); if (type.equals("storable")) readFromStorableInput(filename); else if (type.equals("serialized")) readFromObjectInput(filename); else showStatus("Unknown file type"); } }
<DeepExtract> toolDone(); String type = guessType(filename); if (type.equals("storable")) readFromStorableInput(filename); else if (type.equals("serialized")) readFromObjectInput(filename); else showStatus("Unknown file type"); </DeepExtract>
17
JHotDraw5.2
private void readDrawing(String filename) { toolDone(); String type = guessType(filename); if (type.equals("storable")) readFromStorableInput(filename); else if (type.equals("serialized")) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); ObjectInput input = new ObjectInputStream(stream); fDrawing.release(); fDrawing = (Drawing)input.readObject(); fView.setDrawing(fDrawing); } catch (IOException e) { initDrawing(); showStatus("Error: " + e); } catch (ClassNotFoundException e) { initDrawing(); showStatus("Class not found: " + e); } } else showStatus("Unknown file type"); } private void readFromStorableInput(String filename) {
<DeepExtract> try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); ObjectInput input = new ObjectInputStream(stream); fDrawing.release(); fDrawing = (Drawing)input.readObject(); fView.setDrawing(fDrawing); } catch (IOException e) { initDrawing(); showStatus("Error: " + e); } catch (ClassNotFoundException e) { initDrawing(); showStatus("Class not found: " + e); } </DeepExtract>
22
JHotDraw5.2
private void readFromStorableInput(String filename) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); StorableInput input = new StorableInput(stream); fDrawing.release(); fDrawing = (Drawing)input.readStorable(); fView.setDrawing(fDrawing); } catch (IOException e) { fDrawing = createDrawing(); fView.setDrawing(fDrawing); toolDone(); showStatus("Error:"+e); } }
<DeepExtract> fDrawing = createDrawing(); fView.setDrawing(fDrawing); toolDone(); </DeepExtract>
14
JHotDraw5.2
private void readFromObjectInput(String filename) { try { URL url = new URL(getCodeBase(), filename); InputStream stream = url.openStream(); ObjectInput input = new ObjectInputStream(stream); fDrawing.release(); fDrawing = (Drawing)input.readObject(); fView.setDrawing(fDrawing); } catch (IOException e) { fDrawing = createDrawing(); fView.setDrawing(fDrawing); toolDone(); showStatus("Error: " + e); } catch (ClassNotFoundException e) { initDrawing(); showStatus("Class not found: " + e); } }
<DeepExtract> fDrawing = createDrawing(); fView.setDrawing(fDrawing); toolDone(); </DeepExtract>
16
JHotDraw5.2
public Object clone() { Domain clone; checkConsistency(curInd); clone = new Domain(new Date(release.getTime()), new Date(deadline.getTime())); DomainAction d; ManualAction m; Template t; Date[] dates; for (int i = 0; i < curInd; i++) { d = actions.get(i); if (templateDates.containsKey(i)) { t = (Template) d; dates = templateDates.get(i); if (dates[0] != null && dates[1] != null) clone.addTemplate(t, new Date(dates[0].getTime()), new Date(dates[1].getTime()), t.getAppliedAction()); else if (dates[0] == null && dates[1] != null) clone.addTemplate(t, null, new Date(dates[1].getTime()), t.getAppliedAction()); else if (dates[0] != null && dates[1] == null) clone.addTemplate(t, new Date(dates[0].getTime()), null, t.getAppliedAction()); else clone.addTemplate(t, null, null, t.getAppliedAction()); } else { m = (ManualAction) d; clone.addManualAction((ManualAction) m.clone()); } } clone.listeners = null; return clone; }
<DeepExtract> if (dates[0] != null && dates[1] != null) clone.addTemplate(t, new Date(dates[0].getTime()), new Date(dates[1].getTime()), t.getAppliedAction()); else if (dates[0] == null && dates[1] != null) clone.addTemplate(t, null, new Date(dates[1].getTime()), t.getAppliedAction()); else if (dates[0] != null && dates[1] == null) clone.addTemplate(t, new Date(dates[0].getTime()), null, t.getAppliedAction()); else clone.addTemplate(t, null, null, t.getAppliedAction()); </DeepExtract>
35
myplanner-data-src
public static Task[] getPeriodicPartsOf(Task t, Task[] expandedTasks) { int periods = 0; for (int i = 0; i < expandedTasks.length; i++) { if (expandedTasks[i].name().equals(t.name())) periods++; } Task[] instances = new Task[periods]; int k = 0; for (int i = 0; i < expandedTasks.length; i++) { if (expandedTasks[i].name().equals(t.name())) { instances[k] = expandedTasks[i]; k++; } } return sortTasks(instances); }
<DeepExtract> for (int i = 0; i < expandedTasks.length; i++) { if (expandedTasks[i].name().equals(t.name())) periods++; } </DeepExtract>
14
myplanner-data-src
public Object clone() { TaskManager clone; try { clone = (TaskManager)super.clone(); ArrayList<Task> t = new ArrayList<Task>(); Task[] orTasks = tasks(); for (int i = 0; i < orTasks.length; i++) { t.add(orTasks[i]); } clone.setTasks(t); ArrayList<Solution> s = new ArrayList<Solution>(); if (pastSolutions != null) { for (int i = 0; i < pastSolutions.size(); i++) { s.add(pastSolutions.get(i)); } } clone.setPastSolutions(s); return clone; } catch (CloneNotSupportedException e) { return null; } }
<DeepExtract> ArrayList<Solution> s = new ArrayList<Solution>(); if (pastSolutions != null) { for (int i = 0; i < pastSolutions.size(); i++) { s.add(pastSolutions.get(i)); } } </DeepExtract>
20
myplanner-data-src
public static Task[] sortTasks(Task[] tasks) { Task[] sorted = new Task[tasks.length]; boolean[] ord = new boolean[tasks.length]; int num = 0; int min = 0; for (int i = 0; i < ord.length; i++) { ord[i] = false; } while (num < tasks.length) { min = Integer.MAX_VALUE; for (int i = 0; i < tasks.length; i++) { if ((!ord[i] && min == Integer.MAX_VALUE) || (!ord[i] && tasks[i].domain().releaseDate().compareTo(tasks[min].domain(). releaseDate()) < 0)) { min = i; } } ord[min] = true; sorted[num] = tasks[min]; num++; } return sorted; }
<DeepExtract> min = Integer.MAX_VALUE; for (int i = 0; i < tasks.length; i++) { if ((!ord[i] && min == Integer.MAX_VALUE) || (!ord[i] && tasks[i].domain().releaseDate().compareTo(tasks[min].domain(). releaseDate()) < 0)) { min = i; } } </DeepExtract>
22
myplanner-data-src
protected TestResult start(String args[]) throws Exception { String testCase= ""; boolean wait= false; for (int i= 0; i < args.length; i++) { if (args[i].equals("-wait")) wait= true; else if (args[i].equals("-c")) testCase= extractClassName(args[++i]); else if (args[i].equals("-v")) System.err.println("JUnit "+Version.id()+" by Kent Beck and Erich Gamma"); else testCase= args[i]; } if (testCase.equals("")) throw new Exception("Usage: TestRunner [-wait] testCaseName, where name is the name of the TestCase class"); try { Test suite= getTest(testCase); TestResult result= createTestResult(); result.addListener(fPrinter); long startTime= System.currentTimeMillis(); suite.run(result); long endTime= System.currentTimeMillis(); long runTime= endTime-startTime; fPrinter.print(result, runTime); pause(wait); return result; } catch(Exception e) { throw new Exception("Could not create and run test suite: "+e); } }
<DeepExtract> TestResult result= createTestResult(); result.addListener(fPrinter); long startTime= System.currentTimeMillis(); suite.run(result); long endTime= System.currentTimeMillis(); long runTime= endTime-startTime; fPrinter.print(result, runTime); pause(wait); return result; </DeepExtract>
33
junit3.8
synchronized void print(TestResult result, long runTime) { printHeader(runTime); printErrors(result); printFailures(result); if (result.wasSuccessful()) { getWriter().println(); getWriter().print("OK"); getWriter().println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")"); } else { getWriter().println(); getWriter().println("FAILURES!!!"); getWriter().println("Tests run: "+result.runCount()+ ", Failures: "+result.failureCount()+ ", Errors: "+result.errorCount()); } getWriter().println(); }
<DeepExtract> if (result.wasSuccessful()) { getWriter().println(); getWriter().print("OK"); getWriter().println (" (" + result.runCount() + " test" + (result.runCount() == 1 ? "": "s") + ")"); } else { getWriter().println(); getWriter().println("FAILURES!!!"); getWriter().println("Tests run: "+result.runCount()+ ", Failures: "+result.failureCount()+ ", Errors: "+result.errorCount()); } getWriter().println(); </DeepExtract>
16
junit3.8
public void testFailed(final int status, final Test test, final Throwable t) { SwingUtilities.invokeLater( new Runnable() { public void run() { switch (status) { case TestRunListener.STATUS_ERROR: {fCounterPanel.setErrorValue(fTestResult.errorCount()); fFailures.addElement(new TestFailure(test, t)); if (fFailures.size() == 1) revealFailure(test); break;} case TestRunListener.STATUS_FAILURE: fCounterPanel.setFailureValue(fTestResult.failureCount()); appendFailure("Failure", test, t); break; } } } ); } public void testStarted(String testName) { postInfo("Running: "+testName);
<DeepExtract> fFailures.addElement(new TestFailure(test, t)); if (fFailures.size() == 1) revealFailure(test); </DeepExtract>
20
junit3.8
private void addToHistory(final String suite) { for (int i= 0; i < fSuiteCombo.getItemCount(); i++) { if (suite.equals(fSuiteCombo.getItemAt(i))) { fSuiteCombo.removeItemAt(i); fSuiteCombo.insertItemAt(suite, 0); fSuiteCombo.setSelectedIndex(0); return; } } fSuiteCombo.insertItemAt(suite, 0); fSuiteCombo.setSelectedIndex(0); int historyLength= getPreference("maxhistory", HISTORY_LENGTH); if (historyLength < 1) historyLength= 1; for (int i= fSuiteCombo.getItemCount()-1; i > historyLength-1; i--) fSuiteCombo.removeItemAt(i); }
<DeepExtract> int historyLength= getPreference("maxhistory", HISTORY_LENGTH); if (historyLength < 1) historyLength= 1; for (int i= fSuiteCombo.getItemCount()-1; i > historyLength-1; i--) fSuiteCombo.removeItemAt(i); </DeepExtract>
15
junit3.8
protected JPanel createFailedPanel() { JPanel failedPanel= new JPanel(new GridLayout(0, 1, 0, 2)); fRerunButton= new JButton("Run"); fRerunButton.setEnabled(false); fRerunButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { TestRunView view= (TestRunView)fTestRunViews.elementAt(fTestViewTab.getSelectedIndex()); Test rerunTest= view.getSelectedTest(); if (rerunTest != null) rerunTest(rerunTest); } } ); failedPanel.add(fRerunButton); return failedPanel; }
<DeepExtract> TestRunView view= (TestRunView)fTestRunViews.elementAt(fTestViewTab.getSelectedIndex()); Test rerunTest= view.getSelectedTest(); if (rerunTest != null) rerunTest(rerunTest); </DeepExtract>
15
junit3.8
protected JMenu createJUnitMenu() { JMenu menu= new JMenu("JUnit"); menu.setMnemonic('J'); JMenuItem mi1= new JMenuItem("About..."); mi1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { about(); } } ); mi1.setMnemonic('A'); menu.add(mi1); menu.addSeparator(); JMenuItem mi2= new JMenuItem(" Exit "); mi2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { fFrame.dispose(); try { saveHistory(); } catch (IOException e) { System.out.println("Couldn't save test run history"); } System.exit(0); } } ); mi2.setMnemonic('x'); menu.add(mi2); return menu; }
<DeepExtract> fFrame.dispose(); try { saveHistory(); } catch (IOException e) { System.out.println("Couldn't save test run history"); } System.exit(0); </DeepExtract>
32
junit3.8
protected JFrame createFrame(String title) { JFrame frame= new JFrame("JUnit"); Image icon= loadFrameIcon(); if (icon != null) frame.setIconImage(icon); frame.getContentPane().setLayout(new BorderLayout(0, 0)); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { fFrame.dispose(); try { saveHistory(); } catch (IOException e1) { System.out.println("Couldn't save test run history"); } System.exit(0); } } ); return frame; }
<DeepExtract> fFrame.dispose(); try { saveHistory(); } catch (IOException e1) { System.out.println("Couldn't save test run history"); } System.exit(0); </DeepExtract>
20
junit3.8
protected JButton createQuitButton() { JButton quit= new JButton(" Exit "); quit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fFrame.dispose(); try { saveHistory(); } catch (IOException e1) { System.out.println("Couldn't save test run history"); } System.exit(0); } } ); return quit;
<DeepExtract> fFrame.dispose(); try { saveHistory(); } catch (IOException e1) { System.out.println("Couldn't save test run history"); } System.exit(0); </DeepExtract>
15
junit3.8
protected JButton createRunButton() { JButton run= new JButton("Run"); run.setEnabled(true); run.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (fRunner != null) { fTestResult.stop(); } else { setLoading(shouldReload()); reset(); showInfo("Load Test Case..."); final String suiteName= getSuiteText(); final Test testSuite= getTest(suiteName); if (testSuite != null) { addToHistory(suiteName); doRunTest(testSuite); } } } } ); return run; }
<DeepExtract> if (fRunner != null) { fTestResult.stop(); } else { setLoading(shouldReload()); reset(); showInfo("Load Test Case..."); final String suiteName= getSuiteText(); final Test testSuite= getTest(suiteName); if (testSuite != null) { addToHistory(suiteName); doRunTest(testSuite); } } </DeepExtract>
22
junit3.8
protected JComboBox createSuiteCombo() { JComboBox combo= new JComboBox(); combo.setEditable(true); combo.setLightWeightPopupEnabled(false); combo.getEditor().getEditorComponent().addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { textChanged(); if (e.getKeyChar() == KeyEvent.VK_ENTER){ if (fRunner != null) { fTestResult.stop(); } else { setLoading(shouldReload()); reset(); showInfo("Load Test Case..."); final String suiteName= getSuiteText(); final Test testSuite= getTest(suiteName); if (testSuite != null) { addToHistory(suiteName); doRunTest(testSuite); } } }} } ); try { loadHistory(combo); } catch (IOException e) { } combo.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { textChanged(); } } } ); return combo; }
<DeepExtract> if (fRunner != null) { fTestResult.stop(); } else { setLoading(shouldReload()); reset(); showInfo("Load Test Case..."); final String suiteName= getSuiteText(); final Test testSuite= getTest(suiteName); if (testSuite != null) { addToHistory(suiteName); doRunTest(testSuite); } } </DeepExtract>
40
junit3.8
protected JFrame createUI(String suiteName) { JFrame frame= createFrame("JUnit"); JMenuBar mb= new JMenuBar(); createMenus(mb); frame.setJMenuBar(mb); JLabel suiteLabel= new JLabel("Test class name:"); fSuiteCombo= createSuiteCombo(); fRun= createRunButton(); frame.getRootPane().setDefaultButton(fRun); Component browseButton= createBrowseButton(); fUseLoadingRunner= createUseLoaderCheckBox(); fProgressIndicator= new ProgressBar(); fCounterPanel= createCounterPanel(); fFailures= new DefaultListModel(); fTestViewTab= createTestRunViews(); JPanel failedPanel= createFailedPanel(); fFailureView= createFailureDetailView(); JScrollPane tracePane= new JScrollPane(fFailureView.getComponent(), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); fStatusLine= createStatusLine(); fQuitButton= createQuitButton(); fLogo= createLogo(); JPanel panel= new JPanel(new GridBagLayout()); int fill = GridBagConstraints.HORIZONTAL; GridBagConstraints c= new GridBagConstraints(); c.gridx= 0; c.gridy= 0; c.gridwidth= 2; c.anchor= GridBagConstraints.WEST; c.weightx= 1.0; c.fill= fill; if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty= 1.0; c.insets= new Insets(0 == 0 ? 10 : 0, 0 == 0 ? 10 : GAP, GAP, GAP); panel.add(suiteLabel, c); addGrid(panel, fSuiteCombo, 0, 1, 1, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, browseButton, 1, 1, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.WEST); addGrid(panel, fRun, 2, 1, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER); addGrid(panel, fUseLoadingRunner, 0, 2, 3, GridBagConstraints.NONE, 1.0, GridBagConstraints.WEST); addGrid(panel, fProgressIndicator, 0, 3, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, fLogo, 2, 3, 1, GridBagConstraints.NONE, 0.0, GridBagConstraints.NORTH); addGrid(panel, fCounterPanel, 0, 4, 2, GridBagConstraints.NONE, 0.0, GridBagConstraints.WEST); addGrid(panel, new JSeparator(), 0, 5, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); addGrid(panel, new JLabel("Results:"), 0, 6, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.WEST); JSplitPane splitter= new JSplitPane(JSplitPane.VERTICAL_SPLIT, fTestViewTab, tracePane); addGrid(panel, splitter, 0, 7, 2, GridBagConstraints.BOTH, 1.0, GridBagConstraints.WEST); addGrid(panel, failedPanel, 2, 7, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.NORTH); addGrid(panel, fStatusLine, 0, 9, 2, GridBagConstraints.HORIZONTAL, 1.0, GridBagConstraints.CENTER); addGrid(panel, fQuitButton, 2, 9, 1, GridBagConstraints.HORIZONTAL, 0.0, GridBagConstraints.CENTER); frame.setContentPane(panel); frame.pack(); frame.setLocation(200, 200); return frame; }
<DeepExtract> int fill = GridBagConstraints.HORIZONTAL; GridBagConstraints c= new GridBagConstraints(); c.gridx= 0; c.gridy= 0; c.gridwidth= 2; c.anchor= GridBagConstraints.WEST; c.weightx= 1.0; c.fill= fill; if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty= 1.0; c.insets= new Insets(0 == 0 ? 10 : 0, 0 == 0 ? 10 : GAP, GAP, GAP); panel.add(suiteLabel, c); </DeepExtract>
67
junit3.8
synchronized public void runSuite() { if (fRunner != null) { fTestResult.stop(); } else { setLoading(shouldReload()); fCounterPanel.reset(); fProgressIndicator.reset(); fRerunButton.setEnabled(false); fFailureView.clear(); fFailures.clear(); showInfo("Load Test Case..."); final String suiteName= getSuiteText(); final Test testSuite= getTest(suiteName); if (testSuite != null) { addToHistory(suiteName); doRunTest(testSuite); } } }
<DeepExtract> fCounterPanel.reset(); fProgressIndicator.reset(); fRerunButton.setEnabled(false); fFailureView.clear(); fFailures.clear(); </DeepExtract>
17
junit3.8
synchronized protected void runTest(final Test testSuite) { if (fRunner != null) { fTestResult.stop(); } else { fCounterPanel.reset(); fProgressIndicator.reset(); fRerunButton.setEnabled(false); fFailureView.clear(); fFailures.clear(); if (testSuite != null) { doRunTest(testSuite); } } }
<DeepExtract> fCounterPanel.reset(); fProgressIndicator.reset(); fRerunButton.setEnabled(false); fFailureView.clear(); fFailures.clear(); </DeepExtract>
12
junit3.8
public void terminate() { fFrame.dispose(); try { BufferedWriter bw= new BufferedWriter(new FileWriter(getSettingsFile())); try { for (int i= 0; i < fSuiteCombo.getItemCount(); i++) { String testsuite= fSuiteCombo.getItemAt(i).toString(); bw.write(testsuite, 0, testsuite.length()); bw.newLine(); } } finally { bw.close(); } } catch (IOException e) { System.out.println("Couldn't save test run history"); } System.exit(0); }
<DeepExtract> BufferedWriter bw= new BufferedWriter(new FileWriter(getSettingsFile())); try { for (int i= 0; i < fSuiteCombo.getItemCount(); i++) { String testsuite= fSuiteCombo.getItemAt(i).toString(); bw.write(testsuite, 0, testsuite.length()); bw.newLine(); } } finally { bw.close(); } </DeepExtract>
16
junit3.8
protected static Properties getPreferences() { if (fPreferences == null) { fPreferences= new Properties(); fPreferences.put("loading", "true"); fPreferences.put("filterstack", "true"); InputStream is= null; try { is= new FileInputStream(getPreferencesFile()); setPreferences(new Properties(getPreferences())); getPreferences().load(is); } catch (IOException e) { try { if (is != null) is.close(); } catch (IOException e1) { } } } return fPreferences; }
<DeepExtract> InputStream is= null; try { is= new FileInputStream(getPreferencesFile()); setPreferences(new Properties(getPreferences())); getPreferences().load(is); } catch (IOException e) { try { if (is != null) is.close(); } catch (IOException e1) { } } </DeepExtract>
18
junit3.8
protected void run(final TestCase test) { final int count= test.countTestCases(); synchronized(this) { fRunTests+= count; } for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { ((TestListener)e.nextElement()).startTest(test); } Protectable p= new Protectable() { public void protect() throws Throwable { test.runBare(); } }; runProtected(test, p); endTest(test); } /**
<DeepExtract> final int count= test.countTestCases(); synchronized(this) { fRunTests+= count; } for (Enumeration e= cloneListeners().elements(); e.hasMoreElements(); ) { ((TestListener)e.nextElement()).startTest(test); } </DeepExtract>
15
junit3.8
public void runProtected(final Test test, Protectable p) { try { p.protect(); } catch (AssertionFailedError e) { fFailures.addElement(new TestFailure(test, e)); for (Enumeration e1= cloneListeners().elements(); e1.hasMoreElements(); ) { ((TestListener)e1.nextElement()).addFailure(test, e); } } catch (ThreadDeath e) { throw e; } catch (Throwable e) { addError(test, e); } } /**
<DeepExtract> fFailures.addElement(new TestFailure(test, e)); for (Enumeration e1= cloneListeners().elements(); e1.hasMoreElements(); ) { ((TestListener)e1.nextElement()).addFailure(test, e); } </DeepExtract>
15
junit3.8
End of preview. Expand in Data Studio

Dataset Card for "benchmark-v1"

More Information needed

Downloads last month
13