Class Rdf4jUtils

java.lang.Object
cz.cvut.kbss.ontodriver.rdf4j.util.Rdf4jUtils

public final class Rdf4jUtils extends Object
Utility methods for the RDF4J driver.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.eclipse.rdf4j.model.Literal
    createLiteral(Object value, String language, org.eclipse.rdf4j.model.ValueFactory vf)
    Creates RDF4J literal from the specified value.
    static boolean
    doesLanguageMatch(org.eclipse.rdf4j.model.Literal literal, Assertion assertion)
    Checks whether the language of the specified literal matches the specified assertion language.
    static Object
    getLiteralValue(org.eclipse.rdf4j.model.Literal literal)
    Gets value of the specified literal as the corresponding Java object.
    static boolean
    isBlankNode(org.eclipse.rdf4j.model.Value value)
    Checks whether the specified value is a blank node.
    static boolean
    Resolves whether the specified value is a resource identifier.
    static URI
    toJavaUri(org.eclipse.rdf4j.model.Resource resource)
     
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getLiteralValue

      public static Object getLiteralValue(org.eclipse.rdf4j.model.Literal literal)
      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 check
      assertion - Assertion
      Returns:
      false if the literal is a string literal and its language does not match the one specified by the assertion, true otherwise
    • 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 transform
      language - Language to add to string literals, optional
      vf - 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:
      true if the value is a blank node, false otherwise
    • isResourceIdentifier

      public static boolean isResourceIdentifier(Object value)
      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:
      true if 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 convert
      factory - 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 transform
      factory - RDF4J value factory used for the conversion
      Returns:
      RDF4J IRI
      See Also:
    • toJavaUri

      public static URI toJavaUri(org.eclipse.rdf4j.model.Resource resource)