/************************************************************************** /* This class extends ItemCountFunction: it only counts items != null /* /* Copyright (c) 2004 by Bernhard Bablok (mail@bablokb.de) /* /* This program is free software; you can redistribute it and/or modify /* it under the terms of the GNU General Public License as published /* by the Free Software Foundation; either version 2 of the License or /* (at your option) any later version. /* /* This program is distributed in the hope that it will be useful, but /* WITHOUT ANY WARRANTY; without even the implied warranty of /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /* GNU General Public License for more details. /* /* You should have received a copy of the GNU General Public License /* along with this program; see the file COPYING. If not, write to /* the Free Software Foundation Inc., 59 Temple Place - Suite 330, /* Boston, MA 02111-1307 USA /**************************************************************************/ import org.jfree.report.function.*; import org.jfree.report.event.*; /** This class extends ItemCountFunction: it only counts items != null @version $Revision: 1.1 $ @author $Author: bablokb $ */ public class ItemNotNullCountFunction extends ItemCountFunction { public static final String FIELD_PROPERTY = "field"; ////////////////////////////////////////////////////////////////////////////// /** Returns the name of the field (possibly null) for this function. The item count is incremented for values != null of this field. @return the field name. */ public String getField() { return getProperty(FIELD_PROPERTY); } ////////////////////////////////////////////////////////////////////////////// /** Setss the name of the field for this function. The item count is incremented for values != null of this field. @param field The field name. */ public void setField(String field) { setProperty(FIELD_PROPERTY,field); } ////////////////////////////////////////////////////////////////////////////// /** Received notification of a move to the next row of data. Increments the item count (overridden to increment the count only if the field is not null). @param event Information about the event. */ public void itemsAdvanced(final ReportEvent event) { if (getDataRow().get(getField()) != null) setCount(getCount() + 1); } }