Rule Concepts

A Rule is an object that specifies the following information:

Normally, you will use a subclass of the Rule class, the DiscriminatorRule.

Definition: DiscriminatorRule

A DiscriminatorRule is a Rule that applies under certain conditions but not under other conditions. For example, you can create a DiscriminatorRule that applies only when a number value is greater than 500,000. Then, the formatting that you specify only takes effect when the rule applies (that is, when the number value is greater than 500,000).

Structure of a DiscriminatorRule

A DiscriminatorRule needs two related objects:

Definition: Discriminator

A Discriminator is an object that specifies a condition under which a rule will apply. A Discriminator compares the current situation of an item that the data view will display (the context of the item) with the internal condition. When the context matches the internal condition, the rule applies.

Conditions that you can set in the BI Beans Discriminators

The following table lists sample conditions and, for each, the discriminator that BI Beans supports.

Sample Condition

Discriminator

Only when the item is being displayed in a column header

ComponentTypeDiscriminator

Only when the value is greater than 500,000

NumberValueDiscriminator

Only when the Product is Hiking Boots

QDRDiscriminator

Only when the item is in the Databody of a table or crosstab

DatabodyDiscriminator

Only when the Product is Hiking boots and the value is greater than 500,000

CompositeDiscriminator

Definition: Mergeable object

A mergeable object is a collection of attributes that specify the formatting for a rule. All mergeable objects implement the Mergeable interface, which defines the support for merging the attribute settings from one object to another.

For example, a ViewStyle is a mergeable object. The ViewStyle includes a set of attributes for displaying text and cell borders. Two ViewStyle objects that have attribute values set can be merged into a single ViewStyle object. This object can then be used by a data view to determine how the view will be displayed.

Formatting that you can set in the supported mergeable objects

The following table lists sample formattings and, for each, the mergeable object that BI Beans supports.

Sample Formatting

Mergeable Object

Displaying text in red, displaying the background in yellow, or aligning the text to the right

ViewStyle

Displaying numbers as currency, displaying four values to the right of the decimal, using a comma to separate whole numbers from fractional numbers, or using a pounds sign for currency

ViewFormat

Creating Rules for Formatting Dataviews
How Rules Work
Example: Specifying a Font Color for a Company Name
Example: Stoplight Reporting in a Crosstab
Example: Setting the Number Format for a Measure in a Graph