java.lang.Object
org.apache.jena.sparql.service.enhancer.impl.util.VarScopeUtils

public class VarScopeUtils extends Object
Methods for working with scope levels of SPARQL variables. Includes methods for getting, setting and normalizing scope levels.
  • Constructor Details

    • VarScopeUtils

      public VarScopeUtils()
  • Method Details

    • getPlainName

      public static String getPlainName(String varName)
    • getScopeLevel

      public static int getScopeLevel(org.apache.jena.sparql.core.Var var)
    • getScopeLevel

      public static int getScopeLevel(String varName)
    • allocScoped

      public static org.apache.jena.sparql.core.Var allocScoped(String baseName, int level)
    • getMinimumScopeLevels

      public static Map<String,Integer> getMinimumScopeLevels(Collection<org.apache.jena.sparql.core.Var> vars)
      Returns a mapping of every variable's base name to the minimum seen scope level. Example:
       The input { ?/s, ?//s ?///p }
       yields { "s": 1, "p": 3 }
       
    • normalizeVarScopes

      public static com.google.common.collect.BiMap<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.core.Var> normalizeVarScopes(Collection<org.apache.jena.sparql.core.Var> vars)
      Return a mapping that reduces every variable's scope level by the minimum scope level among the variables having the same base name. Consequently, for every variable name the minimum scope level will be normalized to 0.

      Example: normalizeVarScopes({?a, ?/b, ?//c, ?////c}) yields:

      • ?a -> ?a
      • ?/b -> ?b
      • ?//c -> ?c
      • ?////c -> ?//c
      Parameters:
      vars - A set of variables with arbitrary scope levels.
      Returns:
      A mapping that normalizes every variable's minimum scope to 0.
    • normalizeVarScopesGlobal

      public static com.google.common.collect.BiMap<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.core.Var> normalizeVarScopesGlobal(Collection<org.apache.jena.sparql.core.Var> vars)
      Similar to normalizeVarScopes(Collection), however reduces the scope levels of all variables by the globally minimum scope level. In other words, if the minimum scope level among all given variables is 'n' then the returned mapping reduces every scope level by 'n'.
    • reverseVarRenameMap

      public static Map<org.apache.jena.sparql.core.Var,org.apache.jena.sparql.core.Var> reverseVarRenameMap(Collection<org.apache.jena.sparql.core.Var> vars)
    • reverseVarRename

      public static Set<org.apache.jena.sparql.core.Var> reverseVarRename(Collection<org.apache.jena.sparql.core.Var> vars)
    • reverseVarRename

      public static <C extends Collection<? super org.apache.jena.sparql.core.Var>> C reverseVarRename(Collection<org.apache.jena.sparql.core.Var> vars, C acc)
      Reverse-rename all variables in the given collection