/** * Clones this band and all elements contained in this band. After the cloning the band is no longer connected to a * report definition. * * @return the clone of this band. */ public AbstractRootLevelBand clone() { final AbstractRootLevelBand rootLevelBand = (AbstractRootLevelBand) super.clone(); if ( rootLevelBand.subReports != null ) { rootLevelBand.subReports = (ArrayList<SubReport>) rootLevelBand.subReports.clone(); rootLevelBand.subReports.clear(); for ( int i = 0; i < subReports.size(); i++ ) { final SubReport report = subReports.get( i ); final SubReport clone = (SubReport) report.clone(); clone.setParent( rootLevelBand ); rootLevelBand.subReports.add( clone ); } } return rootLevelBand; }
public void testElementClone() throws CloneNotSupportedException { final Band band = new Band(); final Element e = new Element(); band.addElement( e ); assertNotNull( e.getParent() ); assertNotNull( e.getDataSource() ); assertNotNull( e.getStyle() ); assertNotNull( e.getName() ); assertTrue( e.isVisible() ); final Element clone = (Element) e.clone(); assertNull( clone.getParent() ); assertNotNull( clone.getDataSource() ); assertNotNull( clone.getStyle() ); assertNotNull( clone.getName() ); assertTrue( clone.isVisible() ); final Band clonedBand = (Band) band.clone(); assertNull( clonedBand.getParent() ); assertNotNull( clonedBand.getDataSource() ); assertNotNull( clonedBand.getStyle() ); assertNotNull( clonedBand.getName() ); assertTrue( clonedBand.isVisible() ); final Element clientElement = clonedBand.getElement( 0 ); assertNotNull( clientElement.getParent() ); assertNotNull( clientElement.getDataSource() ); assertNotNull( clientElement.getStyle() ); assertNotNull( clientElement.getName() ); assertTrue( clientElement.isVisible() ); assertEquals( clonedBand, clientElement.getParent() ); }