/** Answer a human-consumable representation of this graph. Not advised for big graphs, as it generates a big string: intended for debugging purposes. */ @Override public String toString() { return toString( (closed ? "closed " : ""), this ); }
/** Add a triple, and notify the event manager. Subclasses should not need to override this - we might make it final. The triple is added using performAdd, and notification done by notifyAdd. */ @Override public void add( Triple t ) { checkOpen(); performAdd( t ); notifyAdd( t ); }
/** Answer true if the graph contains any triple matching <code>t</code>. The default implementation uses <code>find</code> and checks to see if the iterator is non-empty. */ protected boolean graphBaseContains( Triple t ) { return containsByFind( t ); }
/** Answer <code>true</code> iff <code>t</code> is in the graph as revealed by <code>find(t)</code> being non-empty. <code>t</code> may contain ANY wildcards. Sub-classes may over-ride reifierContains and graphBaseContains for efficiency. */ @Override public final boolean contains( Triple t ) { checkOpen(); return graphBaseContains( t ); }
/** Answer the size of this graph (ie the number of exposed triples). Defined as the size of the triple store plus the size of the reification store. Subclasses must override graphBaseSize() to reimplement (and reifierSize if they have some special reason for redefined that). */ @Override public final int size() { checkOpen() ; return graphBaseSize() ; }
/** Delete a triple, and notify the event manager. Subclasses should not need to override this - we might make it final. The triple is added using performDelete, and notification done by notifyDelete. */ @Override public final void delete( Triple t ) { checkOpen(); performDelete( t ); notifyDelete( t ); }
/** Answer an (extended) iterator over all the triples in this Graph matching <code>m</code>. Subclasses cannot over-ride this, because it implements the appending of reification quadlets; instead they must implement graphBaseFind(TripleMatch). */ @Override public final ExtendedIterator<Triple> find(TripleMatch m) { checkOpen() ; return graphBaseFind(m) ; }
/** Tell the event manager that the triple <code>t</code> has been added to the graph. */ public void notifyAdd( Triple t ) { getEventManager().notifyAddTriple( this, t ); }
/** Close this graph; if it is now fully closed, destroy its resources and run the GraphBase close. */ @Override public void close() { if (--count == 0) { destroy(); super.close(); } }
protected ExtendedIterator<Triple> graphBaseFind( Node s, Node p, Node o ) { return find( Triple.createMatch( s, p, o ) ); }
/** Answer the PrefixMapping object for this graph, the same one each time. */ @Override public PrefixMapping getPrefixMapping() { if ( pm == null ) pm = createPrefixMapping() ; return pm; }
@Override public GraphStatisticsHandler getStatisticsHandler() { if (statisticsHandler == null) statisticsHandler = createStatisticsHandler(); return statisticsHandler; }
/** Answer true iff this graph is isomorphic to <code>g</code> according to the algorithm (indeed, method) in <code>GraphMatcher</code>. */ @Override public boolean isIsomorphicWith( Graph g ) { checkOpen(); return g != null && GraphMatcher.equals( this, g ); }
/** */ @Override public final ExtendedIterator<Triple> find( Node s, Node p, Node o ) { checkOpen(); return graphBaseFind( s, p, o ); }
/** Tell the event manager that the triple <code>t</code> has been deleted from the graph. */ public void notifyDelete( Triple t ) { getEventManager().notifyDeleteTriple( this, t ); }
/** * Free all resources, any further use of this Graph is an error. */ @Override public void close() { if (!closed) { fdata.getGraph().close(); fdata = null; super.close(); } }
/** Utility method: answer true iff we can find at least one instantiation of the triple in this graph using find(TripleMatch). @param t Triple that is the pattern to match @return true iff find(t) returns at least one result */ final protected boolean containsByFind( Triple t ) { ClosableIterator<Triple> it = find( t ); try { return it.hasNext(); } finally { it.close(); } }
/** Answer a human-consumable representation of this graph. Not advised for big graphs, as it generates a big string: intended for debugging purposes. */ @Override public String toString() { return GraphBase.toString("", this) ; // Model m = ModelFactory.createModelForGraph(this) ; // m.setNsPrefixes(PrefixMapping.Standard) ; // StringWriter w = new StringWriter() ; // m.write(w, "TTL") ; // return w.toString() ; } }
/** Remove all the statements from this graph. */ @Override public void clear() { GraphUtil.remove(this, Node.ANY, Node.ANY, Node.ANY) ; getEventManager().notifyEvent(this, GraphEvents.removeAll ) ; }