A Rule
is an object that specifies the following information:
A set of attribute values to be used when a data view displays an item
Information about the conditions under which the values should be used
Normally, you will use a subclass of the Rule
class, the
DiscriminatorRule
.
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).
DiscriminatorRule
A DiscriminatorRule
needs two related objects:
A Discriminator
, which describes the conditions under which the rule should
apply
A Mergeable
object, which specifies the formatting that should take effect when
the rule applies.
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.
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 |
|
Only when the value is greater than 500,000 |
|
Only when the Product is Hiking Boots |
|
Only when the item is in the Databody of a table or crosstab |
|
Only when the Product is Hiking boots and the value is greater than 500,000 |
|
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.
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 |
|
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 |
|
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