/** * Try to find all element with the given name in the last active root-band. * * @param band * the band that is suspected to contain the element. * @param element * the element name. * @return the found element or null, if no element could be found. */ public static Element[] findAllElements( final Band band, final String element ) { if ( element == null ) { throw new NullPointerException( "Element name must not be null" ); } if ( band == null ) { throw new NullPointerException( "Band must not be null" ); } final ArrayList<Element> collector = new ArrayList<Element>(); if ( band.getName().equals( element ) ) { collector.add( band ); } performFindElement( band, element, collector ); return collector.toArray( new Element[collector.size()] ); }
/** * Returns a string representation of the band, useful mainly for debugging purposes. * * @return a string representation of this band. */ public String toString() { final StringBuilder b = new StringBuilder( 100 ); b.append( this.getClass().getName() ); b.append( "={name=\"" ); b.append( getName() ); b.append( "\", size=\"" ); b.append( getElementCount() ); b.append( "\", layout=\"" ); b.append( getStyle().getStyleProperty( BandStyleKeys.LAYOUT ) ); b.append( "\"}" ); return b.toString(); }
private boolean isEmptyRootBand( final Band band ) { if ( band.getName().startsWith( Band.ANONYMOUS_BAND_PREFIX ) == false ) { return false; } if ( band.getName().startsWith( Element.ANONYMOUS_ELEMENT_PREFIX ) == false ) { return false; } if ( band.getElementCount() != 0 ) { return false; } if ( band instanceof RootLevelBand ) { final RootLevelBand rlb = (RootLevelBand) band; if ( rlb.getSubReportCount() > 0 ) { return false; } } final ElementStyleSheet styleSheet = band.getStyle(); if ( isStyleSheetEmpty( styleSheet ) ) { return true; } return false; }
if ( band.getName().equals( element ) ) { return band;
if ( band.getName().startsWith( Band.ANONYMOUS_BAND_PREFIX ) || band.getName().startsWith( Element.ANONYMOUS_ELEMENT_PREFIX ) ) { writer.writeTag( ExtParserModule.NAMESPACE, tagName, XmlWriterSupport.OPEN ); } else { writer.writeTag( ExtParserModule.NAMESPACE, tagName, "name", band.getName(), XmlWriterSupport.OPEN );
public void testBandCreate() { Band b = new Band(); assertNotNull( b.getDataSource() ); assertNotNull( b.getStyle() ); assertNotNull( b.getName() ); assertTrue( b.isVisible() ); assertNull( b.getParent() ); assertNotNull( b.getElementArray() ); assertTrue( b.getElementCount() == 0 ); assertTrue( b.getElementType() instanceof BandType ); assertFalse( b.isPagebreakBeforePrint() ); assertFalse( b.isPagebreakAfterPrint() ); InstanceID id = new InstanceID(); b = new Band( id ); assertNotNull( b.getTreeLock() ); assertEquals( id, b.getTreeLock() ); assertTrue( b.getElementType() instanceof BandType ); assertFalse( b.isPagebreakBeforePrint() ); assertFalse( b.isPagebreakAfterPrint() ); b = new Band( true, true ); assertTrue( b.getElementType() instanceof BandType ); assertTrue( b.isPagebreakBeforePrint() ); assertTrue( b.isPagebreakAfterPrint() ); }
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() ); }