站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss RULES 4.0.0.11754MR2 API 英文版文档

Rule (Drools 4.0.0.11754MR2 API) - JBoss RULES 4.0.0.11754MR2 API 英文版文档


org.drools.rule
Class Rule

java.lang.Object
  extended by org.drools.rule.Rule
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Query

public class Rule
extends Object
implements Serializable

A Rule contains a set of Tests and a Consequence.

The Tests describe the circumstances that representrepresent a match for this rule. The Consequence gets fired when the Conditions match.

Author:
bob mcwhirter , Simon Harris , mark proctor
See Also:
Eval, Consequence, Serialized Form

Constructor Summary
Rule(String name)
           
Rule(String name, String agendaGroup)
          Construct a Rule with the given name for the specified pkg parent
Rule(String name, String pkg, String agendaGroup)
          Construct a Rule with the given name for the specified pkg parent
 
Method Summary
 void addPattern(RuleConditionElement element)
          Add a pattern to the rule.
 boolean equals(Object object)
           
 String getActivationGroup()
           
 String getAgendaGroup()
           
 boolean getAutoFocus()
           
 Consequence getConsequence()
          Retrieve the Consequence associated with this Rule.
 Declaration getDeclaration(String identifier)
          Retrieve a parameter Declaration by identifier.
 Declaration[] getDeclarations()
          Retrieve the set of all root fact object parameter Declarations.
 String getDialect()
           
 Duration getDuration()
          Retrieve the truthness duration object.
 GroupElement getLhs()
          Retrieve the List of Conditions for this rule.
 long getLoadOrder()
           
 String getName()
          Retrieve the name of this rule.
 boolean getNoLoop()
           
 String getPackage()
           
 String getRuleFlowGroup()
           
 int getSalience()
          Retrieve the Rule salience.
 int getSpecifity()
           
 GroupElement[] getTransformedLhs()
          Uses the LogicTransformer to process the Rule patters - if no ORs are used this will return an array of a single AND element.
 int hashCode()
           
 boolean hasLogicalDependency()
           
 boolean isEffective()
          This returns true is the rule is effective.
 boolean isLockOnActive()
           
 boolean isSemanticallyValid()
          This will return if the semantic actions or predicates in the rules are valid.
 boolean isValid()
          Determine if this rule is internally consistent and valid.
 void setActivationGroup(String activationGroup)
           
 void setAgendaGroup(String agendaGroup)
           
 void setAutoFocus(boolean autoFocus)
           
 void setConsequence(Consequence consequence)
          Set the Consequence that is associated with the successful match of this rule.
 void setDateEffective(Calendar effectiveDate)
          Sets the date from which this rule takes effect (can include time to the millisecond).
 void setDateExpires(Calendar expiresDate)
          Sets the date after which the rule will no longer apply (can include time to the millisecond).
 void setDialect(String dialect)
           
 void setDuration(Duration duration)
          Set the truthness duration object.
 void setDuration(long ms)
          Set the truthness duration.
 void setEnabled(boolean b)
          A rule is enabled by default.
 void setHasLogicalDependency(boolean hasLogicalDependency)
           
 void setLhs(GroupElement lhsRoot)
           
 void setLockOnActive(boolean lockOnActive)
           
 void setNoLoop(boolean noLoop)
           
 void setRuleFlowGroup(String ruleFlowGroup)
           
 void setSalience(int salience)
          Set the Rule salience.
 void setSemanticallyValid(boolean valid)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Rule

public Rule(String name,
            String pkg,
            String agendaGroup)
Construct a Rule with the given name for the specified pkg parent

Parameters:
name - The name of this rule.

Rule

public Rule(String name,
            String agendaGroup)
Construct a Rule with the given name for the specified pkg parent

Parameters:
name - The name of this rule.

Rule

public Rule(String name)
Method Detail

getDialect

public String getDialect()

setDialect

public void setDialect(String dialect)

setDuration

public void setDuration(long ms)
Set the truthness duration. This causes a delay before the firing of the Consequence if the rule is still true at the end of the duration.

This is merely a convenience method for calling setDuration(Duration)with a FixedDuration.

Parameters:
seconds - - The number of seconds the rule must hold true in order to fire.
See Also:
setDuration(Duration), FixedDuration

setDuration

