Class Rdf4jUtils
java.lang.Object
cz.cvut.kbss.ontodriver.rdf4j.util.Rdf4jUtils
Utility methods for the RDF4J driver.
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.rdf4j.model.LiteralcreateLiteral(Object value, String language, org.eclipse.rdf4j.model.ValueFactory vf) Creates RDF4J literal from the specified value.static booleandoesLanguageMatch(org.eclipse.rdf4j.model.Literal literal, Assertion assertion) Checks whether the language of the specified literal matches the specified assertion language.static ObjectgetLiteralValue(org.eclipse.rdf4j.model.Literal literal) Gets value of the specified literal as the corresponding Java object.static booleanisBlankNode(org.eclipse.rdf4j.model.Value value) Checks whether the specified value is a blank node.static booleanisResourceIdentifier(Object value) Resolves whether the specified value is a resource identifier.static URItoJavaUri(org.eclipse.rdf4j.model.Resource resource) static org.eclipse.rdf4j.model.IRItoRdf4jIri(NamedResource resource, org.eclipse.rdf4j.model.ValueFactory factory) Constructs a RDF4J IRI from identifier of the specified resource.static org.eclipse.rdf4j.model.IRItoRdf4jIri(URI javaUri, org.eclipse.rdf4j.model.ValueFactory factory) Constructs a RDF4J IRI from the specified java.net.URI.
-
Method Details
-
getLiteralValue
Gets value of the specified literal as the corresponding Java object.Primitives are returned boxed. If the type cannot be mapped to a corresponding Java type, it is returned as
Literal.- Parameters:
literal- RDF literal value- Returns:
- Java value corresponding to datatype
-
doesLanguageMatch
public static boolean doesLanguageMatch(org.eclipse.rdf4j.model.Literal literal, Assertion assertion) Checks whether the language of the specified literal matches the specified assertion language.If the assertion does not specify a language, any literal will match. If the literal is not a string, it matches as well.
- Parameters:
literal- Literal to checkassertion- Assertion- Returns:
falseif the literal is a string literal and its language does not match the one specified by the assertion,trueotherwise
-
createLiteral
public static org.eclipse.rdf4j.model.Literal createLiteral(Object value, String language, org.eclipse.rdf4j.model.ValueFactory vf) Creates RDF4J literal from the specified value.- Parameters:
value- The value to transformlanguage- Language to add to string literals, optionalvf- RDF4J value factory- Returns:
- RFD4J Literal
- Throws:
IllegalArgumentException- If the type of the value is not supported
-
isBlankNode
public static boolean isBlankNode(org.eclipse.rdf4j.model.Value value) Checks whether the specified value is a blank node.- Parameters:
value- The value to check- Returns:
trueif the value is a blank node,falseotherwise
-
isResourceIdentifier
Resolves whether the specified value is a resource identifier.Only values of supported identifier types are considered identifiers.
- Parameters:
value- The value to check- Returns:
trueif the value is either a URI or a URL
-
toRdf4jIri
public static org.eclipse.rdf4j.model.IRI toRdf4jIri(URI javaUri, org.eclipse.rdf4j.model.ValueFactory factory) Constructs a RDF4J IRI from the specified java.net.URI.- Parameters:
javaUri- The uri to convertfactory- RDF4J value factory used for the conversion- Returns:
- RDF4J IRI
-
toRdf4jIri
public static org.eclipse.rdf4j.model.IRI toRdf4jIri(NamedResource resource, org.eclipse.rdf4j.model.ValueFactory factory) Constructs a RDF4J IRI from identifier of the specified resource.- Parameters:
resource- Resource whose identifier to transformfactory- RDF4J value factory used for the conversion- Returns:
- RDF4J IRI
- See Also:
-
toJavaUri
-