org.drools.ide.common.client.modeldriven.brl
Class RuleModel

java.lang.Object
  extended by org.drools.ide.common.client.modeldriven.brl.RuleModel
All Implemented Interfaces:
Serializable, PortableObject
Direct Known Subclasses:
TemplateModel

public class RuleModel
extends Object
implements PortableObject

See Also:
Serialized Form

Field Summary
 RuleAttribute[] attributes
           
 IPattern[] lhs
           
 RuleMetadata[] metadataList
           
 String modelVersion
           
 String name
          This name is generally not used - the asset name or the file name is preferred (ie it could get out of sync with the name of the file it is in).
 String parentName
           
 IAction[] rhs
           
 
Constructor Summary
RuleModel()
           
 
Method Summary
 void addAttribute(RuleAttribute attribute)
           
 void addLhsItem(IPattern pat)
           
 void addLhsItem(IPattern pat, boolean append)
           
 void addLhsItem(IPattern pat, int position)
           
 void addMetadata(RuleMetadata metadata)
          Add metaData
 void addRhsItem(IAction action)
           
 void addRhsItem(IAction action, boolean append)
           
 void addRhsItem(IAction action, int position)
           
 List<String> getAllVariables()
          This will get a list of all bound variables, including bound fields..
 List<String> getBoundVariablesInScope(BaseSingleFieldConstraint con)
          This uses a deceptively simple algorithm to determine what bound variables are in scope for a given constraint (including connectives).
 String getLHSBindingType(String var)
          Get the data-type associated with the binding
 FactPattern getLHSBoundFact(String var)
          This will return the FactPattern that a variable is bound to.
 List<String> getLHSBoundFacts()
          This will return a List of all FactPattern bindings
 FieldConstraint getLHSBoundField(String var)
          This will return the FieldConstraint that a variable is bound to.
 FactPattern getLHSParentFactPatternForBinding(String var)
          This will return the FactPattern that a variable is bound to.
 RuleMetadata getMetaData(String attributeName)
          Locate metadata element
 ActionInsertFact getRHSBoundFact(String var)
          This will return the ActionInsertFact that a variable is bound to.
 List<String> getRHSBoundFacts()
          This will return a List of all ActionInsertFact bindings
 boolean hasDSLSentences()
          Returns true if any DSLSentences are used.
 boolean isBoundFactUsed(String binding)
           
 boolean isNegated()
          Is the Rule to be negated, i.e.
 boolean isVariableNameUsed(String s)
          Checks to see if a variable is used or not, includes fields as well as facts.
 void moveLhsItemDown(int itemIndex)
           
 void moveLhsItemUp(int itemIndex)
           
 void moveRhsItemDown(int itemIndex)
           
 void moveRhsItemUp(int itemIndex)
           
 void removeAttribute(int idx)
           
 boolean removeLhsItem(int idx)
           
 void removeMetadata(int idx)
           
 void removeRhsItem(int idx)
           
 void setNegated(boolean isNegated)
          Set whether the Rule is to be negated
 boolean updateMetadata(RuleMetadata target)
          Update metaData element if it exists or add it otherwise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public String name
This name is generally not used - the asset name or the file name is preferred (ie it could get out of sync with the name of the file it is in).


parentName

public String parentName

modelVersion

public String modelVersion

attributes

public RuleAttribute[] attributes

metadataList

public RuleMetadata[] metadataList

lhs

public IPattern[] lhs

rhs

public IAction[] rhs
Constructor Detail

RuleModel

public RuleModel()
Method Detail

getLHSBoundFacts

public List<String> getLHSBoundFacts()
This will return a List of all FactPattern bindings

Returns:
The bindings or an empty list if no bindings are found.

getLHSBoundFact

public FactPattern getLHSBoundFact(String var)
This will return the FactPattern that a variable is bound to.

Parameters:
var - The bound fact variable (NOT bound field).
Returns:
null or the FactPattern found.

getLHSBoundField

public FieldConstraint getLHSBoundField(String var)
This will return the FieldConstraint that a variable is bound to.

Parameters:
var - The bound field variable (NOT bound fact).
Returns:
null or the FieldConstraint found.

getLHSBindingType

public String getLHSBindingType(String var)
Get the data-type associated with the binding

Parameters:
var -
Returns:
The data-type, or null if the binding could not be found

getRHSBoundFacts

public List<String> getRHSBoundFacts()
This will return a List of all ActionInsertFact bindings

Returns:
The bindings or an empty list if no bindings are found.

getRHSBoundFact

public ActionInsertFact getRHSBoundFact(String var)
This will return the ActionInsertFact that a variable is bound to.

Parameters:
var - The bound fact variable (NOT bound field).
Returns:
null or the ActionInsertFact found.

getLHSParentFactPatternForBinding

public FactPattern getLHSParentFactPatternForBinding(String var)
This will return the FactPattern that a variable is bound to. If the variable is bound to a FieldConstraint the parent FactPattern will be returned.

Parameters:
var - The variable binding
Returns:
null or the FactPattern found.

getAllVariables

public List<String> getAllVariables()
This will get a list of all bound variables, including bound fields..


removeLhsItem

public boolean removeLhsItem(int idx)
Parameters:
idx - Remove this index from the LHS. returns false if it was NOT allowed to remove this item (ie it is used on the RHS).

isBoundFactUsed

public boolean isBoundFactUsed(String binding)
Parameters:
binding - The name of the LHS fact binding.
Returns:
Returns true if the specified binding is used on the RHS.

addLhsItem

public void addLhsItem(IPattern pat)

addLhsItem

public void addLhsItem(IPattern pat,
                       boolean append)

addLhsItem

public void addLhsItem(IPattern pat,
                       int position)

moveLhsItemDown

public void moveLhsItemDown(int itemIndex)

moveLhsItemUp

public void moveLhsItemUp(int itemIndex)

moveRhsItemDown

public void moveRhsItemDown(int itemIndex)

moveRhsItemUp

public void moveRhsItemUp(int itemIndex)

addRhsItem

public void addRhsItem(IAction action)

addRhsItem

public void addRhsItem(IAction action,
                       boolean append)

addRhsItem

public void addRhsItem(IAction action,
                       int position)

removeRhsItem

public void removeRhsItem(int idx)

addAttribute

public void addAttribute(RuleAttribute attribute)

removeAttribute

public void removeAttribute(int idx)

addMetadata

public void addMetadata(RuleMetadata metadata)
Add metaData

Parameters:
metadata -

removeMetadata

public void removeMetadata(int idx)

getMetaData

public RuleMetadata getMetaData(String attributeName)
Locate metadata element

Parameters:
attributeName - - value to look for
Returns:
null if not found

updateMetadata

public boolean updateMetadata(RuleMetadata target)
Update metaData element if it exists or add it otherwise

Parameters:
target -
Returns:
true on update of existing element false on added of element

getBoundVariablesInScope

public List<String> getBoundVariablesInScope(BaseSingleFieldConstraint con)
This uses a deceptively simple algorithm to determine what bound variables are in scope for a given constraint (including connectives). Does not take into account globals.


isVariableNameUsed

public boolean isVariableNameUsed(String s)
Checks to see if a variable is used or not, includes fields as well as facts.


hasDSLSentences

public boolean hasDSLSentences()
Returns true if any DSLSentences are used.


isNegated

public boolean isNegated()
Is the Rule to be negated, i.e. "not ( PatternX, PatternY... )"

Returns:

setNegated

public void setNegated(boolean isNegated)
Set whether the Rule is to be negated

Parameters:
isNegated -


Copyright © 2001-2011 JBoss by Red Hat. All Rights Reserved.