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

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.ItemHideFunction
All Implemented Interfaces:
Serializable, Cloneable, EventListener, PageEventListener, ReportListener, Expression, Function, LayoutProcessorFunction

public class ItemHideFunction
extends AbstractFunction
implements PageEventListener, LayoutProcessorFunction

The ItemHideFunction hides equal values in a group. Only the first changed value is printed. This function uses the property element to define the name of the element in the ItemBand that should be made visible or invisible by this function. The property field defines the field in the datasource or the expression which should be used to determine the visibility.

In simple cases, this function can be replaced with a style-formula on the visibly-stylekey: =NOT(ISCHANGED("fieldname")). In addition to the simple case, this function behaves special on pagebreaks and intermediate group changes.

Author:
Thomas Morgner
See Also:
Serialized Form

Constructor Summary
ItemHideFunction()
          Constructs an unnamed function.
ItemHideFunction(String name)
          Constructs a named function.
 
Method Summary
 String getElement()
          Returns the name of the element in the item band that should be set visible/invisible.
 String getField()
          Returns the field used by the function.
 Expression getInstance()
          Return a completly separated copy of this function.
 Object getValue()
          Returns the function value, in this case the visibility of the defined element.
 boolean isIgnoreGroupBreaks()
          Returns whether a group start resets the visiblity of the element.
 boolean isIgnorePageBreaks()
          Returns whether a page start resets the visiblity of the element.
 void itemsAdvanced(ReportEvent event)
          Receives notification that a row of data is being processed.
 void itemsStarted(ReportEvent event)
          Resets the state of the function when a new ItemGroup has started.
 void pageFinished(ReportEvent event)
          Receives notification that a page is completed.
 void pageStarted(ReportEvent event)
          Receives notification that a new page is being started.
 void reportInitialized(ReportEvent event)
          Receives notification that the report has started.
 void setElement(String name)
          Sets the name of the element in the item band that should be set visible/invisible.
 void setField(String field)
          Sets the field name for the function.
 void setIgnoreGroupBreaks(boolean ignoreGroupBreaks)
          Defines whether a group start resets the visiblity of the element.
 void setIgnorePageBreaks(boolean ignorePageBreaks)
          Returns whether a page start resets the visiblity of the element.
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractFunction
groupFinished, groupStarted, itemsFinished, reportDone, reportFinished, reportStarted
 
Methods inherited from class org.pentaho.reporting.engine.classic.core.function.AbstractExpression
clone, 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, groupStarted, itemsFinished, reportDone, reportFinished, reportStarted
 
Methods inherited from interface org.pentaho.reporting.engine.classic.core.function.Expression
clone, getDataRow, getDependencyLevel, getName, getReportConfiguration, getResourceBundleFactory, getRuntime, isActive, isDeepTraversing, isPreserve, setDependencyLevel, setName, setRuntime
 

Constructor Detail

ItemHideFunction

public ItemHideFunction()
Constructs an unnamed function.

Make sure to set the function name before it is used, or function initialisation will fail.


ItemHideFunction

public ItemHideFunction(String name)
Constructs a named function.

The field must be defined before using the function.

Parameters:
name - The function name.
Method Detail

isIgnoreGroupBreaks

public boolean isIgnoreGroupBreaks()
Returns whether a group start resets the visiblity of the element.

Returns:
false, if group breaks reset the visiblity, true otherwise.

setIgnoreGroupBreaks

public void setIgnoreGroupBreaks(boolean ignoreGroupBreaks)
Defines whether a group start resets the visiblity of the element.

Parameters:
ignoreGroupBreaks - false, if group breaks reset the visiblity, true otherwise.

isIgnorePageBreaks

public boolean isIgnorePageBreaks()
Returns whether a page start resets the visiblity of the element.

Returns:
false, if page breaks reset the visiblity, true otherwise.

setIgnorePageBreaks

public void setIgnorePageBreaks(boolean ignorePageBreaks)
Returns whether a page start resets the visiblity of the element.

Parameters:
ignorePageBreaks - false, if page breaks reset the visiblity, true otherwise.

getElement

public String getElement()
Returns the name of the element in the item band that should be set visible/invisible.

Returns:
The element name.

setElement

public void setElement(String name)
Sets the name of the element in the item band that should be set visible/invisible.

Parameters:
name - the element name (must not be null).

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.

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.

Parameters:
field - the field name.

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Receives notification that a row of data is being processed. Reads the data from the field defined for this function and hides the field if the value is equal to the last value and the this is not the first row of the item group.

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

itemsStarted

public void itemsStarted(ReportEvent event)
Resets the state of the function when a new ItemGroup has started.

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

getValue

public Object getValue()
Returns the function value, in this case the visibility of the defined element.

Specified by:
getValue in interface Expression
Returns:
The function value.

pageFinished

public void pageFinished(ReportEvent event)
Receives notification that a page is completed.

Specified by:
pageFinished in interface PageEventListener
Parameters:
event - The event.

pageStarted

public void pageStarted(ReportEvent event)
Receives notification that a new page is being started.

Specified by:
pageStarted in interface PageEventListener
Parameters:
event - The event.

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.

reportInitialized

public void reportInitialized(ReportEvent event)
Receives notification that the report has started.

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