Class QueryPatternUtils

java.lang.Object
se.liu.ida.hefquin.base.query.impl.QueryPatternUtils

public class QueryPatternUtils extends Object
  • Constructor Details

    • QueryPatternUtils

      public QueryPatternUtils()
  • Method Details

    • createBGP

      public static BGP createBGP(org.apache.jena.sparql.core.BasicPattern pattern)
    • createBGP

      public static BGP createBGP(org.apache.jena.sparql.syntax.ElementPathBlock pattern)
      Assumes that the given ElementPathBlock does not contain property path patterns (but only triple patterns). If it does, this methods throws an IllegalArgumentException.
    • createBGP

      public static BGP createBGP(org.apache.jena.sparql.core.PathBlock pattern)
      Assumes that the given PathBlock does not contain property path patterns (but only triple patterns). If it does, this methods throws an IllegalArgumentException.
    • convertToJenaOp

      public static org.apache.jena.sparql.algebra.Op convertToJenaOp(SPARQLGraphPattern pattern)
      Returns a representation of the given graph pattern as an object of the Op interface of the Jena API.
    • convertToJenaElement

      public static org.apache.jena.sparql.syntax.Element convertToJenaElement(SPARQLGraphPattern p)
    • getTPsInPattern

      public static Set<TriplePattern> getTPsInPattern(SPARQLGraphPattern queryPattern)
      Returns the set of all triple patterns that occur in the given graph pattern.
    • getTPsInPattern

      public static Set<TriplePattern> getTPsInPattern(org.apache.jena.sparql.algebra.Op op)
    • getTPsInPattern

      public static Set<TriplePattern> getTPsInPattern(org.apache.jena.sparql.algebra.op.Op2 op)
    • getTPsInPattern

      public static Set<TriplePattern> getTPsInPattern(org.apache.jena.sparql.syntax.Element e)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(SPARQLGraphPattern queryPattern)
      Returns the set of all variables that occur in the given graph pattern, but ignoring variables in FILTER expressions. If the given pattern is a TriplePattern, this function returns the result of getVariablesInPattern(TriplePattern). Similarly, if the given pattern is a BGP, this function returns the result of getVariablesInPattern(BGP).
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(TriplePattern tp)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(org.apache.jena.graph.Triple tp)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(BGP bgp)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(org.apache.jena.sparql.algebra.op.OpBGP bgp)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(org.apache.jena.sparql.algebra.op.Op2 op)
    • getVariablesInPattern

      public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(org.apache.jena.sparql.algebra.Op op)
      Ignores variables in FILTER expressions.
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(TriplePattern tp)
      Returns the number of elements of the given triple pattern that are variables.
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(org.apache.jena.graph.Triple jenaTP)
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(TriplePattern tp)
      Returns the number of elements of the given triple pattern that are RDF terms.
    • getNumberOfBNodeOccurrences

      public static int getNumberOfBNodeOccurrences(TriplePattern tp)
      Returns the number of elements of the given triple pattern that are blank nodes.
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(BGP bgp)
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(org.apache.jena.sparql.algebra.op.OpBGP bgp)
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(org.apache.jena.sparql.algebra.op.Op2 op)
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(org.apache.jena.sparql.algebra.Op op)
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(BGP bgp)
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(org.apache.jena.sparql.algebra.op.Op2 op)
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(org.apache.jena.sparql.algebra.Op op)
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(org.apache.jena.sparql.algebra.op.OpBGP bgp)
    • getNumberOfBNodeOccurrences

      public static int getNumberOfBNodeOccurrences(BGP bgp)
    • getNumberOfVarOccurrences

      public static int getNumberOfVarOccurrences(SPARQLGraphPattern queryPattern)
      Returns the number of occurrences of variables in the given graph pattern. If the same variable occurs multiple times, each occurrence is counted. If the given pattern is a TriplePattern, this function returns the result of getNumberOfVarOccurrences(TriplePattern). Similarly, if the given pattern is a BGP, this function returns the result of getNumberOfVarOccurrences(BGP).
    • getNumberOfTermOccurrences

      public static int getNumberOfTermOccurrences(SPARQLGraphPattern queryPattern)
      Returns the number of occurrences of RDF terms in the given graph pattern. If the same term occurs multiple times, each occurrence is counted. If the given pattern is a TriplePattern, this function returns the result of getNumberOfTermOccurrences(TriplePattern). Similarly, if the given pattern is a BGP, this function returns the result of getNumberOfTermOccurrences(BGP).
    • getExpectedVariablesInPattern

      public static ExpectedVariables getExpectedVariablesInPattern(SPARQLGraphPattern pattern)
    • getExpectedVariablesInQuery

      public static ExpectedVariables getExpectedVariablesInQuery(SPARQLQuery query)
    • applySolMapToGraphPattern

      Throws:
      QueryPatternUtils.VariableByBlankNodeSubstitutionException
    • applySolMapToBGP

      public static BGP applySolMapToBGP(SolutionMapping sm, BGP bgp) throws QueryPatternUtils.VariableByBlankNodeSubstitutionException
      Attention, this function throws an exception in all cases in which one of the variables of the BGP would be replaced by a blank node.
      Throws:
      QueryPatternUtils.VariableByBlankNodeSubstitutionException
    • applySolMapToTriplePattern

      Attention, this function throws an exception in all cases in which one of the variables of the triple pattern would be replaced by a blank node.
      Throws:
      QueryPatternUtils.VariableByBlankNodeSubstitutionException
    • merge

      public static SPARQLGraphPattern merge(org.apache.jena.sparql.expr.ExprList exprs, SPARQLGraphPattern p)
      Merges the given filter expressions into the given graph pattern.
    • merge

      public static SPARQLGraphPattern merge(org.apache.jena.sparql.core.VarExprList exprs, SPARQLGraphPattern p)
      Merges the given BIND clause into the given graph pattern.
    • merge

      Merges the two graph patterns into a single one, using join semantics. Returns a BGP if possible (for instance, if both of the given patterns are BGPs or one of them is a BGP and the other one a triple pattern).
    • merge

      public static SPARQLGraphPattern merge(TriplePattern tp, SPARQLGraphPattern p)
      Merges the given triple pattern into the given graph pattern. If the given graph pattern is also a triple pattern or a BGP, then the resulting graph pattern is a BGP to which the triple pattern was added. Otherwise, the resulting graph pattern is the given graph pattern with the triple pattern joined into it.
    • merge

      public static SPARQLGraphPattern merge(BGP bgp, SPARQLGraphPattern p)
      Merges the given BGP into the given graph pattern. If the given graph pattern is also a BGP, then the resulting graph pattern is a BGP that is the union of the two given BGPs. Otherwise, the resulting graph pattern is the given graph pattern with the BGP joined into it.