Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.able.rules
Class AbleSelector

    java.lang.Object
      com.ibm.able.rules.AbleSelector

All Implemented Interfaces:
  java.io.Serializable

public class AbleSelector
extends java.lang.Object
implements java.io.Serializable

This class represents a single AbleVariable (the selected variable) and a set of constraints on the value that variable can take.

Selectors are created as part of when/do pattern match rules and directly via use of Selector data types in the Able Rule Language.

See Also:
  Serialized Form

Field Summary
`protected AbleExpression` | `constraintExpr`
`protected java.util.Vector` | `constraints`
`protected AbleRuleSet` | `myRuleSet`
`protected boolean` | `positive`
`protected AbleVariable` | `selectorVariable`

Constructor Summary
`AbleSelector()` Create an AbleSelector object
`AbleSelector(AbleRuleSet theRuleSet, AbleVariable selector, java.util.Vector constraints, boolean positive)` Construct a selector object
`AbleSelector(AbleRuleSet theRuleSet, java.lang.String theVariableName, AbleExpression theConstraintExpression)` Construct a selector object from the specified variable name and expression.
`AbleSelector(AbleVariable selector, AbleExpression constraintExpr, boolean positive)` Construct a selector object.
`AbleSelector(AbleVariable selector, java.lang.Object constraintExpr, boolean positive)` Construct a selector object.
`AbleSelector(AbleVariable selector, java.util.Vector constraints)` Create an AbleSelector object

