com.hp.hpl.jena.reasoner
Class BaseInfGraph

java.lang.Object
  extended bycom.hp.hpl.jena.graph.impl.GraphBase
      extended bycom.hp.hpl.jena.reasoner.BaseInfGraph
All Implemented Interfaces:
Graph, InfGraph
Direct Known Subclasses:
RDFSInfGraph, TransitiveInfGraph

public abstract class BaseInfGraph
extends com.hp.hpl.jena.graph.impl.GraphBase
implements InfGraph

A base level implementation of the InfGraph interface.

Version:
$Revision: 1.16 $ on $Date: 2003/06/24 15:46:59 $
Author:
Dave Reynolds

Field Summary
 
Fields inherited from interface com.hp.hpl.jena.graph.Graph
ADD, DELETE, ORDERED, SIZE
 
Constructor Summary
BaseInfGraph(Graph data, Reasoner reasoner)
          Constructor
 
Method Summary
 void add(Triple t)
          Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.
 int capabilities()
          Returns the bitwise or of ADD, DELETE, SIZE and ORDERED, to show the capabilities of this implementation of Graph.
 InfGraph cloneWithPremises(Graph premises)
          Return a new inference graph which is a clone of the current graph together with an additional set of data premises.
 boolean contains(Node s, Node p, Node o)
          Test if the graph contains the given triple.
 boolean contains(Triple t)
          Test if the graph contains the given triple.
 void delete(Triple t)
          Removes the triple t (if possible) from the set belonging to this graph.
 ExtendedIterator find(Node subject, Node property, Node object)
          Returns an iterator over Triples.
 ExtendedIterator find(Node subject, Node property, Node object, Graph param)
          An extension of the Graph.find interface which allows the caller to encode complex expressions in RDF and then refer to those expressions within the query triple.
 ExtendedIterator find(TripleMatch m)
          Returns an iterator over Triples.
 ExtendedIterator find(TriplePattern pattern)
          Basic pattern lookup interface.
abstract  ExtendedIterator findWithContinuation(TriplePattern pattern, Finder continuation)
          Extended find interface used in situations where the implementator may or may not be able to answer the complete query.
 java.util.Iterator getDerivation(Triple triple)
          Return the derivation of the given triple (which is the result of some previous find operation).
 Node getGlobalProperty(Node property)
          Test a global boolean property of the graph.
 Graph getRawGraph()
          Return the raw RDF data Graph being processed (i.e. the argument to the Reasonder.bind call that created this InfGraph).
 Reasoner getReasoner()
          Return the Reasoner which is being used to answer queries to this graph.
abstract  Graph getSchemaGraph()
          Return the schema graph, if any, bound into this inference graph.
 void prepare()
          Perform any initial processing and caching.
 void rebind()
          Cause the inference graph to reconsult the underlying graph to take into account changes.
 void rebind(Graph data)
          Replace the underlying data graph for this inference graph and start any inferences over again.
 void reset()
          Reset any internal caches.
 void setDerivationLogging(boolean logOn)
          Switch on/off drivation logging
 int size()
          Return the number of triples in the just the base graph
 boolean testGlobalProperty(Node property)
          A convenience version of getGlobalProperty which can only return a boolean result.
 ValidityReport validate()
          Test the consistency of the bound data.
 
Methods inherited from class com.hp.hpl.jena.graph.impl.GraphBase
close, dependsOn, getBulkUpdateHandler, getCapabilities, getEventManager, getPrefixMapping, getReifier, getTransactionHandler, isIsomorphicWith, notifyAdd, notifyDelete, performAdd, performDelete, queryHandler, toString, withReification
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.jena.graph.Graph
close, dependsOn, getBulkUpdateHandler, getCapabilities, getEventManager, getPrefixMapping, getReifier, getTransactionHandler, isIsomorphicWith, queryHandler
 

Constructor Detail

BaseInfGraph

public BaseInfGraph(Graph data,
                    Reasoner reasoner)
Constructor

Parameters:
data - the raw data file to be augmented with entailments
reasoner - the engine, with associated tbox data, whose find interface can be used to extract all entailments from the data.
Method Detail

getRawGraph

public Graph getRawGraph()
Return the raw RDF data Graph being processed (i.e. the argument to the Reasonder.bind call that created this InfGraph).

Specified by:
getRawGraph in interface InfGraph

getReasoner

public Reasoner getReasoner()
Return the Reasoner which is being used to answer queries to this graph.

Specified by:
getReasoner in interface InfGraph

rebind

public void rebind(Graph data)
Replace the underlying data graph for this inference graph and start any inferences over again. This is primarily using in setting up ontology imports processing to allow an imports multiunion graph to be inserted between the inference graph and the raw data, before processing.

Specified by:
rebind in interface InfGraph
Parameters:
data - the new raw data graph

rebind

public void rebind()
Cause the inference graph to reconsult the underlying graph to take into account changes. Normally changes are made through the InfGraph's add and remove calls are will be handled appropriately. However, in some cases changes are made "behind the InfGraph's back" and this forces a full reconsult of the changed data.

Specified by:
rebind in interface InfGraph

reset

public void reset()
Reset any internal caches. Some systems, such as the tabled backchainer, retain information after each query. A reset will wipe this information preventing unbounded memory use at the expense of more expensive future queries. A reset does not cause the raw data to be reconsulted and so is less expensive than a rebind.

