Class GraphPattern
- java.lang.Object
-
- org.eclipse.rdf4j.query.parser.sparql.GraphPattern
-
@InternalUseOnly public class GraphPattern extends java.lang.Object
A graph pattern consisting of (required and optional) tuple expressions, binding assignments and boolean constraints.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<ValueExpr>constraintsThe boolean constraints in this graph pattern.private VarcontextVarThe context of this graph pattern.private java.util.List<java.util.Map.Entry<TupleExpr,java.util.List<ValueExpr>>>optionalTEsThe optional tuple expressions in this graph pattern, as a list of Key-Value pairs with the tuple expression as the key and a list of constraints applicable to the tuple expression as the value.private java.util.List<TupleExpr>requiredTEsThe required tuple expressions in this graph pattern.private StatementPattern.ScopespScopeThe StatementPattern-scope of this graph pattern.
-
Constructor Summary
Constructors Constructor Description GraphPattern()Creates a new graph pattern.GraphPattern(GraphPattern parent)Creates a new graph pattern that inherits the context and scope from a parent graph pattern.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConstraint(ValueExpr constraint)voidaddConstraints(java.util.Collection<ValueExpr> constraints)voidaddOptionalTE(TupleExpr te, java.util.List<ValueExpr> constraints)add the supplied tuple expression as an optional expression, with a list of constraints that hold as conditions.voidaddRequiredSP(Var subjVar, Var predVar, Var objVar)voidaddRequiredTE(TupleExpr te)(package private) TupleExprbuildJoinFromRequiredTEs()Build a single tuple expression representing _only_ the basic graph pattern, by joining the required TEsTupleExprbuildOptionalTE(TupleExpr result)Build optionals to the supplied TETupleExprbuildTupleExpr()Builds a combined tuple expression from the tuple expressions and constraints in this graph pattern.voidclear()Removes all tuple expressions and constraints.(package private) voidclearRequiredTEs()Remove all values for required tuple expressions in thisGraphPatternjava.util.List<ValueExpr>getConstraints()VargetContextVar()java.util.List<java.util.Map.Entry<TupleExpr,java.util.List<ValueExpr>>>getOptionalTEs()Retrieves the optional tuple expressions as a list of tuples with the tuple expression as the key and the list of value expressions as the value.java.util.List<TupleExpr>getRequiredTEs()StatementPattern.ScopegetStatementPatternScope()java.util.List<ValueExpr>removeAllConstraints()voidsetContextVar(Var contextVar)voidsetStatementPatternScope(StatementPattern.Scope spScope)
-
-
-
Field Detail
-
contextVar
private Var contextVar
The context of this graph pattern.
-
spScope
private StatementPattern.Scope spScope
The StatementPattern-scope of this graph pattern.
-
requiredTEs
private final java.util.List<TupleExpr> requiredTEs
The required tuple expressions in this graph pattern.
-
optionalTEs
private final java.util.List<java.util.Map.Entry<TupleExpr,java.util.List<ValueExpr>>> optionalTEs
The optional tuple expressions in this graph pattern, as a list of Key-Value pairs with the tuple expression as the key and a list of constraints applicable to the tuple expression as the value.
-
constraints
private java.util.List<ValueExpr> constraints
The boolean constraints in this graph pattern.
-
-
Constructor Detail
-
GraphPattern
public GraphPattern()
Creates a new graph pattern.
-
GraphPattern
public GraphPattern(GraphPattern parent)
Creates a new graph pattern that inherits the context and scope from a parent graph pattern.
-
-
Method Detail
-
setContextVar
public void setContextVar(Var contextVar)
-
getContextVar
public Var getContextVar()
-
setStatementPatternScope
public void setStatementPatternScope(StatementPattern.Scope spScope)
-
getStatementPatternScope
public StatementPattern.Scope getStatementPatternScope()
-
addRequiredTE
public void addRequiredTE(TupleExpr te)
-
clearRequiredTEs
void clearRequiredTEs()
Remove all values for required tuple expressions in thisGraphPattern
-
getRequiredTEs
public java.util.List<TupleExpr> getRequiredTEs()
-
addOptionalTE
public void addOptionalTE(TupleExpr te, java.util.List<ValueExpr> constraints)
add the supplied tuple expression as an optional expression, with a list of constraints that hold as conditions.- Parameters:
te- a tuple expressionconstraints- a list of constraints that form a condition for the LeftJoin to be formed from the optional TE.
-
getOptionalTEs
public java.util.List<java.util.Map.Entry<TupleExpr,java.util.List<ValueExpr>>> getOptionalTEs()
Retrieves the optional tuple expressions as a list of tuples with the tuple expression as the key and the list of value expressions as the value.- Returns:
- a list of Map entries.
-
addConstraint
public void addConstraint(ValueExpr constraint)
-
addConstraints
public void addConstraints(java.util.Collection<ValueExpr> constraints)
-
getConstraints
public java.util.List<ValueExpr> getConstraints()
-
removeAllConstraints
public java.util.List<ValueExpr> removeAllConstraints()
-
clear
public void clear()
Removes all tuple expressions and constraints.
-
buildTupleExpr
public TupleExpr buildTupleExpr()
Builds a combined tuple expression from the tuple expressions and constraints in this graph pattern.- Returns:
- A tuple expression for this graph pattern.
-
buildOptionalTE
public TupleExpr buildOptionalTE(TupleExpr result)
Build optionals to the supplied TE
-
buildJoinFromRequiredTEs
TupleExpr buildJoinFromRequiredTEs()
Build a single tuple expression representing _only_ the basic graph pattern, by joining the required TEs
-
-