Class QueryPatternUtils
java.lang.Object
se.liu.ida.hefquin.base.query.impl.QueryPatternUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BGPapplySolMapToBGP(SolutionMapping sm, BGP bgp) 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.static SPARQLGraphPatternapplySolMapToGraphPattern(SolutionMapping sm, SPARQLGraphPattern pattern) static TriplePatternAttention, 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.static org.apache.jena.sparql.syntax.Elementstatic org.apache.jena.sparql.algebra.OpconvertToJenaOp(SPARQLGraphPattern pattern) Returns a representation of the given graph pattern as an object of theOpinterface of the Jena API.static BGPcreateBGP(org.apache.jena.sparql.core.BasicPattern pattern) static BGPcreateBGP(org.apache.jena.sparql.core.PathBlock pattern) Assumes that the givenPathBlockdoes not contain property path patterns (but only triple patterns).static BGPcreateBGP(org.apache.jena.sparql.syntax.ElementPathBlock pattern) Assumes that the givenElementPathBlockdoes not contain property path patterns (but only triple patterns).static ExpectedVariablesstatic ExpectedVariablesstatic intstatic intReturns the number of elements of the given triple pattern that are blank nodes.static intgetNumberOfTermOccurrences(org.apache.jena.sparql.algebra.Op op) static intgetNumberOfTermOccurrences(org.apache.jena.sparql.algebra.op.Op2 op) static intgetNumberOfTermOccurrences(org.apache.jena.sparql.algebra.op.OpBGP bgp) static intstatic intgetNumberOfTermOccurrences(SPARQLGraphPattern queryPattern) Returns the number of occurrences of RDF terms in the given graph pattern.static intReturns the number of elements of the given triple pattern that are RDF terms.static intgetNumberOfVarOccurrences(org.apache.jena.graph.Triple jenaTP) static intgetNumberOfVarOccurrences(org.apache.jena.sparql.algebra.Op op) static intgetNumberOfVarOccurrences(org.apache.jena.sparql.algebra.op.Op2 op) static intgetNumberOfVarOccurrences(org.apache.jena.sparql.algebra.op.OpBGP bgp) static intstatic intgetNumberOfVarOccurrences(SPARQLGraphPattern queryPattern) Returns the number of occurrences of variables in the given graph pattern.static intReturns the number of elements of the given triple pattern that are variables.static Set<TriplePattern>getTPsInPattern(org.apache.jena.sparql.algebra.Op op) static Set<TriplePattern>getTPsInPattern(org.apache.jena.sparql.algebra.op.Op2 op) static Set<TriplePattern>getTPsInPattern(org.apache.jena.sparql.syntax.Element e) static Set<TriplePattern>getTPsInPattern(SPARQLGraphPattern queryPattern) Returns the set of all triple patterns that occur in the given graph pattern.static Set<org.apache.jena.sparql.core.Var>getVariablesInPattern(org.apache.jena.graph.Triple tp) static Set<org.apache.jena.sparql.core.Var>getVariablesInPattern(org.apache.jena.sparql.algebra.Op op) Ignores variables in FILTER expressions.static Set<org.apache.jena.sparql.core.Var>getVariablesInPattern(org.apache.jena.sparql.algebra.op.Op2 op) static Set<org.apache.jena.sparql.core.Var>getVariablesInPattern(org.apache.jena.sparql.algebra.op.OpBGP bgp) static Set<org.apache.jena.sparql.core.Var>getVariablesInPattern(BGP bgp) 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.static Set<org.apache.jena.sparql.core.Var>static SPARQLGraphPatternmerge(org.apache.jena.sparql.core.VarExprList exprs, SPARQLGraphPattern p) Merges the given BIND clause into the given graph pattern.static SPARQLGraphPatternmerge(org.apache.jena.sparql.expr.ExprList exprs, SPARQLGraphPattern p) Merges the given filter expressions into the given graph pattern.static SPARQLGraphPatternmerge(BGP bgp, SPARQLGraphPattern p) Merges the given BGP into the given graph pattern.static SPARQLGraphPatternMerges the two graph patterns into a single one, using join semantics.static SPARQLGraphPatternmerge(TriplePattern tp, SPARQLGraphPattern p) Merges the given triple pattern into the given graph pattern.
-
Constructor Details
-
QueryPatternUtils
public QueryPatternUtils()
-
-
Method Details
-
createBGP
-
createBGP
Assumes that the givenElementPathBlockdoes not contain property path patterns (but only triple patterns). If it does, this methods throws anIllegalArgumentException. -
createBGP
Assumes that the givenPathBlockdoes not contain property path patterns (but only triple patterns). If it does, this methods throws anIllegalArgumentException. -
convertToJenaOp
Returns a representation of the given graph pattern as an object of theOpinterface of the Jena API. -
convertToJenaElement
-
getTPsInPattern
Returns the set of all triple patterns that occur in the given graph pattern. -
getTPsInPattern
-
getTPsInPattern
-
getTPsInPattern
-
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 aTriplePattern, this function returns the result ofgetVariablesInPattern(TriplePattern). Similarly, if the given pattern is aBGP, this function returns the result ofgetVariablesInPattern(BGP). -
getVariablesInPattern
-
getVariablesInPattern
public static Set<org.apache.jena.sparql.core.Var> getVariablesInPattern(org.apache.jena.graph.Triple tp) -
getVariablesInPattern
-
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
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
Returns the number of elements of the given triple pattern that are RDF terms. -
getNumberOfBNodeOccurrences
Returns the number of elements of the given triple pattern that are blank nodes. -
getNumberOfVarOccurrences
-
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
-
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
-
getNumberOfVarOccurrences
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 aTriplePattern, this function returns the result ofgetNumberOfVarOccurrences(TriplePattern). Similarly, if the given pattern is aBGP, this function returns the result ofgetNumberOfVarOccurrences(BGP). -
getNumberOfTermOccurrences
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 aTriplePattern, this function returns the result ofgetNumberOfTermOccurrences(TriplePattern). Similarly, if the given pattern is aBGP, this function returns the result ofgetNumberOfTermOccurrences(BGP). -
getExpectedVariablesInPattern
-
getExpectedVariablesInQuery
-
applySolMapToGraphPattern
public static SPARQLGraphPattern applySolMapToGraphPattern(SolutionMapping sm, SPARQLGraphPattern pattern) 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. -
applySolMapToTriplePattern
public static TriplePattern applySolMapToTriplePattern(SolutionMapping sm, TriplePattern tp) throws QueryPatternUtils.VariableByBlankNodeSubstitutionException 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. -
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 aBGPif 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
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
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.
-