Skip navigation links

Oracle Business Rules Java API Reference
10g (10.1.3.1.0)

B28966-01


oracle.rules.sdk.editor.ruleset
Class Pattern

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byoracle.rules.sdk.editor.ruleset.RuleComponent
              extended byoracle.rules.sdk.editor.ruleset.Pattern

All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable

public class Pattern
extends RuleComponent

A Pattern contains the alias of a FactType and tests which select instances of the FactType.

Tests can be expressed either as a table of SimpleTests or as a String containing an AdvancedExpression.

A VariableName is used to refer to a fact instance in a pattern test or an action. Its use is optional unless the PatternTable has two FactPatterns of the same FactType. The VariableName defaults to the alias of the FactType.

By default, the Pattern Operator is set to OPERATOR_FORALL, meaning that the Pattern will select all matching fact instances. The Operator property can also be set to OPERATOR_IFANY, OPERATOR_NOTANY, which stop as soon as the Pattern is matched once.

Multiple Patterns can be combined in a PatternTable by setting conjunctions which follow each Pattern, for example pattern.setConjunction (Pattern.CONJUNCTION_OR). By default, the Patterns are ANDed.

By default, the Patterns in a PatternTable are AND'ed.

Patterns can be grouped by setting the Form attribute to FORM_NESTED_TABLE. As in RL, groups may have their own operators. For example, the RL pattern expression "A and exists (B and C)" would be represented in the Rule PatternTable with two rows, the first of FORM_FACT_TYPE for A, and the second of FORM_NESTED_TABLE. The nested table would have two rows, one for B and one for C. The exists would be represented by placing OPERATOR_IF_ANY on the nested pattern table, since it applies to the table.

When FORM_NESTED_TABLE is used, FACT_TYPE, VARIABLE, and TEST_FORM properties are ignored, and will not be persisted.

The Operator property will be applied to the entire nested table. The Conjunction property controls the conjunction generated after the nested table.

For example Assume three pattern entries, and one nested table.

 PatternTable 1: 
    row 0   Form: FactType   FactType: A   Conjunction: &&
    row 1   Form: Nested Table  Operator: If there is no  Conjunction: &&
        NestedPatternTable 1:
           row 0   Form: FactType   FactType:  C Conjunction: ||
           row 1   Form: FactType   FactType:  D
    row 2   Form: FactType   FactType: B 

 would result in a Condition of the form:
    
  A && !(C || D) && B

 
See Also:
Serialized Form

Field Summary
static java.lang.String CONJUNCTION_AND
          Use with Conjunction properties.
static java.lang.String CONJUNCTION_OR
           
static java.lang.String[] CONJUNCTIONS
           
static java.lang.String FORM_FACT_TYPE
          Use with Pattern Form.
static java.lang.String FORM_NESTED_TABLE
           
static java.lang.String[] FORMS
           
static java.lang.String OPERATOR_FORALL
          Use with Pattern Operator.
static java.lang.String OPERATOR_IFANY
           
static java.lang.String OPERATOR_NOTANY
           
static java.lang.String[] OPERATORS
           
static java.lang.String PROP_ADVANCED_EXPRESSION
           
static java.lang.String PROP_CONJUNCTION
           
static java.lang.String PROP_FACT_TYPE
           
static java.lang.String PROP_FORM
           
static java.lang.String PROP_NESTED_TABLE
           
static java.lang.String PROP_OPERATOR
           
static java.lang.String PROP_SIMPLE_TEST_TABLE
           
static java.lang.String PROP_TEST_FORM
           
static java.lang.String PROP_VARIABLE
           
static java.lang.String TEST_FORM_ADVANCED
           
static java.lang.String TEST_FORM_NOTEST
          Specifies test form.
static java.lang.String TEST_FORM_SIMPLE
           

 

