Class PrefixUtils


  • public class PrefixUtils
    extends Object
    Collection of random utilities for working with prefixes.
    Author:
    Dave Reynolds
    • Constructor Summary

      Constructors 
      Constructor Description
      PrefixUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.apache.jena.shared.PrefixMapping asPrefixes​(String... declarations)
      Utility for easily declaring a prefix mapping in code.
      static String asPrefixString​(org.apache.jena.shared.PrefixMapping pm, boolean turtle)  
      static String asSparqlPrefixes​(org.apache.jena.shared.PrefixMapping pm)
      Return the contents of the given prefix mapping, formatted for prepending onto a SPARQL query.
      static String asTurtlePrefixes​(org.apache.jena.shared.PrefixMapping pm)
      Return the contents of the given prefix mapping, formatted for prepending onto Turtle content.
      static org.apache.jena.shared.PrefixMapping commonPrefixes()
      Return a set of commonly used RDF prefixes.
      static org.apache.jena.shared.PrefixMapping commonPrefixes​(String... additional)
      Return a set of commonly used RDF prefixes.
      static org.apache.jena.shared.PrefixMapping commonPrefixes​(org.apache.jena.shared.PrefixMapping additional)
      Return a set of commonly used RDF prefixes.
      static String expandQuery​(String query, org.apache.jena.shared.PrefixMapping pm)
      Expand a SPARQL query by prefixing it will all possibly relevant mappings from the given prefix mapping
      static org.apache.jena.shared.PrefixMapping merge​(org.apache.jena.shared.PrefixMapping pm1, org.apache.jena.shared.PrefixMapping pm2)
      Return a read-only merge of two prefix mappings
    • Constructor Detail

      • PrefixUtils

        public PrefixUtils()
    • Method Detail

      • merge

        public static org.apache.jena.shared.PrefixMapping merge​(org.apache.jena.shared.PrefixMapping pm1,
                                                                 org.apache.jena.shared.PrefixMapping pm2)
        Return a read-only merge of two prefix mappings
      • expandQuery

        public static String expandQuery​(String query,
                                         org.apache.jena.shared.PrefixMapping pm)
        Expand a SPARQL query by prefixing it will all possibly relevant mappings from the given prefix mapping
      • commonPrefixes

        public static org.apache.jena.shared.PrefixMapping commonPrefixes()
        Return a set of commonly used RDF prefixes. This includes the Jena standard mapping (rdf:, owl:, etc) and prefixes for all of the vocabularies defined in epimorphics-lib.
        Returns:
        A prefix mapping object
        See Also:
        commonPrefixes(PrefixMapping)
      • asPrefixes

        public static org.apache.jena.shared.PrefixMapping asPrefixes​(String... declarations)
        Utility for easily declaring a prefix mapping in code. The arguments are assumed to be pairs of strings, alternating prefix and URI.
        Parameters:
        declarations - Alternating prefix and URI strings
        Returns:
        A new PrefixMapping containing only the prefixes declared
        Throws:
        EpiException - if the declarations are not in pairs
      • commonPrefixes

        public static org.apache.jena.shared.PrefixMapping commonPrefixes​(String... additional)
        Return a set of commonly used RDF prefixes. This includes the Jena standard mapping (rdf:, owl:, etc) and prefixes for all of the vocabularies defined in epimorphics-lib. This variant also allows additional prefixes to be declared in code as alternating prefix and uri strings.
        Parameters:
        additional - Array of String objects denoting, alternately, a prefix and a URI
        Returns:
        A prefix mapping object
        See Also:
        commonPrefixes(PrefixMapping)
      • commonPrefixes

        public static org.apache.jena.shared.PrefixMapping commonPrefixes​(org.apache.jena.shared.PrefixMapping additional)
        Return a set of commonly used RDF prefixes. This includes the Jena standard mapping (rdf:, owl:, etc) and prefixes for all of the vocabularies defined in epimorphics-lib.
        Parameters:
        additional - Optional additional prefixes to merge into the common core, or null
        Returns:
        A prefix mapping object
      • asTurtlePrefixes

        public static String asTurtlePrefixes​(org.apache.jena.shared.PrefixMapping pm)
        Return the contents of the given prefix mapping, formatted for prepending onto Turtle content.
        Parameters:
        pm -
        Returns:
      • asSparqlPrefixes

        public static String asSparqlPrefixes​(org.apache.jena.shared.PrefixMapping pm)
        Return the contents of the given prefix mapping, formatted for prepending onto a SPARQL query.
        Parameters:
        pm -
        Returns:
      • asPrefixString

        public static String asPrefixString​(org.apache.jena.shared.PrefixMapping pm,
                                            boolean turtle)