Class ValueMappings

java.lang.Object
com.inrupt.rdf.wrapping.commons.ValueMappings

public final class ValueMappings extends Object
Common mappings from RDF terms to other values. For use in wrapping classes.
Author:
Samu Lang
  • Method Details

    • literalAsString

      public static String literalAsString(RDFTerm term, Graph graph)
      Maps a literal term to its lexical form.
      Parameters:
      term - the term to map
      graph - ignored
      Returns:
      the lexical form of the term as a string
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not a literal
    • iriAsUri

      public static URI iriAsUri(RDFTerm term, Graph graph)
      Maps an IRI term to a URI created from its IRI string.
      Parameters:
      term - the term to convert
      graph - ignored
      Returns:
      the IRI of the term as a URI
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not an IRI
    • iriAsString

      public static String iriAsString(RDFTerm term, Graph graph)
      Maps an IRI term to its IRI string.
      Parameters:
      term - the term to convert
      graph - ignored
      Returns:
      the IRI of the term as a string
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not an IRI
    • literalAsInstant

      public static Instant literalAsInstant(RDFTerm term, Graph graph)
      Maps a literal term to a point in time.
      Parameters:
      term - the term to map
      graph - ignored
      Returns:
      the point in time represented by the term's lexical form as an Instant
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not a literal
      DateTimeParseException - if the term's lexical form cannot be parsed as an Instant
    • literalAsBoolean

      public static Boolean literalAsBoolean(RDFTerm term, Graph graph)
      Maps a literal term to a boolean.
      Parameters:
      term - the term to map
      graph - ignored
      Returns:
      the boolean represented by the term's lexical form as a boolean
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not a literal
    • literalAsIntegerOrNull

      public static Integer literalAsIntegerOrNull(RDFTerm term, Graph graph)
      Maps a literal term to an integer or null.
      Parameters:
      term - the term to map
      graph - ignored
      Returns:
      the integer represented by the term's lexical form or null if the form can not be parsed
      Throws:
      NullPointerException - if the term is null
      IllegalStateException - if the term is not a literal
    • as

      public static <T extends RDFTerm> ValueMapping<T> as(Class<T> view)
      A factory for mappings from a term to a view.
      Type Parameters:
      T - the type of the target class to map to
      Parameters:
      view - the target class to map to
      Returns:
      a mapping that converts the term to the supplied implementation type
      Throws:
      NullPointerException - if the view is null
      See Also:
      • the returned mapping function (including exceptions it throws)