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.
 String getBindingType(String var)
           
 FactPattern getBoundFact(String var)
          This will return the fact pattern that a variable is bound to.
 List<String> getBoundFacts()
           
 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).
 RuleMetadata getMetaData(String attributeName)
          Locate metadata element
 ActionInsertFact getRhsBoundFact(String var)
           
 List<String> getRhsBoundFacts()
           
 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

getBoundFact

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

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

getBindingType

public String getBindingType(String var)

getRhsBoundFact

public ActionInsertFact getRhsBoundFact(String var)

getBoundFacts

public List<String> getBoundFacts()
Returns:
A list of bound facts (String). Or empty list if none are found.

getRhsBoundFacts

public List<String> getRhsBoundFacts()
Returns:
A list of bound facts of the rhs(String). Or empty list if none are found. Fix nheron

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.


getAllVariables

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


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 Inc.. All Rights Reserved.