com.jrefinery.report.function
Class ElementVisibilitySwitchFunction

java.lang.Object
  |
  +--com.jrefinery.report.function.AbstractFunction
        |
        +--com.jrefinery.report.function.ElementVisibilitySwitchFunction
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, Expression, Function, ReportListener, java.io.Serializable

public class ElementVisibilitySwitchFunction
extends AbstractFunction
implements java.io.Serializable

A function that alternates between true and false for each item within a group. The functions value affects a defined elements visibility. If the function evaluates to true, the named element is visible, else the element is invisible.

Use the property element to name an element contained in the ItemBand whose visiblity should be affected by this function.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
static java.lang.String ELEMENT_PROPERTY
          the Property key for the name of the ItemBand element.
static java.lang.String INITIAL_STATE_PROPERTY
          The initial state property key.
 
Fields inherited from interface com.jrefinery.report.function.Expression
AUTOACTIVATE_PROPERTY
 
Constructor Summary
ElementVisibilitySwitchFunction()
          Default constructor.
 
Method Summary
 java.lang.String getElement()
          Returns the element name.
 boolean getInitialTriggerValue()
          Gets the initial value for the visible trigger, either "true" or "false".
 java.lang.Object getValue()
          Returns the defined visibility of the element.
 void initialize()
          Checks that the function has been correctly initialized.
 void itemsAdvanced(ReportEvent event)
          Triggers the visibility of an element.
 void itemsStarted(ReportEvent event)
          Receives notification that the items are being processed.
 void pageStarted(ReportEvent event)
          Receives notification that a page has started.
 void setElement(java.lang.String name)
          Sets the element name.
 
Methods inherited from class com.jrefinery.report.function.AbstractFunction
clone, getDataRow, getDependencyLevel, getInstance, getName, getProperties, getProperty, getProperty, groupFinished, groupStarted, isActive, itemsFinished, pageFinished, 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
the Property key for the name of the ItemBand element.

See Also:
Constant Field Values

INITIAL_STATE_PROPERTY

public static final java.lang.String INITIAL_STATE_PROPERTY
The initial state property key.

See Also:
Constant Field Values
Constructor Detail

ElementVisibilitySwitchFunction

public ElementVisibilitySwitchFunction()
Default constructor.

Method Detail

pageStarted

public void pageStarted(ReportEvent event)
Receives notification that a page has started.

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

itemsStarted

public void itemsStarted(ReportEvent event)
Receives notification that the items are being processed. Sets the function value to false.

Following this event, there will be a sequence of itemsAdvanced events until the itemsFinished event is raised.

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

itemsAdvanced

public void itemsAdvanced(ReportEvent event)
Triggers the visibility of an element. If the named element was visible at the last itemsAdvanced call, it gets now invisible and vice versa. This creates the effect, that an element is printed every other line.

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

initialize

public void initialize()
                throws FunctionInitializeException
Checks that the function has been correctly initialized. The functions name or the elements name have not been set, and FunctionInitializeException is thrown.

Specified by:
initialize in interface Expression
Overrides:
initialize in class AbstractFunction
Throws:
FunctionInitializeException - if required parameters were missing and initialisation cannot be performed.

getInitialTriggerValue

public boolean getInitialTriggerValue()
Gets the initial value for the visible trigger, either "true" or "false".

Returns:
the initial value for the trigger.

setElement

public void setElement(java.lang.String name)
Sets the element name. The name denotes an element within the item band. The element will be retrieved using the getElement(String) function.

Parameters:
name - The element name.
See Also:
Band.getElement(String)

getElement

public java.lang.String getElement()
Returns the element name.

Returns:
The element name.

getValue

public java.lang.Object getValue()
Returns the defined visibility of the element. Returns either true or false as java.lang.Boolean.

Specified by:
getValue in interface Expression
Returns:
the visibility of the element, either Boolean.TRUE or Boolean.FALSE.