Class ValueMappings


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends org.apache.commons.rdf.api.RDFTerm>
      ValueMapping<T>
      as​(Class<T> view)
      A factory for mappings from a term to a view.
      static String iriAsString​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps an IRI term to its IRI string.
      static URI iriAsUri​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps an IRI term to a URI created from its IRI string.
      static Boolean literalAsBoolean​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps a literal term to a boolean.
      static Instant literalAsInstant​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps a literal term to a point in time.
      static Integer literalAsIntegerOrNull​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps a literal term to an integer or null.
      static String literalAsString​(org.apache.commons.rdf.api.RDFTerm term, org.apache.commons.rdf.api.Graph graph)
      Maps a literal term to its lexical form.
    • Method Detail

      • literalAsString

        public static String literalAsString​(org.apache.commons.rdf.api.RDFTerm term,
                                             org.apache.commons.rdf.api.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​(org.apache.commons.rdf.api.RDFTerm term,
                                   org.apache.commons.rdf.api.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​(org.apache.commons.rdf.api.RDFTerm term,
                                         org.apache.commons.rdf.api.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​(org.apache.commons.rdf.api.RDFTerm term,
                                               org.apache.commons.rdf.api.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​(org.apache.commons.rdf.api.RDFTerm term,
                                               org.apache.commons.rdf.api.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​(org.apache.commons.rdf.api.RDFTerm term,
                                                     org.apache.commons.rdf.api.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