Method Summary
 java.lang.Object get(java.lang.Object key)
          Generic property getter inheirited from RuleComponent.
 AdvancedExpression getAdvancedExpression()
          Get AdvancedExpression for checking syntax and creating option lists
 java.lang.String getConjunction()
          Get conjunction which combines this Pattern with the following Pattern, if any.
 java.lang.String getConjunctionConstraint()
           
 java.lang.String[] getConjunctionOptions()
           
 int getConjunctionSelected()
           
 java.lang.String getFactType()
          Get the alias of the fact type.
 java.lang.String getFactTypeConstraint()
           
 java.lang.String[] getFactTypeOptions()
           
 int getFactTypeSelected()
           
 java.lang.String getForm()
          Get Form describing whether this Pattern simple fact type or a subtable of fact types.
 java.lang.String getFormConstraint()
           
 java.lang.String[] getFormOptions()
           
 int getFormSelected()
           
 PatternTable getNestedTable()
          Get the the Pattern subtable when Form is FORM_NESTED_TABLE.
 java.lang.String getOperator()
          Get Pattern operator.
 java.lang.String getOperatorConstraint()
           
 java.lang.String[] getOperatorOptions()
           
 int getOperatorSelected()
           
 java.lang.String[] getPropertyNames()
           
 Expression getSimpleTestLeft(int i)
          Shorthand for getSimpleTestTable.getSimpleTest(i).getLeft()
 java.lang.String getSimpleTestOperator(int i)
          Shorthand for getSimpleTestTable.getSimpleTest(i).getOperator()
 Expression getSimpleTestRight(int i)
          Shorthand for getSimpleTestTable.getSimpleTest(i).getRight()
 SimpleTestTable getSimpleTestTable()
          Get the table of tests for this Pattern.
 java.lang.String getTestForm()
           
 java.lang.String getTestFormConstraint()
           
 java.lang.String[] getTestFormOptions()
           
 int getTestFormSelected()
           
 java.lang.String getVariable()
           
 java.lang.String getVariableConstraint()
           
 java.lang.String[] getVariableOptions()
           
 int getVariableSelected()
           
 java.lang.Object put(java.lang.Object key, java.lang.Object value)
          Generic property setter.
 void setConjunction(java.lang.String conjunction)
          Set conjunction which combines this Pattern with the following Pattern, if any.
 void setConjunctionConstraint(java.lang.String conjunctionConstraint)
           
 void setConjunctionOptions(java.lang.String[] conjunctionOptions)
           
 void setFactType(java.lang.String factType)
          Set the alias of the fact type.
 void setFactTypeConstraint(java.lang.String factTypeConstraint)
           
 void setFactTypeOptions(java.lang.String[] factTypeOptions)
           
 void setForm(java.lang.String form)
          Set Form describing whether this Pattern simple fact type or a subtable of fact types.
 void setFormConstraint(java.lang.String formConstraint)
           
 void setFormOptions(java.lang.String[] formOptions)
           
 void setOperator(java.lang.String operator)
          Set Pattern operator.
 void setOperatorConstraint(java.lang.String operatorConstraint)
           
 void setOperatorOptions(java.lang.String[] operatorOptions)
           
 void setTestForm(java.lang.String testForm)
           
 void setTestFormConstraint(java.lang.String testFormConstraint)
           
 void setTestFormOptions(java.lang.String[] testFormOptions)
           
 void setVariable(java.lang.String variable)
           
 void setVariableConstraint(java.lang.String variableConstraint)
           
 void setVariableOptions(java.lang.String[] variableOptions)
           
 void validate()
          Validates the correctness of the RuleComponent and all RuleComponents below it.

 

Methods inherited from class oracle.rules.sdk.editor.ruleset.RuleComponent
clear, discardCopy, get, getConstraint, getConstraintList, getCustom, getDescription, getID, getOptions, getParent, getParentTable, getRange, getRuleDictionary, getSelected, remove, restoreCopy, saveCopy, setCustom, setDescription, setRuleDictionary, toString

 

Methods inherited from class java.util.HashMap
clone, containsKey, containsValue, entrySet, isEmpty, keySet, putAll, size, values

 

Methods inherited from class java.util.AbstractMap
equals, hashCode

 

Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait

 

Methods inherited from interface java.util.Map
equals, hashCode

 

Field Detail

FORM_FACT_TYPE

public static final java.lang.String FORM_FACT_TYPE
Use with Pattern Form. Default is FORM_FACT_TYPE. FORM_NESTED_TABLE is used for a parenthesized pattern expression.
See Also:
Constant Field Values

FORM_NESTED_TABLE

public static final java.lang.String FORM_NESTED_TABLE
See Also:
Constant Field Values

FORMS

public static final java.lang.String[] FORMS

OPERATOR_FORALL

public static final java.lang.String OPERATOR_FORALL
Use with Pattern Operator. Default is OPERATOR_FORALL.
 OPERATOR_FORALL corresponds to RL no pattern operator
 OPERATOR_IFANY  corresponds to RL exists pattern operator
 OPERATOR_NOTANY corresponds to RL not pattern operator

See Also:
Constant Field Values


OPERATOR_IFANY

public static final java.lang.String OPERATOR_IFANY
See Also:
Constant Field Values

OPERATOR_NOTANY

public static final java.lang.String OPERATOR_NOTANY
See Also:
Constant Field Values