Specified by:
reset in interface InfGraph

prepare

public void prepare()
Perform any initial processing and caching. This call is optional. Most engines either have negligable set up work or will perform an implicit "prepare" if necessary. The call is provided for those occasions where substantial preparation work is possible (e.g. running a forward chaining rule system) and where an application might wish greater control over when this prepration is done.

Specified by:
prepare in interface InfGraph

getGlobalProperty

public Node getGlobalProperty(Node property)
Test a global boolean property of the graph. This might included properties like consistency, OWLSyntacticValidity etc. It remains to be seen what level of generality is needed here. We could replace this by a small number of specific tests for common concepts.

Specified by:
getGlobalProperty in interface InfGraph
Parameters:
property - the URI of the property to be tested
Returns:
a Node giving the value of the global property, this may be a boolean literal, some other literal value (e.g. a size).

testGlobalProperty

public boolean testGlobalProperty(Node property)
A convenience version of getGlobalProperty which can only return a boolean result.

Specified by:
testGlobalProperty in interface InfGraph

validate

public ValidityReport validate()
Test the consistency of the bound data. This normally tests the validity of the bound instance data against the bound schema data.

Specified by:
validate in interface InfGraph
Returns:
a ValidityReport structure

find

public ExtendedIterator find(Node subject,
                             Node property,
                             Node object,
                             Graph param)
An extension of the Graph.find interface which allows the caller to encode complex expressions in RDF and then refer to those expressions within the query triple. For example, one might encode a class expression and then ask if there are any instances of this class expression in the InfGraph.

Specified by:
find in interface InfGraph
Parameters:
subject - the subject Node of the query triple, may be a Node in the graph or a node in the parameter micro-graph or null
property - the property to be retrieved or null
object - the object Node of the query triple, may be a Node in the graph or a node in the parameter micro-graph.
param - a small graph encoding an expression which the subject and/or object nodes refer.

find

public ExtendedIterator find(TripleMatch m)
Returns an iterator over Triples.

Specified by:
find in interface Graph
See Also:
Graph.find(TripleMatch)

findWithContinuation

public abstract ExtendedIterator findWithContinuation(TriplePattern pattern,
                                                      Finder continuation)
Extended find interface used in situations where the implementator may or may not be able to answer the complete query. It will attempt to answer the pattern but if its answers are not known to be complete then it will also pass the request on to the nested Finder to append more results.

Parameters:
pattern - a TriplePattern to be matched against the data
continuation - either a Finder or a normal Graph which will be asked for additional match results if the implementor may not have completely satisfied the query.

find

public ExtendedIterator find(Node subject,
                             Node property,
                             Node object)
Returns an iterator over Triples. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data.

Specified by:
find in interface Graph
See Also:
Graph.find(Node, Node, Node)

find

public ExtendedIterator find(TriplePattern pattern)
Basic pattern lookup interface. This implementation assumes that the underlying findWithContinuation will have also consulted the raw data.

Parameters:
pattern - a TriplePattern to be matched against the data
Returns:
a ExtendedIterator over all Triples in the data set that match the pattern

contains

public boolean contains(Triple t)
Test if the graph contains the given triple. Overridden in order to implement semantic instead of syntactic equivalance.

Specified by:
contains in interface Graph

contains

public boolean contains(Node s,
                        Node p,
                        Node o)
Test if the graph contains the given triple. Overridden in order to implement semantic instead of syntactic equivalance.

Specified by:
contains in interface Graph

setDerivationLogging

public void setDerivationLogging(boolean logOn)
Switch on/off drivation logging

Specified by:
setDerivationLogging in interface InfGraph

getDerivation

public java.util.Iterator getDerivation(Triple triple)
Return the derivation of the given triple (which is the result of some previous find operation). Not all reasoneers will support derivations.

Specified by:
getDerivation in interface InfGraph
Returns:
an iterator over Derivation records or null if there is no derivation information available for this triple.

size

public int size()
Return the number of triples in the just the base graph

Specified by:
size in interface Graph
See Also:
Graph.size()

add

public void add(Triple t)
Add one triple to the data graph, run any rules triggered by the new data item, recursively adding any generated triples.

Specified by:
add in interface Graph

capabilities

public int capabilities()
Returns the bitwise or of ADD, DELETE, SIZE and ORDERED, to show the capabilities of this implementation of Graph. So a read-only graph that finds in an unordered fashion, but can tell you how many triples are in the graph returns SIZE.

Specified by:
capabilities in interface Graph
See Also:
Graph.capabilities()

delete

public void delete(Triple t)
Removes the triple t (if possible) from the set belonging to this graph.

Specified by:
delete in interface Graph
See Also:
Graph.delete(Triple)

getSchemaGraph

public abstract Graph getSchemaGraph()
Return the schema graph, if any, bound into this inference graph.


cloneWithPremises

public InfGraph cloneWithPremises(Graph premises)
Return a new inference graph which is a clone of the current graph together with an additional set of data premises. The default implementation loses ALL partial deductions so far. Some subclasses may be able to a more efficient job.



Copyright © 2001-2003 Hewlett-Packard. All Rights Reserved.