Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.reasoner.rulesys.impl.oldCode
Class RuleState  view RuleState download RuleState.java

java.lang.Object
  extended bycom.hp.hpl.jena.reasoner.rulesys.impl.oldCode.RuleState

public class RuleState
extends java.lang.Object

Part of the backward chaining rule interpreter. A RuleState represents the state of a partially expanded search tree for a single Rule. The RuleStates are linked back in an OR tree to a root goal which is being satisfied. Each RuleState shares a pointer to a RuleInstance which holds references for the rule being processed and the goal which the rule is satisfying.

Encapuslation warning: this object is used in the tight inner loop of the engine so we access its field pointers directly rather than through accessor methods.

Version:
$Revision: 1.4 $ on $Date: 2005/02/21 12:18:05 $

Field Summary
(package private)  int clauseIndex
          The clause number in the rule to be processed next.
protected  com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env
          The binding environment for the rule so far
protected  com.hp.hpl.jena.reasoner.rulesys.Functor functorMatch
          functor node for object binding
protected  GoalState goalState
          The continuation point for the rule clause being processed
protected  boolean isScheduled
          Flag to indicate that rule state is scheduled on the agenda
(package private)  int objectBind
          binding offset for object field, -1 if none
(package private)  int predicateBind
          binding offset for predicate field, -1 if none
protected  RuleState prev
          the parent RuleState for backtracking
protected  RuleInstance ruleInstance
          Reference to a package of information on the rule being processed
(package private)  int subjectBind
          binding offset for subject field, -1 if none
 
Constructor Summary
private RuleState(RuleInstance ruleInstance, com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env, GoalState goalState, int index)
          Constructor used when creating the first RuleState for a rule.
  RuleState(RuleState parent, com.hp.hpl.jena.reasoner.TriplePattern clause, int index, com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
          Normal constructor.
 
Method Summary
 void close()
          Close a non-longer needed rule state.
 boolean couldProcess()
          Return true if it seems worth scheduling this RuleState.
static RuleState createInitialState(com.hp.hpl.jena.reasoner.rulesys.Rule rule, GoalResults generator)
          Create the first RuleState for using a given rule to satisfy a goal.
 com.hp.hpl.jena.graph.Triple getResult(com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector newenv)
          Return the final goal result, based on the given binding environment
private  void initMapping(com.hp.hpl.jena.reasoner.TriplePattern goal)
          Initialize the mapping pointers that map result values to environment bindings
 com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector newEnvironment(com.hp.hpl.jena.graph.Triple result)
          Return a new binding environment based on this one but extended by the matches resulting from the given triple result for this state.
(package private)  java.lang.Object next()
          Return the next match for this clause (or FAIL or SUSPEND)
protected  int nextClauseIndex()
          Return the index of the next body clause to try.
private static int scoreClauseBoundness(com.hp.hpl.jena.reasoner.TriplePattern clause, com.hp.hpl.jena.reasoner.TriplePattern head, com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
          Score a clause in terms of groundedness using simple heurisitcs.
private static int scoreNodeBoundness(com.hp.hpl.jena.graph.Node n, com.hp.hpl.jena.reasoner.TriplePattern head, com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
          Score a node from a pattern as part of scoreClauseBoundedness.
 java.lang.String toString()
          Printable string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ruleInstance

protected RuleInstance ruleInstance
Reference to a package of information on the rule being processed


prev

protected RuleState prev
the parent RuleState for backtracking


env

protected com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env
The binding environment for the rule so far


goalState

protected GoalState goalState
The continuation point for the rule clause being processed


isScheduled

protected boolean isScheduled
Flag to indicate that rule state is scheduled on the agenda


clauseIndex

int clauseIndex
The clause number in the rule to be processed next.


subjectBind

int subjectBind
binding offset for subject field, -1 if none


predicateBind

int predicateBind
binding offset for predicate field, -1 if none


objectBind

int objectBind
binding offset for object field, -1 if none


functorMatch

protected com.hp.hpl.jena.reasoner.rulesys.Functor functorMatch
functor node for object binding

Constructor Detail

RuleState

public RuleState(RuleState parent,
                 com.hp.hpl.jena.reasoner.TriplePattern clause,
                 int index,
                 com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
Normal constructor. Creates a new RuleState as an extension to an existing one.


RuleState

private RuleState(RuleInstance ruleInstance,
                  com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env,
                  GoalState goalState,
                  int index)
Constructor used when creating the first RuleState for a rule. The caller is responsible for initializing the mapping.

Method Detail

next

java.lang.Object next()
Return the next match for this clause (or FAIL or SUSPEND)


newEnvironment

public com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector newEnvironment(com.hp.hpl.jena.graph.Triple result)
Return a new binding environment based on this one but extended by the matches resulting from the given triple result for this state.


getResult

public com.hp.hpl.jena.graph.Triple getResult(com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector newenv)
Return the final goal result, based on the given binding environment


couldProcess

public boolean couldProcess()
Return true if it seems worth scheduling this RuleState. This will be the case if the RS can be immediately disposed of due to being complete or if there is a result known already.


initMapping

private void initMapping(com.hp.hpl.jena.reasoner.TriplePattern goal)
Initialize the mapping pointers that map result values to environment bindings


nextClauseIndex

protected int nextClauseIndex()
Return the index of the next body clause to try. Takes clause reordering into account.


close

public void close()
Close a non-longer needed rule state. This will decrement the reference count of the goal table entry (this might have been the last RuleState working on that entry) and will close any iterators in the goal state.


createInitialState

public static RuleState createInitialState(com.hp.hpl.jena.reasoner.rulesys.Rule rule,
                                           GoalResults generator)
Create the first RuleState for using a given rule to satisfy a goal.


scoreClauseBoundness

private static int scoreClauseBoundness(com.hp.hpl.jena.reasoner.TriplePattern clause,
                                        com.hp.hpl.jena.reasoner.TriplePattern head,
                                        com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
Score a clause in terms of groundedness using simple heurisitcs. For this case we are only considering head variables which occur in the clause and score on boundedness of these.


scoreNodeBoundness

private static int scoreNodeBoundness(com.hp.hpl.jena.graph.Node n,
                                      com.hp.hpl.jena.reasoner.TriplePattern head,
                                      com.hp.hpl.jena.reasoner.rulesys.impl.BindingVector env)
Score a node from a pattern as part of scoreClauseBoundedness.


toString

public java.lang.String toString()
Printable string