Method Summary
`void` | `addConstraint(java.lang.Object constraint)` Add a Clause or Predicate constraint to this selector
`java.lang.Object` | `any(AbleOclCollection theCollection)` From the specified collection, find and return the first element that satisfies the contained expression.
`java.lang.String` | `arlString()` Return a formal ARL string that describes this clause.
`java.lang.String` | `armlString()` Return a formal XML string that describes this clause.
`AbleOclCollection` | `collect(AbleOclCollection theCollection)` Collect the values returned when the expression is evaluated against each element of the specified collection.
`void` | `convertExpressionToClauses(AbleRuleSet theRuleSet)` Convert the constraintExpression to a Vector of AbleAntecedentClauses
`boolean` | `exists(AbleOclCollection theCollection)` Determine whether the collection contains at least one element for which the expression evaluates to true.
`boolean` | `forAll(AbleOclCollection theCollection)` Determine whether all elements of the collection are true for the contained expression expression.
`AbleExpression` | `getConstraintExpression()` Retrieve the constraint expression
`java.util.Vector` | `getConstraints()` Retrieve the list of constraints (antecedent clauses)
`java.lang.Object` | `getSelectorValue()` Return the value of the selector variable
`AbleVariable` | `getSelectorVariable()` Return the selector variable
`java.lang.String` | `getTemplateString(java.util.Vector theTemplateVars)` Retrieve a text format string for use by rule templates.
`boolean` | `isNegative()` Check if selector is negative (checking for patterns that don't exist)
`boolean` | `isPositive()` Check if selector is positive (looking for matches)
`boolean` | `isUnique(AbleOclCollection theCollection)` Determine whether the expression evaluates to a unique value for each element of the specified collection.
`java.util.Vector` | `match(AbleWorkingMemory workingMemory)` Find a list of matching instances in working memory
`boolean` | `one(AbleOclCollection theCollection)` From the specified collection, find and return the first element that satisfies the contained expression.
`AbleOclCollection` | `reject(AbleOclCollection theCollection)` From the specified collection, create a list of those elements that evaluate to false against the contained expression.
`AbleOclCollection` | `select(AbleOclCollection theCollection)` From the specified collection, create a list of those elements that evaluate to true against the contained expression.
`java.lang.String` | `traceString(int theTraceStringFlavor)` Retrieve a string describing (the contents of) the object.
`java.lang.String` | `xmlString()` Return a formal XML string that describes this clause.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### constraints

    protected java.util.Vector constraints

### selectorVariable

    protected AbleVariable selectorVariable

### positive

    protected boolean positive

### constraintExpr

    protected AbleExpression constraintExpr

### myRuleSet

    protected AbleRuleSet myRuleSet

Constructor Detail

### AbleSelector

    public AbleSelector()

  Create an AbleSelector object

### AbleSelector

    public AbleSelector(AbleVariable selector,
                        java.util.Vector constraints)

  Create an AbleSelector object

Parameters:
  `selector` - The selector variable
  `constraints` - A vector of constraints on the values bound to the selector variable The constraints are AbleAntecedentClause objects

### AbleSelector

    public AbleSelector(AbleRuleSet theRuleSet,
                        AbleVariable selector,
                        java.util.Vector constraints,
                        boolean positive)

  Construct a selector object

Parameters:
  `theRuleSet` - The ruleset object this selector belongs to
  `selector` - The selector variable
  `constraints` - A vector of constraints on the values bound to the selector variable The constraints are AbleAntecedentClause objects
  `positive` - A boolean , true if the selector is positive, false if negative

### AbleSelector

    public AbleSelector(AbleVariable selector,
                        AbleExpression constraintExpr,
                        boolean positive)

  Construct a selector object.

Parameters:
  `selector` - The selector variable
  `constraintExpr` - A constraint expression bound to the selector variable.
  `positive` - A boolean , true if the selector is positive, false if negative

### AbleSelector

    public AbleSelector(AbleVariable selector,
                        java.lang.Object constraintExpr,
                        boolean positive)
                 throws AbleParException

  Construct a selector object.

Parameters:
  `selector` - The selector variable.
  `constraintExpr` - An AbleExpression bound to the selector variable. The constraints are AbleAntecedentClause objects.
  `positive` - A boolean, true if the selector is positive, false if negative.

### AbleSelector

    public AbleSelector(AbleRuleSet theRuleSet,
                        java.lang.String theVariableName,
                        AbleExpression theConstraintExpression)

  Construct a selector object from the specified variable name and expression.

Parameters:
  `theRuleSet` - The ruleset in which this selector is evaluated.

  `theVariableName` - The name of the selector variable; it must identify a variable declared within the specified ruleset.

  `theConstraintExpression` - An expression that, when evaluated with an instance of the specified variable, must return a boolean value.

Method Detail

### addConstraint

    public void addConstraint(java.lang.Object constraint)

  Add a Clause or Predicate constraint to this selector

  Parameters:
    `constraint` - An AntecedentClause that places a constraint on instances bound to the selector

### isPositive

    public boolean isPositive()

  Check if selector is positive (looking for matches)

  Returns:
    true if the selector is checking for matches

### isNegative

    public boolean isNegative()

  Check if selector is negative (checking for patterns that don't exist)

  Returns:
    true if the selector is checking for no matches

### match

    public java.util.Vector match(AbleWorkingMemory workingMemory)
                           throws AbleDataException

  Find a list of matching instances in working memory

  Parameters:
    `workingMemory` - The associated working memory to be searched
  Throws:
    `AbleDataException`

### exists

    public boolean exists(AbleOclCollection theCollection)
                   throws AbleDataException

  Determine whether the collection contains at least one element for which the expression evaluates to true.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    true if the expression evaluates to true for at least one element of the collection; otherwise returns false.
  Throws:
    `AbleDataException`

### forAll

    public boolean forAll(AbleOclCollection theCollection)
                   throws AbleDataException

  Determine whether all elements of the collection are true for the contained expression expression.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    true if the expression evaluates to true for all elements of the collection; otherwise false is returned.
  Throws:
    `AbleDataException`

### isUnique

    public boolean isUnique(AbleOclCollection theCollection)
                     throws AbleDataException

  Determine whether the expression evaluates to a unique value for each element of the specified collection.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    true if the expression evaluates to a unique value for each element of the collection; otherwise false is returned.
  Throws:
    `AbleDataException`

### any

    public java.lang.Object any(AbleOclCollection theCollection)
                         throws AbleDataException

  From the specified collection, find and return the first element that satisfies the contained expression.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    The first element of the collection to satisfy expression, or null if no element satisfies the expression.
  Throws:
    `AbleDataException`

### one

    public boolean one(AbleOclCollection theCollection)
                throws AbleDataException

  From the specified collection, find and return the first element that satisfies the contained expression.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    true if just one element satisfies the expression; otherwise false is returned.
  Throws:
    `AbleDataException`

### collect

    public AbleOclCollection collect(AbleOclCollection theCollection)
                              throws AbleDataException

  Collect the values returned when the expression is evaluated against each element of the specified collection.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    a collection of values returned by evaluating the expression against each element of the specified collection.
  Throws:
    `AbleDataException`

### select

    public AbleOclCollection select(AbleOclCollection theCollection)
                             throws AbleDataException

  From the specified collection, create a list of those elements that evaluate to true against the contained expression.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    A subcollection of elements from the specified collection. The collection may be empty, but it will not be null.
  Throws:
    `AbleDataException`

### reject

    public AbleOclCollection reject(AbleOclCollection theCollection)
                             throws AbleDataException

  From the specified collection, create a list of those elements that evaluate to false against the contained expression.

  Parameters:
    `theCollection` - The collection of elements to examine.

  Returns:
    A subcollection of elements from the specified collection. The collection may be empty, but it will not be null.
  Throws:
    `AbleDataException`

### getSelectorVariable

    public AbleVariable getSelectorVariable()

  Return the selector variable

### getSelectorValue

    public java.lang.Object getSelectorValue()
                                      throws AbleDataException

  Return the value of the selector variable

  Throws:
    `AbleDataException`

### getConstraints

    public java.util.Vector getConstraints()

  Retrieve the list of constraints (antecedent clauses)

### getConstraintExpression

    public AbleExpression getConstraintExpression()

  Retrieve the constraint expression

### convertExpressionToClauses

    public void convertExpressionToClauses(AbleRuleSet theRuleSet)

  Convert the constraintExpression to a Vector of AbleAntecedentClauses

  Parameters:
    `theRuleSet` - An AbleRuleSet objet

### arlString

    public java.lang.String arlString()

  Return a formal ARL string that describes this clause.

  For antecedent clauses, add the weight of the clause, but only if the weight is something other than the default weight.

  Returns:
    A String that describes this clause in formal rule language.

### xmlString

    public java.lang.String xmlString()

  Return a formal XML string that describes this clause.

  For antecedent clauses, add the weight of the clause, but only if the weight is something other than the default weight.

  Returns:
    A String that describes this clause in XML.

### armlString

    public java.lang.String armlString()

  Return a formal XML string that describes this clause.

  For antecedent clauses, add the weight of the clause, but only if the weight is something other than the default weight.

  Returns:
    A String that describes this clause in XML.

### getTemplateString

    public java.lang.String getTemplateString(java.util.Vector theTemplateVars)
                                       throws AbleDataException

  Retrieve a text format string for use by rule templates. The string contains "{n}" strings, where the index 'n' corresponds to the template variables defined in the rule template. This string is based on the standard arlString() representation of the rule. After replacement of the template variable values, the resulting string must be a valid ARL format string that can be parsed.

  Parameters:
    `theTemplateVars` - An ordered list of template variables referenced by this selector.
  Returns:
    A Text format string used to create a new rule instance.
  Throws:
    `AbleDataException`
  See Also:
    `AbleRuleTemplate`

### traceString

    public java.lang.String traceString(int theTraceStringFlavor)

  Retrieve a string describing (the contents of) the object.

  Parameters:
    `theTraceStringFlavor` - An Able.TraceStringFlavor value.

  Returns:
    A String containing the current contents of the object.

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
| ABLE 2.3.0 07/13/2005 14:21:00
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

(C) Copyright IBM Corporation 1999, 2005