public void setDuration(Duration duration)
Set the truthness duration object. This causes a delay before the firing of the Consequence if the rule is still true at the end of the duration.

Parameters:
duration - The truth duration object.

getDuration

public Duration getDuration()
Retrieve the truthness duration object.

Returns:
The truthness duration object.

isValid

public boolean isValid()
Determine if this rule is internally consistent and valid. This will include checks to make sure the rules semantic components (actions and predicates) are valid. No exception is thrown.

A Rule must include at least one parameter declaration and one condition.

Returns:
true if this rule is valid, else false.

getPackage

public String getPackage()

getName

public String getName()
Retrieve the name of this rule.

Returns:
The name of this rule.

getSalience

public int getSalience()
Retrieve the Rule salience.

Returns:
The salience.

setSalience

public void setSalience(int salience)
Set the Rule salience.

Parameters:
salience - The salience.

getAgendaGroup

public String getAgendaGroup()

setAgendaGroup

public void setAgendaGroup(String agendaGroup)

getNoLoop

public boolean getNoLoop()

isEffective

public boolean isEffective()
This returns true is the rule is effective. If the rule is not effective, it cannot activate. This uses the dateEffective, dateExpires and enabled flag to decide this.


setNoLoop

public void setNoLoop(boolean noLoop)

getAutoFocus

public boolean getAutoFocus()

setAutoFocus

public void setAutoFocus(boolean autoFocus)

getActivationGroup

public String getActivationGroup()

setActivationGroup

public void setActivationGroup(String activationGroup)

getRuleFlowGroup

public String getRuleFlowGroup()

setRuleFlowGroup

public void setRuleFlowGroup(String ruleFlowGroup)

getDeclaration

public Declaration getDeclaration(String identifier)
Retrieve a parameter Declaration by identifier.

Parameters:
identifier - The identifier.
Returns:
The declaration or null if no declaration matches the identifier.

hasLogicalDependency

public boolean hasLogicalDependency()

setHasLogicalDependency

public void setHasLogicalDependency(boolean hasLogicalDependency)

isLockOnActive

public boolean isLockOnActive()

setLockOnActive

public void setLockOnActive(boolean lockOnActive)

getDeclarations

public Declaration[] getDeclarations()
Retrieve the set of all root fact object parameter Declarations.

Returns:
The Set of Declarations in order which specify the root fact objects.

addPattern

public void addPattern(RuleConditionElement element)
Add a pattern to the rule. All patterns are searched for bindings which are then added to the rule as declarations

Parameters:
condition - The Test to add.
Throws:
InvalidRuleException

getLhs

public GroupElement getLhs()
Retrieve the List of Conditions for this rule.

Returns:
The List of Conditions.

setLhs

public void setLhs(GroupElement lhsRoot)

getTransformedLhs

public GroupElement[] getTransformedLhs()
                                 throws InvalidPatternException
Uses the LogicTransformer to process the Rule patters - if no ORs are used this will return an array of a single AND element. If there are Ors it will return an And element for each possible logic branch. The processing uses as a clone of the Rule's patterns, so they are not changed.

Returns:
Throws:
InvalidPatternException

getSpecifity

public int getSpecifity()

setConsequence

public void setConsequence(Consequence consequence)
Set the Consequence that is associated with the successful match of this rule.

Parameters:
consequence - The Consequence to attach to this Rule.

getConsequence

public Consequence getConsequence()
Retrieve the Consequence associated with this Rule.

Returns:
The Consequence.

getLoadOrder

public long getLoadOrder()

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

setSemanticallyValid

public void setSemanticallyValid(boolean valid)

isSemanticallyValid

public boolean isSemanticallyValid()
This will return if the semantic actions or predicates in the rules are valid. This is provided so that lists of rules can be provided even if their semantic actions do not "compile" etc.


setDateEffective

public void setDateEffective(Calendar effectiveDate)
Sets the date from which this rule takes effect (can include time to the millisecond).

Parameters:
effectiveDate -

setDateExpires

public void setDateExpires(Calendar expiresDate)
Sets the date after which the rule will no longer apply (can include time to the millisecond).

Parameters:
expiresDate -

setEnabled

public void setEnabled(boolean b)
A rule is enabled by default. This can explicitly disable it in which case it will never activate.



Copyright © 2001-2007 JBoss Inc.. All Rights Reserved.