Class SolutionMappingUtils

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

public class SolutionMappingUtils extends Object
  • 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.
    • compatible

      public static boolean compatible(SolutionMapping m1, SolutionMapping m2)
      Returns true if the given solution mappings are compatible.
    • 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 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 RewritingIterableForSolMapsG2L or 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 RewritingIterableForSolMapsG2L or 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 RewritingIterableForSolMapsL2G or 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 RewritingIterableForSolMapsL2G or 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 Jena binding to the given set of variables. Hence, the returned binding will be compatible to 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 binding 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 to 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<SolutionMapping> 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<SolutionMapping> 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<SolutionMapping> solmaps, org.apache.jena.sparql.serializer.SerializationContext scxt)
    • createValuesClauseLongForm

      protected static String createValuesClauseLongForm(List<org.apache.jena.sparql.core.Var> vars, Iterable<SolutionMapping> 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)