public class Rule
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Dataview
renders an item
The property values are specified in a Mergeable object.
The applies method specifies whether the properties in the
Mergeable should be used.
In this class, the applies method always returns
true, so the rule always applies.
Rule objects are normally stored in RuleBundle
objects. RuleBundle objects are stored in vectors, which are then
passed to a Manager class, which runs all the rules
in all of the rule bundles.
The result is a single Mergeable object that specifies all
of the settings that the Manager should use to render an item
in a Dataview.
Subclasses of this class can override methods, in order to produce more
specific rules.
For example, the DiscriminatorRule specifies conditions under
which the rule applies.
Mergeable,
DiscriminatorRule,
RuleBundle,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected Mergeable |
m_mergeable |
static int |
RESET_EVERYTHING
Reset all defaults, so that the rule is equivalent to one that has just
been created.
|
static int |
RESET_NONE
Reset no defaults.
|
static int |
RESET_XML_PROPERTIES
Reset defaults for properties that can be set through XML.
|
| Constructor and Description |
|---|
Rule()
Constructor that does not specify a
Mergeable object. |
Rule(Mergeable mergeable)
Constructor that specifies a
Mergeable object. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
applies(RuleContext context,
Mergeable target)
Specifies whether this rule applies in the specified context.
|
java.lang.Object |
clone()
Clones this object.
|
void |
fireRule(RuleContext context,
Mergeable target)
Modifies the specified
Mergeable object to include
property settings that this Rule specifies. |
Mergeable |
getFixedMergeable()
Retrieves the
Mergeable object that specifies property
settings that should take effect when this Rule applies. |
long |
getID() |
oracle.dss.util.xml.ObjectNode |
getXML(boolean allProperties,
ComponentTypeConverter converter) |
boolean |
runRule(RuleContext context,
Mergeable target)
Fires this rule if the specified context warrants.
|
void |
setFixedMergeable(Mergeable mergeable)
Specifies the
Mergeable object whose property values
should be set whenever this Rule applies. |
void |
setID(long id) |
boolean |
setXML(oracle.dss.util.xml.ObjectNode objectNode,
java.lang.String version,
int reset) |
protected Mergeable m_mergeable
public static final int RESET_NONE
public static final int RESET_XML_PROPERTIES
public static final int RESET_EVERYTHING
public Rule()
Mergeable object.
If you call this constructor, and the rule needs a Mergeable
object, then you must also call the setFixedMergeable
method.public Rule(Mergeable mergeable)
Mergeable object.mergeable - The Mergeable object whose property
values should be used when this rule applies.public void setID(long id)
id - A long number that identifies this
Rule. This id is internally set by
our UI Panels.Rule.public long getID()
Rule.Rule.public java.lang.Object clone()
clone in class java.lang.Objectpublic boolean applies(RuleContext context, Mergeable target) throws RuleException
true.context - The context of the item that is to
be rendered. The Dataview provides this
parameter.target - The Mergeable object whose properties will
be modified when the rule is fired, if this method
returns true. Overriding methods may or may not use
this parameter.
This must be the same class as the object retrieved by
calling the getFixedMergeable method.true. Overriding methods should return
true or false.RuleException - If context is unusable for some reason
or if this Rule has a problem.public boolean runRule(RuleContext context, Mergeable target) throws RuleException
applies method. If the
applies method returns true, then this
method calls the fireRule method.
The RuleBundle method calls this method for each rule
in the bundle.
Extending classes may or may not choose to override this method.
(An implementation might skip the call to applies altogether
and just call fireRule.)
context - The context of the item that is to
be rendered. The Dataview provides this
parameter.target - The Mergeable object whose properties will
be modified when the rule is fired, if this method
returns true. Included in case the applies
method wants to examine the Mergeable.
This must be the same class as, or a
subclass of, the object retrieved by calling the
getFixedMergeable method.true if the applies method
returns true, false if not.RuleException - If context is unusable for some reason
or if this Rule has a problem.public void fireRule(RuleContext context, Mergeable target) throws RuleException
Mergeable object to include
property settings that this Rule specifies.
This implementation merges the specified Mergeable object
with the Mergeable object of this Rule.
Merging the two objects adds the property settings from this
Rule to those property settings that will be used when
the Dataview renders an item.context - The context of the item that is to
be rendered. The Dataview provides this
parameter. Subclasses might examine the context to
determine how to modify the Mergeable
object.target - The Mergeable object whose properties will
be modified. This must be the same class as, or a
subclass of, the object retrieved by calling the
getFixedMergeable method.RuleException - If context is unusable for some reason
or if this Rule has a problem.public Mergeable getFixedMergeable()
Mergeable object that specifies property
settings that should take effect when this Rule applies.Mergeable that specifies the property settings
for this Rule.public void setFixedMergeable(Mergeable mergeable)
Mergeable object whose property values
should be set whenever this Rule applies.mergeable - The object that specifies property values that
should be set whenever this Rule applies.public oracle.dss.util.xml.ObjectNode getXML(boolean allProperties,
ComponentTypeConverter converter)
allProperties - true to store all property values in XML,
false to store only values that are different
from default values.converter - A class that converts view component identifiers from
strings to integers and back. Dataview
objects implement the ComponentTypeConverter
interface.ObjectNode.public boolean setXML(oracle.dss.util.xml.ObjectNode objectNode,
java.lang.String version,
int reset)
node - ObjectNode that has the properties and their values.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.true if XML is properly applied,
false if the XML cannot be applied.RESET_NONE,
RESET_XML_PROPERTIES,
RESET_EVERYTHINGRule.