com.hp.hpl.jena.graph
Class GraphUtil

java.lang.Object
  extended by com.hp.hpl.jena.graph.GraphUtil

public class GraphUtil
extends Object

An ad-hoc collection of useful code for graphs


Method Summary
static void add(Graph graph, Iterator<Triple> it)
           
static void add(Graph graph, List<Triple> triples)
           
static void add(Graph graph, Triple[] triples)
           
static void addInto(Graph dstGraph, Graph srcGraph)
          Add triples into the destination (arg 1) from the source (arg 2)
static boolean containsNode(Graph graph, Node node)
          Does the graph use the node anywhere as a subject, predciate or object?
static void delete(Graph graph, Iterator<Triple> it)
           
static void delete(Graph graph, List<Triple> triples)
           
static void delete(Graph graph, Triple[] triples)
           
static void deleteFrom(Graph dstGraph, Graph srcGraph)
          Delete triples the destination (arg 1) as given in the source (arg 2)
static com.hp.hpl.jena.util.iterator.ExtendedIterator<Triple> findAll(Graph g)
          Answer an iterator covering all the triples in the specified graph.
static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listObjects(Graph g, Node s, Node p)
          Return an iterator over the unique objects with a given subject and object.
static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listPredicates(Graph g, Node s, Node o)
          Return an iterator over the unique predicate between s and o.
static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listSubjects(Graph g, Node p, Node o)
          Return an iterator over the unique subjects with predciate p and object o.
static void remove(Graph g, Node s, Node p, Node o)
          A safe and cautious remve() function.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

listSubjects

public static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listSubjects(Graph g,
                                                                                Node p,
                                                                                Node o)
Return an iterator over the unique subjects with predciate p and object o. p and o can be wildcards (Node.ANY)

Parameters:
g - Graph
p - Predicate - may be Node.ANY
o - Object - may be Node.ANY
Returns:
ExtendedIterator

listPredicates

public static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listPredicates(Graph g,
                                                                                  Node s,
                                                                                  Node o)
Return an iterator over the unique predicate between s and o. s and o can be wildcards (Node.ANY)

Parameters:
g - Graph
s - Subject - may be Node.ANY
o - Object - may be Node.ANY
Returns:
ExtendedIterator

listObjects

public static com.hp.hpl.jena.util.iterator.ExtendedIterator<Node> listObjects(Graph g,
                                                                               Node s,
                                                                               Node p)
Return an iterator over the unique objects with a given subject and object. s and p can be wildcards (Node.ANY)

Parameters:
g - Graph
s - Subject - may be Node.ANY
p - Predicate - may be Node.ANY
Returns:
ExtendedIterator

containsNode

public static boolean containsNode(Graph graph,
                                   Node node)
Does the graph use the node anywhere as a subject, predciate or object?


findAll

public static com.hp.hpl.jena.util.iterator.ExtendedIterator<Triple> findAll(Graph g)
Answer an iterator covering all the triples in the specified graph.

Parameters:
g - the graph from which to extract triples
Returns:
an iterator over all the graph's triples

add

public static void add(Graph graph,
                       Triple[] triples)

add

public static void add(Graph graph,
                       List<Triple> triples)

add

public static void add(Graph graph,
                       Iterator<Triple> it)

addInto

public static void addInto(Graph dstGraph,
                           Graph srcGraph)
Add triples into the destination (arg 1) from the source (arg 2)


delete

public static void delete(Graph graph,
                          Triple[] triples)

delete

public static void delete(Graph graph,
                          List<Triple> triples)

delete

public static void delete(Graph graph,
                          Iterator<Triple> it)

deleteFrom

public static void deleteFrom(Graph dstGraph,
                              Graph srcGraph)
Delete triples the destination (arg 1) as given in the source (arg 2)


remove

public static void remove(Graph g,
                          Node s,
                          Node p,
                          Node o)
A safe and cautious remve() function. To avoid any possible ConcurrentModificationExceptions, it finds batches of triples, deletes them and tries again until no change occurs.



Licenced under the Apache License, Version 2.0