Class SolutionMappingUtils

java.lang.Object
se.liu.ida.hefquin.base.data.utils.SolutionMappingUtils

public class SolutionMappingUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected static void
    appendValuesClauseEntry(StringBuilder b, List<org.apache.jena.sparql.core.Var> vars, org.apache.jena.sparql.engine.binding.Binding sm, org.apache.jena.sparql.serializer.SerializationContext scxt)
     
    Applies the given vocabulary mapping to each of the solution mappings of the given iterable (translating them from the global vocabulary to the local vocabulary), collects the resulting solution mappings in a list, and returns this list in the end.
    Applies the given vocabulary mapping to each of the solution mappings of the given iterator (translating them from the global vocabulary to the local vocabulary), collects the resulting solution mappings in a list, and returns this list in the end.
    Applies the given vocabulary mapping to each of the solution mappings of the given iterable (translating them from the local vocabulary to the global vocabulary), collects the resulting solution mappings in a list, and returns this list in the end.
    Applies the given vocabulary mapping to each of the solution mappings of the given iterator (translating them from the local vocabulary to the global vocabulary), collects the resulting solution mappings in a list, and returns this list in the end.
    static boolean
    compatible(org.apache.jena.sparql.engine.binding.Binding b1, org.apache.jena.sparql.engine.binding.Binding b2)
    Returns true if the given bindings are compatible.
    static boolean
    Returns true if the given solution mappings are compatible.
    static boolean
    containsBlankNodes(org.apache.jena.sparql.engine.binding.Binding b)
    Returns true if the given solution mapping binds any of its variables to a blank node.
    static boolean
    Returns true if the given solution mapping binds any of its variables to a blank node.
    Creates an empty solution mapping.
    createSolutionMapping(org.apache.jena.query.QuerySolution s)
    Creates a solution mapping based on the given QuerySolution.
    createSolutionMapping(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node node)
    Creates a solution mapping in which the given variable is mapped to the given node.
    createSolutionMapping(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node node1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node node2)
    Creates a solution mapping in which the given variables are mapped to the given nodes, respectively.
    createSolutionMapping(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node node1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node node2, org.apache.jena.sparql.core.Var var3, org.apache.jena.graph.Node node3)
    Creates a solution mapping in which the given variables are mapped to the given nodes, respectively.
    static String
    createValuesClause(Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
    Serializes the given collection of solution mappings as a string that can be used in a SPARQL VALUES clause.
    protected static String
    createValuesClauseLongForm(List<org.apache.jena.sparql.core.Var> vars, Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
     
    protected static String
    createValuesClauseShortForm(List<org.apache.jena.sparql.core.Var> vars, Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
     
    static boolean
    Returns true if the given set of solution mappings are equivalent; that is, if they contain the same number of solution mappings and for each such solution mapping there is an equivalent solution mapping in the respective other set.
    static boolean
    Returns true if the given solution mappings are equivalent; that is, if they are defined for the exact same set of variables and they are compatible.
    static boolean
    equalSets(Set<org.apache.jena.sparql.engine.binding.Binding> s1, Set<org.apache.jena.sparql.engine.binding.Binding> s2)
    Returns true if the given set of solution mappings are equivalent; that is, if they contain the same number of solution mappings and for each such solution mapping there is an equivalent solution mapping in the respective other set.
    static Set<org.apache.jena.sparql.core.Var>
    getAllMentionedVariables(Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps)
    Returns a set containing all the variables that have a binding in at least one of the given solution mappings.
    static boolean
    includedIn(org.apache.jena.sparql.engine.binding.Binding b1, org.apache.jena.sparql.engine.binding.Binding b2)
    Returns true if the first solution mapping, b1, is included in the second solution mapping, b2, where we say that 'b1 is included in b2' if the variables in b1 are a proper subset of the variables in b2 and the two solution mappings are compatible.
    Merges the given solution mappings into one, assuming that the given solution mappings are compatible.
    Performs a nested-loop join between two Solution Mapping iterables.
    static org.apache.jena.sparql.engine.binding.Binding
    restrict(org.apache.jena.sparql.engine.binding.Binding input, Collection<org.apache.jena.sparql.core.Var> vars)
    Restricts the given solution mapping to the given set of variables.
    restrict(SolutionMapping sm, Collection<org.apache.jena.sparql.core.Var> vars)
    Restricts the given solution mapping to the given set of variables.

    Methods inherited from class java.lang.Object

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

    • SolutionMappingUtils

      public SolutionMappingUtils()
  • Method Details

    • createSolutionMapping

      public static SolutionMapping createSolutionMapping()
      Creates an empty solution mapping.
    • createSolutionMapping

      public static SolutionMapping createSolutionMapping(org.apache.jena.query.QuerySolution s)
      Creates a solution mapping based on the given QuerySolution.
    • createSolutionMapping

      public static SolutionMapping createSolutionMapping(org.apache.jena.sparql.core.Var var, org.apache.jena.graph.Node node)
      Creates a solution mapping in which the given variable is mapped to the given node.
    • createSolutionMapping

      public static SolutionMapping createSolutionMapping(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node node1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node node2)
      Creates a solution mapping in which the given variables are mapped to the given nodes, respectively.
    • createSolutionMapping

      public static SolutionMapping createSolutionMapping(org.apache.jena.sparql.core.Var var1, org.apache.jena.graph.Node node1, org.apache.jena.sparql.core.Var var2, org.apache.jena.graph.Node node2, org.apache.jena.sparql.core.Var var3, org.apache.jena.graph.Node node3)
      Creates a solution mapping in which the given variables are mapped to the given nodes, respectively.
    • equals

      public static boolean equals(SolutionMapping m1, SolutionMapping m2)
      Returns true if the given solution mappings are equivalent; that is, if they are defined for the exact same set of variables and they are compatible.
    • equals

      public static boolean equals(Set<SolutionMapping> s1, Set<SolutionMapping> s2)
      Returns true if the given set of solution mappings are equivalent; that is, if they contain the same number of solution mappings and for each such solution mapping there is an equivalent solution mapping in the respective other set.
    • equalSets

      public static boolean equalSets(Set<org.apache.jena.sparql.engine.binding.Binding> s1, Set<org.apache.jena.sparql.engine.binding.Binding> s2)
      Returns true if the given set of solution mappings are equivalent; that is, if they contain the same number of solution mappings and for each such solution mapping there is an equivalent solution mapping in the respective other set.
    • compatible

      public static boolean compatible(SolutionMapping m1, SolutionMapping m2)
      Returns true if the given solution mappings are compatible.
    • compatible

      public static boolean compatible(org.apache.jena.sparql.engine.binding.Binding b1, org.apache.jena.sparql.engine.binding.Binding b2)
      Returns true if the given bindings are compatible.
    • includedIn

      public static boolean includedIn(org.apache.jena.sparql.engine.binding.Binding b1, org.apache.jena.sparql.engine.binding.Binding b2)
      Returns true if the first solution mapping, b1, is included in the second solution mapping, b2, where we say that 'b1 is included in b2' if the variables in b1 are a proper subset of the variables in b2 and the two solution mappings are compatible. In other words, b1 and b2 are the same for the subset of variables for which they both have bindings and, additionally, b2 has bindings for additional variables.
    • merge

      public static SolutionMapping merge(SolutionMapping m1, SolutionMapping m2)
      Merges the given solution mappings into one, assuming that the given solution mappings are compatible.
    • nestedLoopJoin

      public static Set<SolutionMapping> nestedLoopJoin(Iterable<SolutionMapping> i1, Iterable<SolutionMapping> i2)
      Performs a nested-loop join between two Solution Mapping iterables. If you do not need the join result materialized (as done by this function), it is better to use
      invalid reference
      JoiningIterableForSolMaps
      instead (or the iterator version: JoiningIteratorForSolMaps).
    • applyVocabularyMappingG2L

      public static List<SolutionMapping> applyVocabularyMappingG2L(Iterable<SolutionMapping> it, VocabularyMapping vm)
      Applies the given vocabulary mapping to each of the solution mappings of the given iterable (translating them from the global vocabulary to the local vocabulary), collects the resulting solution mappings in a list, and returns this list in the end. Attention: While this function materializes the complete list of all the resulting solution mappings, for use cases in which such a materialization is not necessary, use
      invalid reference
      RewritingIterableForSolMapsG2L
      or
      invalid reference
      RewritingIteratorForSolMapsG2L
      instead.
    • applyVocabularyMappingG2L

      public static List<SolutionMapping> applyVocabularyMappingG2L(Iterator<SolutionMapping> it, VocabularyMapping vm)
      Applies the given vocabulary mapping to each of the solution mappings of the given iterator (translating them from the global vocabulary to the local vocabulary), collects the resulting solution mappings in a list, and returns this list in the end. Attention: While this function materializes the complete list of all the resulting solution mappings, for use cases in which such a materialization is not necessary, use
      invalid reference
      RewritingIterableForSolMapsG2L
      or
      invalid reference
      RewritingIteratorForSolMapsG2L
      instead.
    • applyVocabularyMappingL2G

      public static List<SolutionMapping> applyVocabularyMappingL2G(Iterable<SolutionMapping> it, VocabularyMapping vm)
      Applies the given vocabulary mapping to each of the solution mappings of the given iterable (translating them from the local vocabulary to the global vocabulary), collects the resulting solution mappings in a list, and returns this list in the end. Attention: While this function materializes the complete list of all the resulting solution mappings, for use cases in which such a materialization is not necessary, use
      invalid reference
      RewritingIterableForSolMapsL2G
      or
      invalid reference
      RewritingIteratorForSolMapsL2G
      instead.
    • applyVocabularyMappingL2G

      public static List<SolutionMapping> applyVocabularyMappingL2G(Iterator<SolutionMapping> it, VocabularyMapping vm)
      Applies the given vocabulary mapping to each of the solution mappings of the given iterator (translating them from the local vocabulary to the global vocabulary), collects the resulting solution mappings in a list, and returns this list in the end. Attention: While this function materializes the complete list of all the resulting solution mappings, for use cases in which such a materialization is not necessary, use
      invalid reference
      RewritingIterableForSolMapsL2G
      or
      invalid reference
      RewritingIteratorForSolMapsL2G
      instead.
    • restrict

      public static org.apache.jena.sparql.engine.binding.Binding restrict(org.apache.jena.sparql.engine.binding.Binding input, Collection<org.apache.jena.sparql.core.Var> vars)
      Restricts the given solution mapping to the given set of variables. Hence, the returned solution mapping will be compatible with the solution mapping given as input, but it will be defined only for the variables that are in the intersection of the given set of variables and the set of variables for which the given solution mapping is defined.
    • restrict

      public static SolutionMapping restrict(SolutionMapping sm, Collection<org.apache.jena.sparql.core.Var> vars)
      Restricts the given solution mapping to the given set of variables. Hence, the returned solution mapping will be compatible with the solution mapping given as input, but it will be defined only for the variables that are in the intersection of the given set of variables and the set of variables for which the given solution mapping is defined.
    • containsBlankNodes

      public static boolean containsBlankNodes(SolutionMapping sm)
      Returns true if the given solution mapping binds any of its variables to a blank node.
    • containsBlankNodes

      public static boolean containsBlankNodes(org.apache.jena.sparql.engine.binding.Binding b)
      Returns true if the given solution mapping binds any of its variables to a blank node.
    • getAllMentionedVariables

      public static Set<org.apache.jena.sparql.core.Var> getAllMentionedVariables(Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps)
      Returns a set containing all the variables that have a binding in at least one of the given solution mappings.
    • createValuesClause

      public static String createValuesClause(Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
      Serializes the given collection of solution mappings as a string that can be used in a SPARQL VALUES clause.
    • createValuesClauseShortForm

      protected static String createValuesClauseShortForm(List<org.apache.jena.sparql.core.Var> vars, Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
    • createValuesClauseLongForm

      protected static String createValuesClauseLongForm(List<org.apache.jena.sparql.core.Var> vars, Iterable<org.apache.jena.sparql.engine.binding.Binding> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
    • appendValuesClauseEntry

      protected static void appendValuesClauseEntry(StringBuilder b, List<org.apache.jena.sparql.core.Var> vars, org.apache.jena.sparql.engine.binding.Binding sm, org.apache.jena.sparql.serializer.SerializationContext scxt)