OPERATORS

public static final java.lang.String[] OPERATORS

CONJUNCTION_AND

public static final java.lang.String CONJUNCTION_AND
Use with Conjunction properties. Default is CONJUNCTION_AND.
See Also:
Constant Field Values

CONJUNCTION_OR

public static final java.lang.String CONJUNCTION_OR
See Also:
Constant Field Values

CONJUNCTIONS

public static final java.lang.String[] CONJUNCTIONS

TEST_FORM_NOTEST

public static final java.lang.String TEST_FORM_NOTEST
Specifies test form. Default is TEST_FORM_SIMPLE.
See Also:
Constant Field Values

TEST_FORM_SIMPLE

public static final java.lang.String TEST_FORM_SIMPLE
See Also:
Constant Field Values

TEST_FORM_ADVANCED

public static final java.lang.String TEST_FORM_ADVANCED
See Also:
Constant Field Values

PROP_FORM

public static final java.lang.String PROP_FORM
See Also:
Constant Field Values

PROP_FACT_TYPE

public static final java.lang.String PROP_FACT_TYPE
See Also:
Constant Field Values

PROP_TEST_FORM

public static final java.lang.String PROP_TEST_FORM
See Also:
Constant Field Values

PROP_SIMPLE_TEST_TABLE

public static final java.lang.String PROP_SIMPLE_TEST_TABLE
See Also:
Constant Field Values

PROP_ADVANCED_EXPRESSION

public static final java.lang.String PROP_ADVANCED_EXPRESSION
See Also:
Constant Field Values

PROP_VARIABLE

public static final java.lang.String PROP_VARIABLE
See Also:
Constant Field Values

PROP_OPERATOR

public static final java.lang.String PROP_OPERATOR
See Also:
Constant Field Values

PROP_CONJUNCTION

public static final java.lang.String PROP_CONJUNCTION
See Also:
Constant Field Values

PROP_NESTED_TABLE

public static final java.lang.String PROP_NESTED_TABLE
See Also:
Constant Field Values

Method Detail

get

public java.lang.Object get(java.lang.Object key)
Description copied from class: RuleComponent
Generic property getter inheirited from RuleComponent.

Please see the specific bean class for a list of properties.

Specified by:
get in interface java.util.Map
Overrides:
get in class RuleComponent
Parameters:
key - a String containing the property name to be fetched.
Returns:
the value corresponding to the key: a String, String[], RuleComponent, or RuleComponentTable

put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object value)
Description copied from class: RuleComponent
Generic property setter. Throws runtime exceptions for incorrect arguments. Please see the specific bean class for a list of properties, their types, and permissible values.

A put() with either null key or null value throws a NullPointerException.

A put() with a key that is not a String throws a ClassCastException

A put() of a value that is not of the correct type for the key throws a ClassCastException.

Bean properties which have no set() method are read only, and cannot be modified using the put(). Attempting to do so throws a runtime IllegalArgumentException. PROP_ID, and PROP_*_SELECTED are always read only.

Specified by:
put in interface java.util.Map
Overrides:
put in class RuleComponent
Parameters:
key - the key of the property to set
value - the value of the named property to set
Returns:
the previous value of the property

getSimpleTestLeft

public Expression getSimpleTestLeft(int i)
Shorthand for getSimpleTestTable.getSimpleTest(i).getLeft()
Parameters:
i - ordinal of SimpleTest to retrieve from SimpleTestTable
Returns:
the Expression on the left side of the SimpleTest
Throws:
java.lang.IndexOutOfBoundsException

getSimpleTestRight

public Expression getSimpleTestRight(int i)
Shorthand for getSimpleTestTable.getSimpleTest(i).getRight()
Parameters:
i - ordinal of SimpleTest to retrieve from SimpleTestTable
Returns:
the Expression on the right side of the SimpleTest
Throws:
java.lang.IndexOutOfBoundsException

getSimpleTestOperator

public java.lang.String getSimpleTestOperator(int i)
Shorthand for getSimpleTestTable.getSimpleTest(i).getOperator()
Parameters:
i - ordinal of SimpleTest to retrieve from SimpleTestTable
Returns:
the Operator of the SimpleTest
Throws:
java.lang.IndexOutOfBoundsException

validate

public void validate()
              throws RuleEditorException,
                     RuleEditorSDKException
Description copied from class: RuleComponent
Validates the correctness of the RuleComponent and all RuleComponents below it.
Overrides:
validate in class RuleComponent
Throws:
RuleEditorSDKException - incorrect SDK usage
RuleEditorException - for user input errors

