Package org.eclipse.rdf4j.model.util
Class Statements
java.lang.Object
org.eclipse.rdf4j.model.util.Statements
Utility methods for working with
Statement
objects, including conversion to/from RDF-star
triple objects
.- Author:
- Jeen Broekstra
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
consume
(ValueFactory vf, Resource subject, IRI predicate, Value object, Consumer<Statement> consumer, Resource... contexts) static void
convertRDFStarToReification
(Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer.static void
convertRDFStarToReification
(ValueFactory vf, Function<Triple, Resource> reifiedIdMapper, Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer.static void
convertRDFStarToReification
(ValueFactory vf, Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer.static <C extends Collection<Statement>>
Ccreate
(ValueFactory vf, Resource subject, IRI predicate, Value object, C collection, Resource... contexts) Creates one or moreStatement
objects with the given subject, predicate and object, one for each given context.static boolean
isSameTriple
(Statement st1, Statement st2) Checks if the two statements represent the same triple (that is, they have equal subject, predicate, and object).static Statement
Create aStatement
from the supplied subject, predicate, object and context.static Statement
Create aStatement
from the suppliedRDF-star triple
static Statement
Create aStatement
from the suppliedRDF-star triple
and context.static Statement
Create aStatement
from the supplied subject, predicate, object and context.static Statement
statement
(ValueFactory vf, Triple triple, Resource context) Create aStatement
from the suppliedRDF-star triple
and context.static Statement
stripContext
(Statement statement) Strips the context (if any) from the supplied statement and returns a statement with the same subject, predicate and object, but with no assigned context.static Statement
stripContext
(ValueFactory vf, Statement statement) Strips the context (if any) from the supplied statement and returns a statement with the same subject, predicate and object, but with no assigned context.static Statement
toStatement
(Triple triple) Deprecated.static Statement
toStatement
(Triple triple, Resource context) Deprecated.since 3.7.0 - usestatement(Triple, Resource)
insteadstatic Statement
toStatement
(ValueFactory vf, Triple triple, Resource context) Deprecated.Usestatement(ValueFactory, Triple, Resource)
insteadstatic Triple
Deprecated.UseValues.triple(Statement)
insteadstatic Triple
toTriple
(ValueFactory vf, Statement statement) Deprecated.UseValues.triple(ValueFactory, Statement)
instead
-
Field Details
-
TRIPLE_BNODE_MAPPER
-
-
Constructor Details
-
Statements
public Statements()
-
-
Method Details
-
consume
public static void consume(ValueFactory vf, Resource subject, IRI predicate, Value object, Consumer<Statement> consumer, Resource... contexts) Creates one or moreStatement
objects with the given subject, predicate and object, one for each given context, and sends each created statement to the suppliedConsumer
. If no context is supplied, only a single statement (without any assigned context) is created.- Parameters:
vf
- theValueFactory
to use for creating statements.subject
- the subject of each statement. May not be null.predicate
- the predicate of each statement. May not be null.object
- the object of each statement. May not be null.consumer
- theConsumer
function for the produced statements.contexts
- the context(s) for which to produce statements. This argument is an optional vararg: leave it out completely to produce a single statement without context.
-
create
public static <C extends Collection<Statement>> C create(ValueFactory vf, Resource subject, IRI predicate, Value object, C collection, Resource... contexts) Creates one or moreStatement
objects with the given subject, predicate and object, one for each given context. If no context is supplied, only a single statement (without any assigned context) is created.- Parameters:
vf
- theValueFactory
to use for creating statements.subject
- the subject of each statement. May not be null.predicate
- the predicate of each statement. May not be null.object
- the object of each statement. May not be null.collection
- the collection of Statements to which the newly created Statements will be added. May not be null.contexts
- the context(s) for which to produce statements. This argument is an optional vararg: leave it out completely to produce a single statement without context.- Returns:
- the input collection of Statements, with the newly created Statements added.
-
stripContext
Strips the context (if any) from the supplied statement and returns a statement with the same subject, predicate and object, but with no assigned context.- Parameters:
statement
- the statement to strip the context from- Returns:
- a statement without context
- Since:
- 3.1.0
-
stripContext
Strips the context (if any) from the supplied statement and returns a statement with the same subject, predicate and object, but with no assigned context.- Parameters:
vf
- theValueFactory
to use for creating a newStatement
.statement
- the statement to strip the context from.- Returns:
- a statement without context
- Since:
- 3.1.0
-
toTriple
Deprecated.UseValues.triple(Statement)
insteadCreate anRDF-star triple
from the suppliedStatement
- Parameters:
statement
- a statement to convert to an RDF-star triple- Returns:
- an
RDF-star triple
with the same subject, predicate and object as the input statement. - Since:
- 3.4.0
-
toTriple
Deprecated.UseValues.triple(ValueFactory, Statement)
insteadCreate anRDF-star triple
from the suppliedStatement
- Parameters:
vf
- theValueFactory
to use for creating theTriple
object.statement
- a statement to convert to an RDF-star triple- Returns:
- an
RDF-star triple
with the same subject, predicate and object as the input statement. - Since:
- 3.4.0
-
toStatement
Deprecated.Usestatement(Triple)
insteadCreate aStatement
from the suppliedRDF-star triple
-
statement
Create aStatement
from the suppliedRDF-star triple
-
statement
Create aStatement
from the suppliedRDF-star triple
and context. -
toStatement
Deprecated.since 3.7.0 - usestatement(Triple, Resource)
insteadCreate aStatement
from the suppliedRDF-star triple
and context. -
toStatement
Deprecated.Usestatement(ValueFactory, Triple, Resource)
insteadCreate aStatement
from the suppliedRDF-star triple
and context.- Parameters:
vf
- theValueFactory
to use for creating theStatement
object.triple
- an RDF-star triple to convert to aStatement
.context
- the context to assign to theStatement
. May be null to indicate no context.- Returns:
- an
Statement
with the same subject, predicate and object as the input triple, and having the supplied context. - Since:
- 3.4.0
-
statement
Create aStatement
from the suppliedRDF-star triple
and context.- Parameters:
vf
- theValueFactory
to use for creating theStatement
object.triple
- an RDF-star triple to convert to aStatement
.context
- the context to assign to theStatement
. May be null to indicate no context.- Returns:
- an
Statement
with the same subject, predicate and object as the input triple, and having the supplied context. - Since:
- 3.7.0
-
statement
Create aStatement
from the supplied subject, predicate, object and context.- Parameters:
subject
- the statement subjectpredicate
- the statement predicateobject
- the statement objectcontext
- the context to assign to theStatement
. May be null to indicate no context.- Returns:
- an
Statement
with the same subject, predicate and object as the input triple, and having the supplied context. - Throws:
NullPointerException
- if any of subject, predicate, or object arenull
.- Since:
- 3.5.0
-
statement
public static Statement statement(ValueFactory vf, Resource subject, IRI predicate, Value object, Resource context) Create aStatement
from the supplied subject, predicate, object and context.- Parameters:
vf
- theValueFactory
to use for creating theStatement
object.subject
- the statement subjectpredicate
- the statement predicateobject
- the statement objectcontext
- the context to assign to theStatement
. May be null to indicate no context.- Returns:
- an
Statement
with the same subject, predicate and object as the input triple, and having the supplied context. - Throws:
NullPointerException
- if any of vf, subject, predicate, or object arenull
.- Since:
- 3.5.0
-
isSameTriple
Checks if the two statements represent the same triple (that is, they have equal subject, predicate, and object). Context information is disregarded.- Parameters:
st1
- the first statement to compare. May not be null.st2
- the second statement to compare. May not be null.- Returns:
true
iff the subject, predicate and object ofst1
andst2
are equal,false
otherwise.- Since:
- 2.0
- See Also:
-
convertRDFStarToReification
@Experimental public static void convertRDFStarToReification(Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer. If the supplied statement is not RDF-star it will be sent to the consumer as is.The statements needed to represent reification will use blank nodes.
-
convertRDFStarToReification
@Experimental public static void convertRDFStarToReification(ValueFactory vf, Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer. If the supplied statement is not RDF-star it will be sent to the consumer as is.The statements needed to represent reification will use blank nodes.
The supplied value factory is used to create all new statements and blank nodes.
- Parameters:
vf
- theValueFactory
to use for creating statements.st
- theStatement
to convert.consumer
- theConsumer
function for the produced statements.
-
convertRDFStarToReification
@Experimental public static void convertRDFStarToReification(ValueFactory vf, Function<Triple, Resource> reifiedIdMapper, Statement st, Consumer<Statement> consumer) Converts the supplied RDF-star statement to RDF reification statements, and sends the resultant statements to the supplied consumer. If the supplied statement is not RDF-star it will be sent to the consumer as is.The supplied value factory is used to create all new statements.
The supplied mapper function maps a
Triple
to aResource
and is used to create the ID of the RDF reification statement corresponding to the converted triple. The function must return the same value for identical triples in order to produce consistent results between invocations. SeeTRIPLE_BNODE_MAPPER
.
-
statement(Triple)
instead