public interface IRule<E> extends IStep
IPredicate
s with optional IConstraint
s.Modifier and Type | Method and Description |
---|---|
IBindingSet |
getConstants()
Returns any variables that were bound to constants when an
IRule
was specialized . |
IConstraint |
getConstraint(int index)
Return the constraint at the given index.
|
int |
getConstraintCount()
The #of constraints on the legal states for bindings of the variables
declared by rule.
|
Iterator<IConstraint> |
getConstraints()
The optional constraints.
|
IPredicate |
getHead()
The head of the rule -or-
null iff there is no head for
this rule. |
String |
getName()
The name of the rule.
|
int |
getRequiredVariableCount()
The #of distinct required variables declared by the rule.
|
Iterator<IVariable> |
getRequiredVariables()
The required variables declared by the rule in no particular order.
|
Set<IVariable<?>> |
getSharedVars(int index1,
int index2)
Return the variables in common for two
IPredicate s. |
Iterator<IPredicate> |
getTail()
Iterator visits the
IPredicate s in the body (ala tail) of the
rule. |
IPredicate |
getTail(int index)
Return the predicate at the given index from the tail of the rule.
|
int |
getTailCount()
The #of
IPredicate s in the body (aka tail) of the rule. |
IRuleTaskFactory |
getTaskFactory()
An optional
IRuleTaskFactory that will be used in place of the
default IRuleTaskFactory to evaluate this rule (optional) |
int |
getVariableCount()
The #of distinct variables declared by the rule.
|
int |
getVariableCount(int index,
IBindingSet bindingSet)
The #of arguments in the selected predicate that are variables (vs
constants) with the given the bindings.
|
Iterator<IVariable> |
getVariables()
The variables declared by the rule in no particular order.
|
boolean |
isConsistent(IBindingSet bindingSet)
|
boolean |
isDeclared(IVariable var)
Return
true iff the rule declares this variable. |
boolean |
isFullyBound(IBindingSet bindingSet)
If the rule is fully bound for the given bindings.
|
boolean |
isFullyBound(int index,
IBindingSet bindingSet)
Return true iff the selected predicate is fully bound.
|
IRule<E> |
specialize(IBindingSet bindingSet,
IConstraint[] constraints)
Specialize a rule - the name of the new rule will be derived from the
name of the old rule with an appended single quote to indicate that it is
a derived variant.
|
IRule<E> |
specialize(String name,
IBindingSet bindingSet,
IConstraint[] constraints)
Specialize a rule by binding zero or more variables and adding zero or
more constraints.
|
String |
toString()
Externalizes the rule displaying variable names and constants.
|
String |
toString(IBindingSet bindingSet)
Externalizes the rule displaying variable names, their bindings, and
constants.
|
getQueryOptions, isRule
int getVariableCount()
Iterator<IVariable> getVariables()
int getRequiredVariableCount()
Iterator<IVariable> getRequiredVariables()
IPredicate getHead()
null
iff there is no head for
this rule. Note that rules that are executed as queries DO NOT need to
specify a head. However, rules that will be executed as mutation
operations (insert or delete) MUST specify the head as it determines the
IRelation
on which the rule will write.ActionEnum
int getTailCount()
IPredicate
s in the body (aka tail) of the rule.Iterator<IPredicate> getTail()
IPredicate
s in the body (ala tail) of the
rule.IPredicate getTail(int index)
index
- The index.IndexOutOfBoundsException
int getConstraintCount()
Iterator<IConstraint> getConstraints()
IConstraint getConstraint(int index)
index
- The index.IndexOutOfBoundsException
String toString()
String toString(IBindingSet bindingSet)
bindingSet
- When non-null
, the current variable bindings
will be displayed. Otherwise, the names of variables will be
displayed rather than their bindings.IRule<E> specialize(IBindingSet bindingSet, IConstraint[] constraints)
bindingSet
- Bindings for zero or more free variables in this rule. The
rule will be rewritten such that the variable is replaced by
the binding throughout the rule. An attempt to bind a variable
not declared by the rule will be ignored.constraints
- An array of additional constraints to be imposed on the rule
(optional).IllegalArgumentException
- if bindingSet is null
.IRule<E> specialize(String name, IBindingSet bindingSet, IConstraint[] constraints)
bindingSet
- Bindings for zero or more free variables in this rule. The
rule will be rewritten such that the variable is replaced by
the binding throughout the rule. An attempt to bind a variable
not declared by the rule will be ignored.constraints
- An array of additional constraints to be imposed on the rule
(optional).IllegalArgumentException
- if name is null
.IllegalArgumentException
- if bindingSet is null
.IBindingSet getConstants()
IRule
was specialized
.
Note: IJoinNexus.newBindingSet(IRule)
MUST apply the constants
before returning the bindings to the caller.
Set<IVariable<?>> getSharedVars(int index1, int index2)
IPredicate
s.index1
- The index of a predicate in the #tail
.index2
- The index of a different predicate in the #tail
.null
iff there are no
variables in common.IllegalArgumentException
- if the two predicate indices are the same.IndexOutOfBoundsException
- if either index is out of bounds.boolean isFullyBound(int index, IBindingSet bindingSet)
index
- The index of a predicate declared the tail
of the IRule
.bindingSet
- The variable bindings.IndexOutOfBoundsException
- if the index is out of bounds.IllegalArgumentException
- if bindingSet is null
.boolean isFullyBound(IBindingSet bindingSet)
bindingSet
- The bindings.int getVariableCount(int index, IBindingSet bindingSet)
boolean isConsistent(IBindingSet bindingSet)
bindingSet
- The binding set.true
unless a constraint is violated by the
bindings.boolean isDeclared(IVariable var)
true
iff the rule declares this variable.var
- Some variable.IllegalArgumentException
- if var is null
.IRuleTaskFactory getTaskFactory()
IRuleTaskFactory
that will be used in place of the
default IRuleTaskFactory
to evaluate this rule (optional)null
unless custom evaluation is desired.Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.