getPropertyNames

public java.lang.String[] getPropertyNames()
Overrides:
getPropertyNames in class RuleComponent

getForm

public java.lang.String getForm()
Get Form describing whether this Pattern simple fact type or a subtable of fact types. See FORM_FACT_TYPE

setForm

public void setForm(java.lang.String form)
Set Form describing whether this Pattern simple fact type or a subtable of fact types. See FORM_FACT_TYPE

getFormConstraint

public java.lang.String getFormConstraint()

setFormConstraint

public void setFormConstraint(java.lang.String formConstraint)

getFormOptions

public java.lang.String[] getFormOptions()

setFormOptions

public void setFormOptions(java.lang.String[] formOptions)

getFormSelected

public int getFormSelected()

getFactType

public java.lang.String getFactType()
Get the alias of the fact type. For use when Form is FORM_FACT_TYPE

setFactType

public void setFactType(java.lang.String factType)
Set the alias of the fact type. For use when Form is FORM_FACT_TYPE

getFactTypeConstraint

public java.lang.String getFactTypeConstraint()

setFactTypeConstraint

public void setFactTypeConstraint(java.lang.String factTypeConstraint)

getFactTypeOptions

public java.lang.String[] getFactTypeOptions()

setFactTypeOptions

public void setFactTypeOptions(java.lang.String[] factTypeOptions)

getFactTypeSelected

public int getFactTypeSelected()

getTestForm

public java.lang.String getTestForm()

setTestForm

public void setTestForm(java.lang.String testForm)

getTestFormConstraint

public java.lang.String getTestFormConstraint()

setTestFormConstraint

public void setTestFormConstraint(java.lang.String testFormConstraint)

getTestFormOptions

public java.lang.String[] getTestFormOptions()

setTestFormOptions

public void setTestFormOptions(java.lang.String[] testFormOptions)

getTestFormSelected

public int getTestFormSelected()

getSimpleTestTable

public SimpleTestTable getSimpleTestTable()
Get the table of tests for this Pattern. For use when Form is FORM_FACT_TYPE. See SimpleTest

getAdvancedExpression

public AdvancedExpression getAdvancedExpression()
Get AdvancedExpression for checking syntax and creating option lists

getVariable

public java.lang.String getVariable()

setVariable

public void setVariable(java.lang.String variable)

getVariableConstraint

public java.lang.String getVariableConstraint()

setVariableConstraint

public void setVariableConstraint(java.lang.String variableConstraint)

getVariableOptions

public java.lang.String[] getVariableOptions()

setVariableOptions

public void setVariableOptions(java.lang.String[] variableOptions)

getVariableSelected

public int getVariableSelected()

getOperator

public java.lang.String getOperator()
Get Pattern operator. See OPERATOR_FORALL. Defaults to OPERATOR_FORALL

setOperator

public void setOperator(java.lang.String operator)
Set Pattern operator. See OPERATOR_FORALL. Defaults to OPERATOR_FORALL

getOperatorConstraint

public java.lang.String getOperatorConstraint()

setOperatorConstraint

public void setOperatorConstraint(java.lang.String operatorConstraint)

getOperatorOptions

public java.lang.String[] getOperatorOptions()

setOperatorOptions

public void setOperatorOptions(java.lang.String[] operatorOptions)

getOperatorSelected

public int getOperatorSelected()

getConjunction

public java.lang.String getConjunction()
Get conjunction which combines this Pattern with the following Pattern, if any. See Util.CONJUNCTION_AND. Defaults to CONJUNCTION_AND.

setConjunction

public void setConjunction(java.lang.String conjunction)
Set conjunction which combines this Pattern with the following Pattern, if any. See Util.CONJUNCTION_AND. Defaults to CONJUNCTION_AND.

getConjunctionConstraint

public java.lang.String getConjunctionConstraint()

setConjunctionConstraint

public void setConjunctionConstraint(java.lang.String conjunctionConstraint)

getConjunctionOptions

public java.lang.String[] getConjunctionOptions()

setConjunctionOptions

public void setConjunctionOptions(java.lang.String[] conjunctionOptions)

getConjunctionSelected

public int getConjunctionSelected()

getNestedTable

public PatternTable getNestedTable()
Get the the Pattern subtable when Form is FORM_NESTED_TABLE. Operators and conjunctions apply to the whole table. FactType and Tests are ignored in this form.

Skip navigation links

Oracle Business Rules Java API Reference
10g (10.1.3.1.0)

B28966-01


Copyright © 2006, Oracle. All rights reserved.