Package org.apache.jena.graph
Interface Graph
-
- All Known Subinterfaces:
BackwardRuleInfGraphI
,ForwardRuleInfGraphI
,GraphWithPerform
,InfGraph
- All Known Implementing Classes:
BaseInfGraph
,BasicForwardRuleInfGraph
,CollectionGraph
,CompositionBase
,Delta
,Difference
,DisjointUnion
,Dyadic
,FBRuleInfGraph
,GraphBase
,GraphMem
,GraphMemBase
,GraphPlain
,Intersection
,LPBackwardRuleInfGraph
,MonitorGraph
,MultiUnion
,Polyadic
,RandomOrderGraph
,RDFSRuleInfGraph
,RETERuleInfGraph
,SafeGraph
,TransitiveInfGraph
,Union
,WrappedGraph
public interface Graph
The interface to be satisfied by implementations maintaining collections of RDF triples. The core interface is small (add, delete, find, contains) and is augmented by additional classes to handle more complicated matters such as event management.- See Also:
for an implementation framework.
-
-
Field Summary
Fields Modifier and Type Field Description static Graph
emptyGraph
An immutable empty graph.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
add(Node s, Node p, Node o)
Add the triple comprised of s,p,o to the set belonging to this graphvoid
add(Triple t)
Add the triple t (if possible) to the set belonging to this graphvoid
clear()
Remove all the statements from this graph.void
close()
Free all resources, any further use of this Graph is an error.boolean
contains(Node s, Node p, Node o)
Answer true iff the graph contains a triple matching (s, p, o).boolean
contains(Triple t)
Answer true iff the graph contains a triple that t matches; t may be fluid.default void
delete(Node s, Node p, Node o)
Delete the triple comprised of s,p,o from the set belonging to this graphvoid
delete(Triple t)
Delete the triple t (if possible) from the set belonging to this graphboolean
dependsOn(Graph other)
true if this graph's content depends on the other graph.default ExtendedIterator<Triple>
find()
Returns an iterator over all Triples in the graph.ExtendedIterator<Triple>
find(Node s, Node p, Node o)
Returns an iterator over Triples matching a pattern.ExtendedIterator<Triple>
find(Triple m)
Returns an iterator over all the Triples that match the triple pattern.Capabilities
getCapabilities()
returns this Graph's capabilitiesGraphEventManager
getEventManager()
Answer this Graph's event manager.PrefixMapping
getPrefixMapping()
returns this Graph's prefix mapping.TransactionHandler
getTransactionHandler()
returns this Graph's transaction handlerboolean
isClosed()
Answer true iff .close() has been called on this Graph.boolean
isEmpty()
Answer true iff this graph is empty.boolean
isIsomorphicWith(Graph g)
Compare this graph with another using the method described in http://www.w3.org/TR/rdf-concepts#section-Graph-syntaxvoid
remove(Node s, Node p, Node o)
Remove all triples that match by find(s, p, o)int
size()
For a concrete graph this returns the number of triples in the graph.default java.util.stream.Stream<Triple>
stream()
Returns aStream
of all triples in the graph.default java.util.stream.Stream<Triple>
stream(Node s, Node p, Node o)
Returns aStream
of Triples matching a pattern.
-
-
-
Field Detail
-
emptyGraph
static final Graph emptyGraph
An immutable empty graph.
-
-
Method Detail
-
dependsOn
boolean dependsOn(Graph other)
true if this graph's content depends on the other graph. May be pessimistic (ie return true if it's not sure). Typically true when a graph is a composition of other graphs, eg union.- Parameters:
other
- the graph this graph may depend on- Returns:
- false if this does not depend on other
-
getTransactionHandler
TransactionHandler getTransactionHandler()
returns this Graph's transaction handler
-
getCapabilities
Capabilities getCapabilities()
returns this Graph's capabilities
-
getEventManager
GraphEventManager getEventManager()
Answer this Graph's event manager.
-
getPrefixMapping
PrefixMapping getPrefixMapping()
returns this Graph's prefix mapping. Each call on a given Graph gets the same PrefixMapping object, which is the one used by the Graph.
-
add
void add(Triple t) throws AddDeniedException
Add the triple t (if possible) to the set belonging to this graph- Parameters:
t
- the triple to add to the graph- Throws:
AddDeniedException
- if the triple cannot be added
-
add
default void add(Node s, Node p, Node o) throws AddDeniedException
Add the triple comprised of s,p,o to the set belonging to this graph- Throws:
AddDeniedException
- if the triple cannot be added
-
delete
void delete(Triple t) throws DeleteDeniedException
Delete the triple t (if possible) from the set belonging to this graph- Parameters:
t
- the triple to delete to the graph- Throws:
DeleteDeniedException
- if the triple cannot be removed
-
delete
default void delete(Node s, Node p, Node o) throws DeleteDeniedException
Delete the triple comprised of s,p,o from the set belonging to this graph- Throws:
AddDeniedException
- if the triple cannot be addedDeleteDeniedException
-
find
ExtendedIterator<Triple> find(Triple m)
Returns an iterator over all the Triples that match the triple pattern.- Parameters:
m
- a Triple encoding the pattern to look for- Returns:
- an iterator of all triples in this graph that match m
-
find
ExtendedIterator<Triple> find(Node s, Node p, Node o)
Returns an iterator over Triples matching a pattern.- Returns:
- an iterator of triples in this graph matching the pattern.
-
stream
default java.util.stream.Stream<Triple> stream(Node s, Node p, Node o)
Returns aStream
of Triples matching a pattern.- Returns:
- a stream of triples in this graph matching the pattern.
-
stream
default java.util.stream.Stream<Triple> stream()
Returns aStream
of all triples in the graph.- Returns:
- a stream of triples in this graph.
-
find
default ExtendedIterator<Triple> find()
Returns an iterator over all Triples in the graph. Equivalent tofind(Node.ANY, Node.ANY, Node.ANY)
- Returns:
- an iterator of all triples in this graph
-
isIsomorphicWith
boolean isIsomorphicWith(Graph g)
Compare this graph with another using the method described in http://www.w3.org/TR/rdf-concepts#section-Graph-syntax- Parameters:
g
- Compare against this.- Returns:
- boolean True if the two graphs are isomorphic.
-
contains
boolean contains(Node s, Node p, Node o)
Answer true iff the graph contains a triple matching (s, p, o). s/p/o may be concrete or fluid. Equivalent to find(s,p,o).hasNext, but an implementation is expected to optimise this in easy cases.
-
contains
boolean contains(Triple t)
Answer true iff the graph contains a triple that t matches; t may be fluid.
-
clear
void clear()
Remove all the statements from this graph.
-
close
void close()
Free all resources, any further use of this Graph is an error.
-
isEmpty
boolean isEmpty()
Answer true iff this graph is empty. "Empty" means "has as few triples as it can manage", because an inference graph may have irremovable axioms and their consequences.
-
size
int size()
For a concrete graph this returns the number of triples in the graph. For graphs which might infer additional triples it results an estimated lower bound of the number of triples. For example, an inference graph might return the number of triples in the raw data graph.
-
isClosed
boolean isClosed()
Answer true iff .close() has been called on this Graph.
-
-