java.lang.Object
org.apache.jena.system.G
A library of functions for working with
Graph
. Internally all
ExtendedIterators
used, run to completion or have
.close()
called. Any ExtendedIterators
returned
by functions in this library must be used in the same way-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addInto
(org.apache.jena.graph.Graph dstGraph, org.apache.jena.graph.Graph srcGraph) Add triples into the destination (arg 1) from the source (arg 2)static Set<org.apache.jena.graph.Node>
allNodesOfTypeRDFS
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List all the node of type, including considering rdfs:subClassOfstatic <X> boolean
allNonNull
(X... objects) Are all the arguments non-null?static Set<org.apache.jena.graph.Node>
allPO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Return a set of all subjects for predicate-objectstatic Set<org.apache.jena.graph.Node>
allSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Return a set of all objects for subject-predicatestatic Set<org.apache.jena.graph.Node>
allTypesOfNodeRDFS
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List all the types of a node, including super-classes.static void
Apply an action to every triple of a graph.static void
apply
(org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> iter, Consumer<org.apache.jena.graph.Triple> action) Apply an action to every triple of an iterator.static String
asString
(org.apache.jena.graph.Node x) Get a string, assuming the node is an xsd:string literal.static <X> X
atMostOne
(X... objects) Is one or none of the arguments non-null?static <X> X
Execute a graph transaction and result result if the graph supports transactions else execute and return without a transaction wrapper.static void
clear
(org.apache.jena.graph.Graph graph) Clear graph.static boolean
contains
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Does the graph match the s/p/o pattern?static boolean
containsByLang
(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Contains, and language tags compare case-insentivelystatic boolean
containsBySameTerm
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Test whether a graph contains by "same term", regardless of whether the graph implements "same value" or "same term".static boolean
containsBySameTerm
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Triple triple) Test whether a graph contains by "same term", regardless of whether the graph implements "same value" or "same term".static boolean
containsNode
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Does the graph use the node anywhere as a subject, predicate or object?static boolean
containsOne
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Contains exactly one.static org.apache.jena.graph.Graph
copy
(org.apache.jena.graph.Graph src) Creates a copy of the given graph.static void
copyGraphSrcToDst
(org.apache.jena.graph.Graph src, org.apache.jena.graph.Graph dst) Add src to dst - assumes transaction.static long
count
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Count occurrences of the pattern.static <X> int
countNonNulls
(X... objects) Count non-nullsstatic long
countPO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Count matches of predicate-object (which can be wildcards).static long
countSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Count matches of subject-predicate (which can be wildcards).static void
deleteModify
(org.apache.jena.graph.Graph modify, org.apache.jena.graph.Graph srcGraph) Delete triples in the graph-to-modify (arg 1) that are in the source (arg 2).static <X> boolean
exactlyOneSet
(X... objects) Is one and only one argument non-null?static void
Execute a graph transaction if the graph supports transactions else apply without a transaction wrapper.static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple>
find
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Graph.find(Node, Node, Node)
as a function.static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple>
findAll
(org.apache.jena.graph.Graph graph) Graph.find()
as a function.static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple>
findByLang
(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Contains, and language tags match case-insentivelystatic void
findExec
(org.apache.jena.graph.Graph graph, Consumer<org.apache.jena.graph.Triple> action, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Find triples and execute an action on each triple found.static org.apache.jena.graph.Triple
getOne
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o, else throw RDFDataException.static Quad
getOne
(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get quad if there is exactly one to match the s/p/o, else throw RDFDataException.static List<org.apache.jena.graph.Node>
getOneOrList
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Return a java list where thenode
is an RDF list of nodes or a single node (returned a singleton list).static org.apache.jena.graph.Triple
getOneOrNull
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; else return null if none or more than one.static Quad
getOneOrNull
(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; else return null if none or more than one.static org.apache.jena.graph.Node
getOnePO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject for predicate-object.static org.apache.jena.graph.Node
getOneSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object for subject-predicate.static org.apache.jena.graph.Node
getPO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject, given predicate and object.static org.apache.jena.graph.Node
getSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object, given subject and predicate.static org.apache.jena.graph.Triple
getZeroOrOne
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; return null if none; throw RDFDataException if more than one.static Quad
getZeroOrOne
(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; return null if none; throw RDFDataException if more than one.static org.apache.jena.graph.Node
getZeroOrOnePO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject for predicate-object.static org.apache.jena.graph.Node
getZeroOrOneSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object for subject-predicate.static boolean
hasDatatype
(org.apache.jena.graph.Node n, org.apache.jena.datatypes.RDFDatatype datatype) Return true if n is a literal and it has the given datatype, else return false.static boolean
hasLang
(org.apache.jena.graph.Node node) Test whether a node has a language tag.static boolean
hasOnePO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Test whether there is exactly one subject for the predicate-object.static boolean
hasOneSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Test whether there is exactly one object for the subject-predicate.static boolean
hasProperty
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Does nodes
have propertyp
in graphg
?static boolean
hasType
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, org.apache.jena.graph.Node type) Does the node x have the given type (non-RDFS - no rdfs:subclassOf considered)?static boolean
isBlank
(org.apache.jena.graph.Node n) static boolean
isBoolean
(org.apache.jena.graph.Node n) static boolean
isLiteral
(org.apache.jena.graph.Node n) static boolean
isNodeGraph
(org.apache.jena.graph.Node n) static boolean
isNodeTriple
(org.apache.jena.graph.Node n) static boolean
isNullOrAny
(org.apache.jena.graph.Node n) static boolean
isOfType
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, org.apache.jena.graph.Node type) Test whether the node has the type or one of its types is an rdfs:subclassOf the type.static boolean
isResource
(org.apache.jena.graph.Node n) static boolean
isString
(org.apache.jena.graph.Node n) static boolean
isURI
(org.apache.jena.graph.Node n) static Iterator<org.apache.jena.graph.Node>
iterObjects
(org.apache.jena.graph.Graph graph) List the objects in a graph (no duplicates)static Iterator<org.apache.jena.graph.Node>
iterObjectsOfPredicate
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate) List the objects in a graph (no duplicates)static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
iterPO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) ExtendedIterator
of subjects where the triple matches for predicate and object (which can be wildcards).static Iterator<org.apache.jena.graph.Node>
iterPredicates
(org.apache.jena.graph.Graph graph) List the predicates in a graph (no duplicates)static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node>
iterSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) ExtendedIterator
of objects where the triple matches for subject and predicate (which can be wildcards).static Iterator<org.apache.jena.graph.Node>
iterSubjects
(org.apache.jena.graph.Graph graph) List the subjects in a graph (no duplicates)static Iterator<org.apache.jena.graph.Node>
iterSubjectsOfPredicate
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate) List the subjects of a predicate in a graph (no duplicates)static List<org.apache.jena.graph.Node>
listNodesOfTypeRDFS
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List all the nodes of type, including nodes of sub-classes.static List<org.apache.jena.graph.Node>
listPO
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) List of subjects matching the predicate-object (which can be wildcards).static List<org.apache.jena.graph.Node>
listSP
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) List of objects matching the subject-predicate (which can be wildcards).static List<org.apache.jena.graph.Node>
listSubClasses
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the subclasses of a type, including itself.static List<org.apache.jena.graph.Node>
listSuperClasses
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the super-classes of a type, including itself.static List<org.apache.jena.graph.Node>
listTypesOfNodeRDFS
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List the types of a node, following rdfs:subClassOf for super classes.static List<org.apache.jena.graph.Node>
nodesOfTypeAsList
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the subjects with exactlytype
.static Set<org.apache.jena.graph.Node>
nodesOfTypeAsSet
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of nodes with exactlytype
.static org.apache.jena.graph.Node
nullAsAny
(org.apache.jena.graph.Node x) Convert null to Node.ANY, otherwise return the original node so that==
may be used to test whether any change has occurred.static org.apache.jena.graph.Triple
nullAsAny
(org.apache.jena.graph.Triple triple) Convert any null terms in a triple to "ANY".static Quad
Convert any null terms in a quad to "ANY".static org.apache.jena.graph.Node
nullAsDft
(org.apache.jena.graph.Node x, org.apache.jena.graph.Node dft) Convert null to some default Node, otherwise return the original node so that==
may be used to test whether any change has occurred.static org.apache.jena.graph.Node
object
(org.apache.jena.graph.Triple triple) Return the object of a triple, or null if the triple is null.static long
objectConnectiveness
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node object) Count the number of in-arc to an objectstatic boolean
oneConnected
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node object) Test whether an object has exactly one in-arc.static org.apache.jena.graph.Node
predicate
(org.apache.jena.graph.Triple triple) Return the predicate of a triple, or null if the triple is null.static Iterator<org.apache.jena.graph.Node>
quad2graphName
(Iterator<Quad> iter) Project quad to graph namestatic Iterator<org.apache.jena.graph.Node>
quad2object
(Iterator<Quad> iter) Project quad to objectstatic Iterator<org.apache.jena.graph.Node>
quad2predicate
(Iterator<Quad> iter) Project quad to predicatestatic Iterator<org.apache.jena.graph.Node>
quad2subject
(Iterator<Quad> iter) Project quad to subjectstatic org.apache.jena.atlas.iterator.Iter<org.apache.jena.graph.Triple>
quads2triples
(Iterator<Quad> iter) Project quads to triplesstatic List<org.apache.jena.graph.Node>
rdfList
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Return a java list for an RDF list of data.static boolean
sameTermMatch
(org.apache.jena.graph.Node match, org.apache.jena.graph.Node data) Match a node, which can be a wildcard (ANY or null) against a ground RDF Term (ANY and variables are considered ground terms in the data term).static boolean
sameTermMatch
(org.apache.jena.graph.Node matchSubj, org.apache.jena.graph.Node matchPred, org.apache.jena.graph.Node matchObj, org.apache.jena.graph.Triple dataTriple) Match S/P/O which can be wildcards (ANY or null), against a ground triple (even ANY and variables are considered ground terms in the data triple).static Set<org.apache.jena.graph.Node>
subClasses
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of the subclasses of a type, including itself.static org.apache.jena.graph.Node
subject
(org.apache.jena.graph.Triple triple) Return the subject of a triple, or null if the triple is null.static Set<org.apache.jena.graph.Node>
superClasses
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of the subclasses of a type, including itself.static Iterator<org.apache.jena.graph.Node>
triple2object
(Iterator<org.apache.jena.graph.Triple> iter) Project triple to objectstatic Iterator<org.apache.jena.graph.Node>
triple2predicate
(Iterator<org.apache.jena.graph.Triple> iter) Project triple to predicatestatic Iterator<org.apache.jena.graph.Node>
triple2subject
(Iterator<org.apache.jena.graph.Triple> iter) Project triple to subjectstatic org.apache.jena.atlas.iterator.Iter<Quad>
triples2quads
(org.apache.jena.graph.Node graphNode, Iterator<org.apache.jena.graph.Triple> iter) Convert an iterator of triples into quads for the specified graph name.static org.apache.jena.atlas.iterator.Iter<Quad>
triples2quadsDftGraph
(Iterator<org.apache.jena.graph.Triple> iter) Convert an iterator of triples into quads for the default graph.static List<org.apache.jena.graph.Node>
typesOfNodeAsList
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List the types of a node/subject.static Set<org.apache.jena.graph.Node>
typesOfNodeAsSet
(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Set of exact types of a node.
-
Method Details
-
subject
public static org.apache.jena.graph.Node subject(org.apache.jena.graph.Triple triple) Return the subject of a triple, or null if the triple is null. -
predicate
public static org.apache.jena.graph.Node predicate(org.apache.jena.graph.Triple triple) Return the predicate of a triple, or null if the triple is null. -
object
public static org.apache.jena.graph.Node object(org.apache.jena.graph.Triple triple) Return the object of a triple, or null if the triple is null. -
isURI
public static boolean isURI(org.apache.jena.graph.Node n) -
isBlank
public static boolean isBlank(org.apache.jena.graph.Node n) -
isLiteral
public static boolean isLiteral(org.apache.jena.graph.Node n) -
isResource
public static boolean isResource(org.apache.jena.graph.Node n) -
isNodeTriple
public static boolean isNodeTriple(org.apache.jena.graph.Node n) -
isNodeGraph
public static boolean isNodeGraph(org.apache.jena.graph.Node n) -
isNullOrAny
public static boolean isNullOrAny(org.apache.jena.graph.Node n) -
hasDatatype
public static boolean hasDatatype(org.apache.jena.graph.Node n, org.apache.jena.datatypes.RDFDatatype datatype) Return true if n is a literal and it has the given datatype, else return false. -
isString
public static boolean isString(org.apache.jena.graph.Node n) -
isBoolean
public static boolean isBoolean(org.apache.jena.graph.Node n) -
nullAsAny
public static org.apache.jena.graph.Node nullAsAny(org.apache.jena.graph.Node x) Convert null to Node.ANY, otherwise return the original node so that==
may be used to test whether any change has occurred. -
nullAsDft
public static org.apache.jena.graph.Node nullAsDft(org.apache.jena.graph.Node x, org.apache.jena.graph.Node dft) Convert null to some default Node, otherwise return the original node so that==
may be used to test whether any change has occurred. -
nullAsAny
public static org.apache.jena.graph.Triple nullAsAny(org.apache.jena.graph.Triple triple) Convert any null terms in a triple to "ANY". If there are no changes, return the original triple object so that==
may be used to test whether any change has occurred. -
nullAsAny
Convert any null terms in a quad to "ANY". If there are no changes, return the original quad object so that==
may be used to test whether any change has occurred. -
asString
Get a string, assuming the node is an xsd:string literal. -
contains
public static boolean contains(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Does the graph match the s/p/o pattern? -
containsNode
public static boolean containsNode(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Does the graph use the node anywhere as a subject, predicate or object? -
isOfType
public static boolean isOfType(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, org.apache.jena.graph.Node type) Test whether the node has the type or one of its types is an rdfs:subclassOf the type. -
hasType
public static boolean hasType(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node, org.apache.jena.graph.Node type) Does the node x have the given type (non-RDFS - no rdfs:subclassOf considered)? -
hasProperty
public static boolean hasProperty(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Does nodes
have propertyp
in graphg
? -
containsOne
public static boolean containsOne(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Contains exactly one. -
getSP
public static org.apache.jena.graph.Node getSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object, given subject and predicate. Returns one (non-deterministically) or null. See alsogetOneSP(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
andgetZeroOrOneSP(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
. -
getOneSP
public static org.apache.jena.graph.Node getOneSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object for subject-predicate. Must be exactly one object; exception RDFDataException thrown when none or more than one. -
hasOneSP
public static boolean hasOneSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Test whether there is exactly one object for the subject-predicate. -
getZeroOrOneSP
public static org.apache.jena.graph.Node getZeroOrOneSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Get object for subject-predicate. Return null for none, object for one, and exception RDFDataException if more than one. -
getPO
public static org.apache.jena.graph.Node getPO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject, given predicate and object. Returns one (non-deterministically) or null. See alsogetOnePO(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
andgetZeroOrOnePO(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
. -
getOnePO
public static org.apache.jena.graph.Node getOnePO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject for predicate-object. Must be exactly one subject; exception RDFDataException thrown when none or more than one. -
hasOnePO
public static boolean hasOnePO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Test whether there is exactly one subject for the predicate-object. -
getZeroOrOnePO
public static org.apache.jena.graph.Node getZeroOrOnePO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get the subject for predicate-object. Return null for none, subject for one, throw exception RDFDataException if more than one. -
getOne
public static org.apache.jena.graph.Triple getOne(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o, else throw RDFDataException. -
getZeroOrOne
public static org.apache.jena.graph.Triple getZeroOrOne(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; return null if none; throw RDFDataException if more than one. -
getOneOrNull
public static org.apache.jena.graph.Triple getOneOrNull(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; else return null if none or more than one. -
getOne
public static Quad getOne(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get quad if there is exactly one to match the s/p/o, else throw RDFDataException. -
getZeroOrOne
public static Quad getZeroOrOne(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; return null if none; throw RDFDataException if more than one. -
getOneOrNull
public static Quad getOneOrNull(DatasetGraph dsg, org.apache.jena.graph.Node graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Get triple if there is exactly one to match the s/p/o; else return null if none or more than one. -
iterSP
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> iterSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) ExtendedIterator
of objects where the triple matches for subject and predicate (which can be wildcards). TheExtendedIterator
must be fully used or explicitly closed. It is preferable uselistSP(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
which handles this condition. -
listSP
public static List<org.apache.jena.graph.Node> listSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) List of objects matching the subject-predicate (which can be wildcards). -
countSP
public static long countSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Count matches of subject-predicate (which can be wildcards). -
iterPO
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Node> iterPO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) ExtendedIterator
of subjects where the triple matches for predicate and object (which can be wildcards). TheExtendedIterator
must be fully used or explicitly closed. It is preferable uselistSP(org.apache.jena.graph.Graph, org.apache.jena.graph.Node, org.apache.jena.graph.Node)
which handles this condition. -
listPO
public static List<org.apache.jena.graph.Node> listPO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) List of subjects matching the predicate-object (which can be wildcards). -
countPO
public static long countPO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Count matches of predicate-object (which can be wildcards). -
iterSubjects
List the subjects in a graph (no duplicates) -
iterPredicates
public static Iterator<org.apache.jena.graph.Node> iterPredicates(org.apache.jena.graph.Graph graph) List the predicates in a graph (no duplicates) -
iterObjects
List the objects in a graph (no duplicates) -
iterSubjectsOfPredicate
public static Iterator<org.apache.jena.graph.Node> iterSubjectsOfPredicate(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate) List the subjects of a predicate in a graph (no duplicates)Use
iterPO(predicate, null)
for "with duplicates." -
iterObjectsOfPredicate
public static Iterator<org.apache.jena.graph.Node> iterObjectsOfPredicate(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate) List the objects in a graph (no duplicates)Use
iterSP(null, predicate)
for "with duplicates." -
nodesOfTypeAsList
public static List<org.apache.jena.graph.Node> nodesOfTypeAsList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the subjects with exactlytype
. SeelistNodesOfTypeRDFS(Graph, Node)
, which does include sub-classes. -
typesOfNodeAsList
public static List<org.apache.jena.graph.Node> typesOfNodeAsList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List the types of a node/subject. SeelistTypesOfNodeRDFS(Graph, Node)
, which does include super-classes. -
nodesOfTypeAsSet
public static Set<org.apache.jena.graph.Node> nodesOfTypeAsSet(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of nodes with exactlytype
. SeeallNodesOfTypeRDFS(Graph, Node)
, which does include sub-classes. -
typesOfNodeAsSet
public static Set<org.apache.jena.graph.Node> typesOfNodeAsSet(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Set of exact types of a node.See
allTypesOfNodeRDFS(Graph, Node)
, which does include super-classes. -
rdfList
public static List<org.apache.jena.graph.Node> rdfList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Return a java list for an RDF list of data. -
getOneOrList
public static List<org.apache.jena.graph.Node> getOneOrList(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) Return a java list where thenode
is an RDF list of nodes or a single node (returned a singleton list). -
listSubClasses
public static List<org.apache.jena.graph.Node> listSubClasses(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the subclasses of a type, including itself. This is?x rdfs:subClassOf* type
. The list does not contain duplicates. -
listSuperClasses
public static List<org.apache.jena.graph.Node> listSuperClasses(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List the super-classes of a type, including itself. This istype rdfs:subClassOf* ?x
. The list does not contain duplicates. -
subClasses
public static Set<org.apache.jena.graph.Node> subClasses(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of the subclasses of a type, including itself. This is?x rdfs:subClassOf* type
. -
superClasses
public static Set<org.apache.jena.graph.Node> superClasses(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) Set of the subclasses of a type, including itself. This is?x rdfs:subClassOf* type
. -
listTypesOfNodeRDFS
public static List<org.apache.jena.graph.Node> listTypesOfNodeRDFS(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List the types of a node, following rdfs:subClassOf for super classes. -
listNodesOfTypeRDFS
public static List<org.apache.jena.graph.Node> listNodesOfTypeRDFS(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List all the nodes of type, including nodes of sub-classes. -
allTypesOfNodeRDFS
public static Set<org.apache.jena.graph.Node> allTypesOfNodeRDFS(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node node) List all the types of a node, including super-classes. -
allNodesOfTypeRDFS
public static Set<org.apache.jena.graph.Node> allNodesOfTypeRDFS(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node type) List all the node of type, including considering rdfs:subClassOf -
allSP
public static Set<org.apache.jena.graph.Node> allSP(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate) Return a set of all objects for subject-predicate -
allPO
public static Set<org.apache.jena.graph.Node> allPO(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Return a set of all subjects for predicate-object -
objectConnectiveness
public static long objectConnectiveness(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node object) Count the number of in-arc to an object -
oneConnected
public static boolean oneConnected(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node object) Test whether an object has exactly one in-arc. -
count
public static long count(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Count occurrences of the pattern. -
find
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> find(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node subject, org.apache.jena.graph.Node predicate, org.apache.jena.graph.Node object) Graph.find(Node, Node, Node)
as a function. -
findAll
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> findAll(org.apache.jena.graph.Graph graph) Graph.find()
as a function. -
allNonNull
Are all the arguments non-null? -
exactlyOneSet
Is one and only one argument non-null? -
atMostOne
Is one or none of the arguments non-null? -
countNonNulls
Count non-nulls -
quads2triples
public static org.apache.jena.atlas.iterator.Iter<org.apache.jena.graph.Triple> quads2triples(Iterator<Quad> iter) Project quads to triples -
quad2graphName
Project quad to graph name -
quad2subject
Project quad to subject -
quad2predicate
Project quad to predicate -
quad2object
Project quad to object -
triple2subject
public static Iterator<org.apache.jena.graph.Node> triple2subject(Iterator<org.apache.jena.graph.Triple> iter) Project triple to subject -
triple2predicate
public static Iterator<org.apache.jena.graph.Node> triple2predicate(Iterator<org.apache.jena.graph.Triple> iter) Project triple to predicate -
triple2object
public static Iterator<org.apache.jena.graph.Node> triple2object(Iterator<org.apache.jena.graph.Triple> iter) Project triple to object -
copyGraphSrcToDst
public static void copyGraphSrcToDst(org.apache.jena.graph.Graph src, org.apache.jena.graph.Graph dst) Add src to dst - assumes transaction. src and dst must not overlap. Copies "left to right" --src into dst
- Parameters:
src
-dst
-
-
copy
public static org.apache.jena.graph.Graph copy(org.apache.jena.graph.Graph src) Creates a copy of the given graph. If the graph implements Copyablethen the copy method is called. Otherwise, a new system default memory-based graph is created and the triples are copied into it. - Parameters:
src
- the graph to copy- Returns:
- a copy of the graph
-
clear
public static void clear(org.apache.jena.graph.Graph graph) Clear graph. -
apply
public static void apply(org.apache.jena.graph.Graph src, Consumer<org.apache.jena.graph.Triple> action) Apply an action to every triple of a graph. The action must not attempt to modify the graph but it can read it. -
apply
public static void apply(org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> iter, Consumer<org.apache.jena.graph.Triple> action) Apply an action to every triple of an iterator. If the iterator is attracted to a graph, the action must not attempt to modify the graph but it can read it. -
deleteModify
public static void deleteModify(org.apache.jena.graph.Graph modify, org.apache.jena.graph.Graph srcGraph) Delete triples in the graph-to-modify (arg 1) that are in the source (arg 2).- Parameters:
modify
-srcGraph
-
-
triples2quads
public static org.apache.jena.atlas.iterator.Iter<Quad> triples2quads(org.apache.jena.graph.Node graphNode, Iterator<org.apache.jena.graph.Triple> iter) Convert an iterator of triples into quads for the specified graph name. -
triples2quadsDftGraph
public static org.apache.jena.atlas.iterator.Iter<Quad> triples2quadsDftGraph(Iterator<org.apache.jena.graph.Triple> iter) Convert an iterator of triples into quads for the default graph. This isQuad.defaultGraphIRI
, notQuad.defaultGraphNodeGenerated
, which is for quads outside a dataset, usually the output of parsers. -
execTxn
Execute a graph transaction if the graph supports transactions else apply without a transaction wrapper. -
calcTxn
Execute a graph transaction and result result if the graph supports transactions else execute and return without a transaction wrapper. -
findExec
public static void findExec(org.apache.jena.graph.Graph graph, Consumer<org.apache.jena.graph.Triple> action, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Find triples and execute an action on each triple found. -
addInto
public static void addInto(org.apache.jena.graph.Graph dstGraph, org.apache.jena.graph.Graph srcGraph) Add triples into the destination (arg 1) from the source (arg 2) -
containsBySameTerm
public static boolean containsBySameTerm(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Triple triple) Test whether a graph contains by "same term", regardless of whether the graph implements "same value" or "same term". -
containsBySameTerm
public static boolean containsBySameTerm(org.apache.jena.graph.Graph graph, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Test whether a graph contains by "same term", regardless of whether the graph implements "same value" or "same term". -
sameTermMatch
public static boolean sameTermMatch(org.apache.jena.graph.Node matchSubj, org.apache.jena.graph.Node matchPred, org.apache.jena.graph.Node matchObj, org.apache.jena.graph.Triple dataTriple) Match S/P/O which can be wildcards (ANY or null), against a ground triple (even ANY and variables are considered ground terms in the data triple). -
sameTermMatch
public static boolean sameTermMatch(org.apache.jena.graph.Node match, org.apache.jena.graph.Node data) Match a node, which can be a wildcard (ANY or null) against a ground RDF Term (ANY and variables are considered ground terms in the data term). Language tags compare case-insensitively. -
containsByLang
public static boolean containsByLang(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Contains, and language tags compare case-insentively -
findByLang
public static org.apache.jena.util.iterator.ExtendedIterator<org.apache.jena.graph.Triple> findByLang(org.apache.jena.graph.Graph g, org.apache.jena.graph.Node s, org.apache.jena.graph.Node p, org.apache.jena.graph.Node o) Contains, and language tags match case-insentively -
hasLang
public static boolean hasLang(org.apache.jena.graph.Node node) Test whether a node has a language tag. If the node is null or any "match" (non-concrete) node, return false.
-