/** * Free all resources, any further use of this Graph is an error. */ @Override public void close() { if (!closed) { engine = null; fdeductions = null; rules = null; schemaGraph = null; super.close(); } }
/** * Checks whether the graph is prepared and calls {@link #prepare()} if it is not */ protected synchronized void requirePrepared() { if (!this.isPrepared) this.prepare(); } }
/** * Basic pattern lookup interface. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. * @param pattern a TriplePattern to be matched against the data * @return a ExtendedIterator over all Triples in the data set * that match the pattern */ public ExtendedIterator<Triple> find(TriplePattern pattern) { checkOpen(); return findWithContinuation(pattern, fdata); }
@Override public void clear() { getRawGraph().clear() ; discardState(); rebind(); getEventManager().notifyEvent( this, GraphEvents.removeAll ); }
@Override @Deprecated public void remove( Node s, Node p, Node o ) { BaseInfGraph g = (BaseInfGraph) graph; g.getRawGraph().remove( s, p, o ); g.discardState(); g.rebind(); manager.notifyEvent( graph, GraphEvents.remove( s, p, o ) ); }
/** * 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. */ public InfGraph cloneWithPremises(Graph premises) { MultiUnion union = new MultiUnion(); Graph raw = getRawGraph(); union.addGraph( raw ); union.setBaseGraph( raw ); union.addGraph( premises ); Graph schema = getSchemaGraph(); if (schema != null) { if (schema instanceof BaseInfGraph) { BaseInfGraph ischema = (BaseInfGraph)schema; Graph sschema = ischema.getSchemaGraph(); if (sschema != null) union.addGraph( sschema ); Graph rschema = ischema.getRawGraph(); if (rschema != null) union.addGraph( rschema ); } } return getReasoner().bind(union); }
/** * Test the consistency of the bound data. This normally tests * the validity of the bound instance data against the bound * schema data. * @return a ValidityReport structure */ @Override public ValidityReport validate() { checkOpen(); return new StandardValidityReport(); }
/** Inference graphs share the prefix-mapping of their underlying raw graph. @see com.hp.hpl.jena.graph.Graph#getPrefixMapping() */ @Override public PrefixMapping getPrefixMapping() { return getRawGraph().getPrefixMapping(); }
/** * Returns an iterator over Triples. * This implementation assumes that the underlying findWithContinuation * will have also consulted the raw data. */ @Override public ExtendedIterator<Triple> graphBaseFind(Node subject, Node property, Node object) { return findWithContinuation(new TriplePattern(subject, property, object), fdata); }
/** Answer the InfCapabilities of this InfGraph. */ @Override public Capabilities getCapabilities() { if (capabilities == null) { return getReasoner().getGraphCapabilities(); } else { return capabilities; } }
/** * 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. * @param 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 * @param property the property to be retrieved or null * @param object the object Node of the query triple, may be a Node in * the graph or a node in the parameter micro-graph. * @param param a small graph encoding an expression which the subject and/or * object nodes refer. */ @Override public ExtendedIterator<Triple> find(Node subject, Node property, Node object, Graph param) { return cloneWithPremises(param).find(subject, property, object); }
/** * A convenience version of getGlobalProperty which can only return * a boolean result. */ @Override public boolean testGlobalProperty(Node property) { Node resultNode = getGlobalProperty(property); if (resultNode.isLiteral()) { Object result = resultNode.getLiteralValue(); if (result instanceof Boolean) { return ((Boolean)result).booleanValue(); } } throw new ReasonerException("Global property test returned non-boolean value" + "\nTest was: " + property + "\nResult was: " + resultNode); }
@Override @Deprecated public void removeAll() { BaseInfGraph g = (BaseInfGraph) graph; g.getRawGraph().clear(); g.discardState(); g.rebind(); g.getEventManager().notifyEvent( g, GraphEvents.removeAll ); } }
/** * Return the number of triples in the just the base graph */ @Override public int graphBaseSize() { checkOpen(); return fdata.getGraph().size(); }
protected TransactionHandler getBaseHandler() { return base.getRawGraph().getTransactionHandler(); }
@Override public void remove( Node s, Node p, Node o ) { getRawGraph().remove( s, p, o ); discardState(); rebind(); getEventManager().notifyEvent( this, GraphEvents.remove( s, p, o ) ); }
public void prepare(boolean doConsistencyCheck) { if( isPrepared() ) { return; } if( log.isLoggable( Level.FINE ) ) { log.fine( "Preparing PelletInfGraph..." ); } load(); kb.prepare(); if( doConsistencyCheck ) { kb.isConsistent(); } if( log.isLoggable( Level.FINE ) ) { log.fine( "done." ); } super.prepare(); }
public void close(boolean recursive) { if (closed) return; if (recursive) super.close(); else closed = true; if( deductionsGraph != null ) { deductionsGraph.close(); deductionsGraph = null; } clear(); graphListener.dispose(); graphListener = null; kb = null; }