public class RuleBundle
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Rule objects.
The order of the Rule objects in the RuleBundle
determines the order in which the rules are run.
The RuleBundle supports running all of the rules in the
RuleBundle, resulting in a single Mergeable
object, which a DataView then uses to paint an item.
In cases where more than one rule sets the same property, the
last rule to run sets the final value of the property.
All of the Rule objects in the RuleBundle
must have compatible Mergeable objects.
To be compatible, Mergeable objects should be the same
class.
For example, all of the rules should operate on ViewFormat
objects or on ViewStyle objects, but not on some of each.
A class and its subclass can be compatible if the merge
method handles any properties that are in the subclass but not in the
original class.
The RuleBundle actually contains clones of the Rule
objects that you add to the bundle.
If you change a Rule after you add it to a
RuleBundle, then call the ReplaceRule method
to replace the old Rule with the modified Rule.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Hashtable |
m_context |
static java.lang.String |
NAME_BUNDLE |
| Constructor and Description |
|---|
RuleBundle()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRule(Rule rule)
Adds a
Rule to the end of this RuleBundle. |
void |
addRule(Rule rule,
int index)
Adds a
Rule to this RuleBundle, at the specified
index. |
void |
addRuleBundleListener(RuleBundleListener listener)
Registers a listener for this
RuleBundle. |
java.lang.Object |
clone()
Clones this
RuleBundle. |
void |
fireEvent(RuleBundleEvent e)
Fires a
RuleBundleEvent to all listeners. |
int |
getCount()
Retrieves the number of rules in this
RuleBundle. |
java.lang.String |
getID()
Retrieves the identifier for this
RuleBundle. |
Rule |
getRule(int index)
Retrieves the
Rule at the specified index. |
oracle.dss.util.xml.ObjectNode |
getXML(boolean allProperties,
ComponentTypeConverter dataview)
Retrieves XML that represents properties and their values in the form
of and
ObjectNode. |
oracle.dss.util.xml.ObjectNode |
getXML(boolean allProperties,
ComponentTypeConverter dataview,
java.lang.String name)
Retrieves XML that represents properties and their values in the form
of and
ObjectNode. |
boolean |
isStopAtFirstMatch()
Indicates whether the first
Rule that applies in a
RuleBundle is the last Rule that is run
in the RuleBundle. |
void |
removeRule(int index)
Removes the
Rule at the specified index. |
void |
removeRule(Rule rule)
Removes the specified
Rule from this RuleBundle. |
void |
removeRuleBundleListener(RuleBundleListener listener)
Removes the specified listener.
|
void |
removeRulesThatApply(RuleContext context,
Mergeable mergeable)
Removes from this
RuleBundle any Rule that
applies in the specified context. |
void |
replaceRule(Rule rule,
int index)
Replaces a
Rule with another Rule. |
boolean |
runRules(RuleContext context,
Mergeable target)
Runs each
Rule in this RuleBundle. |
void |
setContext(java.util.Hashtable context) |
void |
setID(java.lang.String id)
Specifies an identifier for this
RuleBundle. |
void |
setStopAtFirstMatch(boolean v)
Specifies whether the first
Rule that applies in a
RuleBundle is the
last Rule that is run in the RuleBundle . |
void |
setXML(oracle.dss.util.xml.ContainerNode node,
ComponentTypeConverter converter,
java.lang.String version,
int reset)
Specifies XML that represents properties and values.
|
protected java.util.Hashtable m_context
public static final java.lang.String NAME_BUNDLE
public java.lang.Object clone()
RuleBundle.
The clone contains a clone of each Rule in this
RuleBundle.clone in class java.lang.ObjectRuleBundle.public Rule getRule(int index)
Rule at the specified index.
At this time, this method returns a reference to the Rule;
it does not clone the Rule.index - The index of the Rule that you want. Valid
indexes are zero to the current size of this
RuleBundle.Rule at the specified index.public void addRule(Rule rule)
Rule to the end of this RuleBundle.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.rule - The Rule to add.public void addRule(Rule rule, int index)
Rule to this RuleBundle, at the specified
index.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.rule - The Rule to add.index - The index at which to add the Rule. Valid
values are zero to the current size of the
RuleBundle.public void addRuleBundleListener(RuleBundleListener listener)
RuleBundle.listener - The listener to add.public boolean runRules(RuleContext context, Mergeable target) throws RuleException
Rule in this RuleBundle.
This method passes a single Mergeable object to be
modified by all the Rules that are run and that apply.
If the isStopAtFirstMatch method returns true,
then this method runs rules only until a rule applies.
If isStopAtFirstMatch returns false, then
this method runs all of the rules in the bundle.
context - Information about the data item in question.
Rules use this information to test
whether they apply.target - The Mergeable object whose properties
are to be modified by a Rule that applies.true if any Rule applies (that is,
if the Mergeable is changed at all),
false if no Rule applies.RuleException - If context is unusable for some reason
or if any Rule in this RuleBundle
has a problem.public int getCount()
RuleBundle.RuleBundle.public void removeRuleBundleListener(RuleBundleListener listener)
listener - The listener to remove.public void fireEvent(RuleBundleEvent e)
RuleBundleEvent to all listeners.
Currently, the RuleBundleEvent has one type, which indicates
that the RuleBundle has been modified.
If you change a Rule in this RuleBundle, then
you should call this method.
e - The RuleBundleEvent.public void removeRule(Rule rule)
Rule from this RuleBundle.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.rule - The Rule to remove.public void removeRule(int index)
Rule at the specified index.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.index - The index of the Rule to remove. Valid
values are zero to the current size of the
RuleBundle.public void removeRulesThatApply(RuleContext context, Mergeable mergeable) throws RuleException
RuleBundle any Rule that
applies in the specified context.
If this method removes any rules, then it fires a
RuleBundleEvent to notify listeners
that the RuleBundle was modified.context - Information about the DataView item in question.
This method uses this information to test
whether the rules apply.mergeable - The Mergeable object that would be modified
if the rules were run. This method does not run rules,
so the Mergeable is not modified. Dynamic
rules might use the Mergeable to see if they
apply.RuleException - If context is unusable for some reason
or if any Rule in this RuleBundle
has a problem.public void replaceRule(Rule rule, int index)
Rule with another Rule.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.rule - The Rule that you want to put in this
RuleBundle.index - The index of the Rule that you want
rule to replace.public void setStopAtFirstMatch(boolean v)
Rule that applies in a
RuleBundle is the
last Rule that is run in the RuleBundle .
This method affects the behavior of the
runRules method.
This method fires a RuleBundleEvent to notify
listeners that the RuleBundle was modified.v - true to stop rules from running after the
first rule that applies is fired,
false to have all the rules in the bundle run.public boolean isStopAtFirstMatch()
Rule that applies in a
RuleBundle is the last Rule that is run
in the RuleBundle.
The return value of this method affects the behavior of the
runRules method.true if the first Rule that applies
is the last Rule that runs,
false if all the rules in the bundle are run.public void setID(java.lang.String id)
RuleBundle.id - The String that identifies this
RuleBundle.public java.lang.String getID()
RuleBundle.RuleBundle.public void setContext(java.util.Hashtable context)
context - A hashtable that a user can use to pass XMLContext
One can also use this table to pass more information
to its objects.public void setXML(oracle.dss.util.xml.ContainerNode node,
ComponentTypeConverter converter,
java.lang.String version,
int reset)
Rule.node - ObjectNode that has the properties and their values.converter - A class that converts view component identifiers from
strings to integers and back. Dataview
objects implement the ComponentTypeConverter
interface.version - The XML version.reset - A constant that indicates how much to reset when XML
is applied. Valid values are listed in the See Also section.Rule.RESET_NONE,
Rule.RESET_XML_PROPERTIES,
Rule.RESET_EVERYTHINGpublic oracle.dss.util.xml.ObjectNode getXML(boolean allProperties,
ComponentTypeConverter dataview)
ObjectNode.allProperties - true to store all property values in XML,
false to store only values that are different
from default values.dataview - A class that converts view component identifiers from
strings to integers and back. Dataview
objects implement the ComponentTypeConverter
interface.public oracle.dss.util.xml.ObjectNode getXML(boolean allProperties,
ComponentTypeConverter dataview,
java.lang.String name)
ObjectNode.allProperties - true to store all property values in XML,
false to store only values that are different
from default values.dataview - A class that converts view component identifiers from
strings to integers and back. Dataview
objects implement the ComponentTypeConverter
interface.name - The element name to use in the XML.