org.jfree.report.function
Class ItemHideFunction

java.lang.Object
  extended byorg.jfree.report.function.AbstractFunction
      extended byorg.jfree.report.function.ItemHideFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable

public class ItemHideFunction
extends AbstractFunction
implements java.io.Serializable

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.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String ELEMENT_PROPERTY
          Literal text for the 'element' property.
static java.lang.String FIELD_PROPERTY
          Literal text for the 'field' property.
 
Fields inherited from interface org.jfree.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
ItemHideFunction()
          Constructs an unnamed function.
ItemHideFunction(java.lang.String name)
          Constructs a named function.
 
Method Summary
 java.lang.String getElement()
          Returns the name of the element in the item band that should be set visible/invisible.
 java.lang.String getField()
          Returns the field used by the function.
 Expression getInstance()
          Return a completly separated copy of this function.
 java.lang.Object getValue()
          Returns the function value, in this case the visibility of the defined element.
 void initialize()
          Initializes the function and tests that all required properties are set.
 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 setElement(java.lang.String name)
          Sets the name of the element in the item band that should be set visible/invisible.
 void setField(java.lang.String field)
          Sets the field name for the function.
 
Methods inherited from class org.jfree.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getName, getProperties, getProperty, getProperty, groupFinished, groupStarted, isActive, itemsFinished, reportDone, reportFinished, reportInitialized, reportStarted, setDataRow, setDependencyLevel, setName, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ELEMENT_PROPERTY

public static final java.lang.String ELEMENT_PROPERTY
Literal text for the 'element' property.

See Also:
Constant Field Values

FIELD_PROPERTY

public static final java.lang.String FIELD_PROPERTY
Literal text for the 'field' property.

See Also:
Constant Field Values
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(java.lang.String name)
Constructs a named function.

The field must be defined before using the function.

Parameters:
name - The function name.
Method Detail

getElement

public java.lang.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(java.lang.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 java.lang.String getField()
Returns the field used by the function.

The field name corresponds to a column name in the report's TableModel or to an expression.

Returns:
The field name.

setField

public void setField(java.lang.String field)
Sets the field name for the function.

The field name corresponds to a column name in the report's TableModel.

Parameters:
field - the field name (null not permitted).

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 java.lang.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.

initialize

public void initialize()
                throws FunctionInitializeException
Initializes the function and tests that all required properties are set. If the required field property or the element property are not set, a FunctionInitializeException is thrown.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - when no field or element is set.

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 AbstractFunction
Returns:
a copy of this function.