001: /******************************************************************
002: * File: RuleContext.java
003: * Created by: Dave Reynolds
004: * Created on: 28-Apr-03
005: *
006: * (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
007: * [See end of file]
008: * $Id: RuleContext.java,v 1.12 2008/01/02 12:07:47 andy_seaborne Exp $
009: *****************************************************************/package com.hp.hpl.jena.reasoner.rulesys;
010:
011: import com.hp.hpl.jena.reasoner.InfGraph;
012: import com.hp.hpl.jena.util.iterator.ClosableIterator;
013: import com.hp.hpl.jena.graph.*;
014:
015: /**
016: * Interface used to convey context information from a rule engine
017: * to the stack of procedural builtins. This gives access
018: * to the triggering rule, the variable bindings and the set of
019: * currently known triples.
020: *
021: * @author <a href="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
022: * @version $Revision: 1.12 $ on $Date: 2008/01/02 12:07:47 $
023: */
024: public interface RuleContext {
025: /**
026: * Returns the current variable binding environment for the current rule.
027: * @return BindingEnvironment
028: */
029: public BindingEnvironment getEnv();
030:
031: /**
032: * Returns the parent inference graph.
033: * @return InfGraph
034: */
035: public InfGraph getGraph();
036:
037: /**
038: * Returns the rule.
039: * @return Rule
040: */
041: public Rule getRule();
042:
043: /**
044: * Sets the rule.
045: * @param rule The rule to set
046: */
047: public void setRule(Rule rule);
048:
049: /**
050: * Return true if the triple is already in either the graph or the stack.
051: * I.e. it has already been deduced.
052: */
053: public boolean contains(Triple t);
054:
055: /**
056: * Return true if the triple pattern is already in either the graph or the stack.
057: * I.e. it has already been deduced.
058: */
059: public boolean contains(Node s, Node p, Node o);
060:
061: /**
062: * In some formulations the context includes deductions that are not yet
063: * visible to the underlying graph but need to be checked for.
064: */
065: public ClosableIterator find(Node s, Node p, Node o);
066:
067: /**
068: * Assert a new triple in the deduction graph, bypassing any processing machinery.
069: */
070: public void silentAdd(Triple t);
071:
072: /**
073: * Assert a new triple in the deduction graph, triggering any consequent processing as appropriate.
074: */
075: public void add(Triple t);
076:
077: /**
078: * Remove a triple from the deduction graph (and the original graph if relevant).
079: */
080: public void remove(Triple t);
081: }
082:
083: /*
084: (c) Copyright 2003, 2004, 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
085: All rights reserved.
086:
087: Redistribution and use in source and binary forms, with or without
088: modification, are permitted provided that the following conditions
089: are met:
090:
091: 1. Redistributions of source code must retain the above copyright
092: notice, this list of conditions and the following disclaimer.
093:
094: 2. Redistributions in binary form must reproduce the above copyright
095: notice, this list of conditions and the following disclaimer in the
096: documentation and/or other materials provided with the distribution.
097:
098: 3. The name of the author may not be used to endorse or promote products
099: derived from this software without specific prior written permission.
100:
101: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
102: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
103: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
104: IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
105: INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
106: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
107: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
108: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
109: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
110: THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
111: */
|