org.pentaho.reporting.engine.classic.core.function
Class CountDistinctFunction

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.function.AbstractExpression
      extended by org.pentaho.reporting.engine.classic.core.function.AbstractFunction
          extended by org.pentaho.reporting.engine.classic.core.function.CountDistinctFunction
All Implemented Interfaces:
Serializable, Cloneable, EventListener, ReportListener, AggregationFunction, Expression, FieldAggregationFunction, Function

public class CountDistinctFunction
extends AbstractFunction
implements FieldAggregationFunction

Counts the distinct occurences of an certain value of an column. This functionality is similiar to the SQL distinct() function.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
CountDistinctFunction()
          DefaultConstructor.
 
Method Summary
 Object clone()
          Clones the expression.
 String getField()
          Returns the field used by the function.
 String getGroup()
          Returns the group name.
 Expression getInstance()
          Return a completly separated copy of this function.
 Object getValue()
          Return the number of distint values for the given column.
 void groupStarted(ReportEvent event)
          Receives notification that a group has started.
 void itemsAdvanced(ReportEvent event)
          Receives notification that a row of data is being processed.
 void reportInitialized(ReportEvent event)
          Receives notification that report generation initializes the current run.
 void setField(String field)
          Sets the field name for the function.
 void setGroup(String name)
          Sets the group name.
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setActive, setDependencyLevel, setName, setPreserve, setRuntime
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.event.ReportListener
groupFinished, itemsFinished, itemsStarted, reportDone, reportFinished, reportStarted
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setDependencyLevel, setName, setRuntime
 

Constructor Detail

CountDistinctFunction

public CountDistinctFunction()
DefaultConstructor.

Method Detail

getGroup

public String getGroup()
Returns the group name.

Specified by:
getGroup in interface AggregationFunction
Returns:
The group name.

setGroup

public void setGroup(String name)
Sets the group name.

If a group is defined, the running total is reset to zero at the start of every instance of this group.

Specified by:
setGroup in interface AggregationFunction
Parameters:
name - the group name (null permitted).

getField

public String getField()
Returns the field used by the function. The field name corresponds to a column name in the report's data-row.

Specified by:
getField in interface FieldAggregationFunction
Returns:
The field name.

setField

public void setField(String field)
Sets the field name for the function. The field name corresponds to a column name in the report's data-row.

Specified by:
setField in interface FieldAggregationFunction
Parameters:
field - the field name.

reportInitialized

public void reportInitialized(ReportEvent event)
Receives notification that report generation initializes the current run.

The event carries a ReportState.Started state. Use this to initialize the report.

Specified by:
reportInitialized in interface ReportListener
Overrides:
reportInitialized in class AbstractFunction
Parameters:
event - The event.

groupStarted

public void groupStarted(ReportEvent event)
Receives notification that a group has started.

Specified by:
groupStarted in interface ReportListener
Overrides:
groupStarted in class AbstractFunction
Parameters:
event - the event.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed.

Specified by:
itemsAdvanced in interface ReportListener
Overrides:
itemsAdvanced in class AbstractFunction
Parameters:
event - the event.

getValue

public Object getValue()
Return the number of distint values for the given column.

Specified by:
getValue in interface Expression
Returns:
the value of the function.

getInstance

public Expression getInstance()
Return a completly separated copy of this function. The copy does no longer share any changeable objects with the original function.

Specified by:
getInstance in interface Expression
Overrides:
getInstance in class AbstractExpression
Returns:
a copy of this function.

clone

public Object clone()
             throws CloneNotSupportedException
Clones the expression. The expression should be reinitialized after the cloning.

Expressions maintain no state, cloning is done at the beginning of the report processing to disconnect the expression from any other object space.

Specified by:
clone in interface Expression
Overrides:
clone in class AbstractExpression
Returns:
a clone of this expression.
Throws:
CloneNotSupportedException - this should never happen.