Package org.eclipse.rdf4j.query.algebra
Class Service
- java.lang.Object
-
- org.eclipse.rdf4j.query.algebra.AbstractQueryModelNode
-
- org.eclipse.rdf4j.query.algebra.UnaryTupleOperator
-
- org.eclipse.rdf4j.query.algebra.Service
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,GraphPatternGroupable,QueryModelNode,TupleExpr,VariableScopeChange
public class Service extends UnaryTupleOperator
The SERVICE keyword as defined in SERVICE definition. The service expression is evaluated at the specified service URI. If the service reference is a variable, a value for this variable must be available at evaluation time (e.g. from earlier computations).- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringbaseURIprivate java.util.Map<java.lang.String,java.lang.String>prefixDeclarationsprivate java.lang.StringpreparedAskQueryStringprivate java.lang.StringpreparedSelectQueryStringprivate java.lang.StringserviceExpressionStringprivate VarserviceRefprivate java.util.Set<java.lang.String>serviceVarsprivate booleansilentprivate static java.util.regex.PatternsubselectPattern-
Fields inherited from class org.eclipse.rdf4j.query.algebra.UnaryTupleOperator
arg
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Serviceclone()Returns a (deep) clone of this query model node.private java.lang.StringcomputePrefixString(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations)Compute the prefix string only once to avoid computation overhead during evaluation.private java.util.Set<java.lang.String>computeServiceVars(TupleExpr serviceExpression)Compute the variable names occurring in the service expression using tree traversal, since these are necessary for building the SPARQL query.booleanequals(java.lang.Object other)Returns true if this query model node and its children are recursively equal to o and its children.java.lang.StringgetAskQueryString()Returns an ASK query string using no projection vars.java.lang.StringgetBaseURI()java.util.Map<java.lang.String,java.lang.String>getPrefixDeclarations()java.lang.StringgetSelectQueryString(java.util.Set<java.lang.String> projectionVars)Returns a SELECT query string using the provided projection vars.TupleExprgetServiceExpr()java.lang.StringgetServiceExpressionString()VargetServiceRef()java.util.Set<java.lang.String>getServiceVars()inthashCode()private voidinitPreparedQueryString()booleanisSilent()private java.lang.StringparseServiceExpression(java.lang.String serviceExpression)Parses a service expression to just have the inner expression, e.g.voidreplaceChildNode(QueryModelNode current, QueryModelNode replacement)Default implementation ofQueryModelNode.replaceChildNode(QueryModelNode, QueryModelNode)that throws anIllegalArgumentExceptionindicating that current is not a child node of this node.voidsetBaseURI(java.lang.String baseURI)voidsetExpressionString(java.lang.String serviceExpressionString)The SERVICE expression, either complete or just the expression e.g.voidsetPrefixDeclarations(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations)voidsetServiceRef(Var serviceRef)<X extends java.lang.Exception>
voidvisit(QueryModelVisitor<X> visitor)Visits this node.<X extends java.lang.Exception>
voidvisitChildren(QueryModelVisitor<X> visitor)Dummy implementation ofQueryModelNode.visitChildren(org.eclipse.rdf4j.query.algebra.QueryModelVisitor<X>)that does nothing.-
Methods inherited from class org.eclipse.rdf4j.query.algebra.UnaryTupleOperator
getArg, getAssuredBindingNames, getBindingNames, setArg
-
Methods inherited from class org.eclipse.rdf4j.query.algebra.AbstractQueryModelNode
getCardinality, getCostEstimate, getParentNode, getResultSizeActual, getResultSizeEstimate, getSignature, getTotalTimeNanosActual, isCardinalitySet, isGraphPatternGroup, isVariableScopeChange, nullEquals, replaceNodeInList, replaceWith, resetCardinality, setCardinality, setCostEstimate, setGraphPatternGroup, setParentNode, setResultSizeActual, setResultSizeEstimate, setTotalTimeNanosActual, setVariableScopeChange, shouldCacheCardinality, toHumanReadbleNumber, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.query.algebra.QueryModelNode
getCostEstimate, getParentNode, getResultSizeActual, getResultSizeEstimate, getSignature, getTotalTimeNanosActual, replaceWith, setCostEstimate, setParentNode, setResultSizeActual, setResultSizeEstimate, setTotalTimeNanosActual, toString
-
-
-
-
Field Detail
-
serviceRef
private Var serviceRef
-
serviceExpressionString
private java.lang.String serviceExpressionString
-
serviceVars
private final java.util.Set<java.lang.String> serviceVars
-
prefixDeclarations
private java.util.Map<java.lang.String,java.lang.String> prefixDeclarations
-
baseURI
private java.lang.String baseURI
-
preparedSelectQueryString
private java.lang.String preparedSelectQueryString
-
preparedAskQueryString
private java.lang.String preparedAskQueryString
-
silent
private final boolean silent
-
subselectPattern
private static final java.util.regex.Pattern subselectPattern
-
-
Method Detail
-
getServiceRef
public Var getServiceRef()
-
getServiceExpr
public TupleExpr getServiceExpr()
-
setServiceRef
public void setServiceRef(Var serviceRef)
-
isSilent
public boolean isSilent()
- Returns:
- Returns the silent.
-
getPrefixDeclarations
public java.util.Map<java.lang.String,java.lang.String> getPrefixDeclarations()
- Returns:
- Returns the prefixDeclarations.
-
setPrefixDeclarations
public void setPrefixDeclarations(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations)
- Parameters:
prefixDeclarations- The prefixDeclarations to set.
-
setExpressionString
public void setExpressionString(java.lang.String serviceExpressionString)
The SERVICE expression, either complete or just the expression e.g. "SERVICE{ ... }" becomes " ... " - Parameters:
serviceExpressionString- the inner expression as SPARQL String representation
-
getServiceExpressionString
public java.lang.String getServiceExpressionString()
- Returns:
- Returns the serviceExpressionString.
-
getAskQueryString
public java.lang.String getAskQueryString()
Returns an ASK query string using no projection vars.- Returns:
- an ASK query string
-
getSelectQueryString
public java.lang.String getSelectQueryString(java.util.Set<java.lang.String> projectionVars)
Returns a SELECT query string using the provided projection vars. The variables are inserted into the preparedSelectQueryString in the SELECT clause.- Parameters:
projectionVars-- Returns:
- SELECT query string, utilizing the given projection variables
-
getServiceVars
public java.util.Set<java.lang.String> getServiceVars()
- Returns:
- Returns the serviceVars.
-
visit
public <X extends java.lang.Exception> void visit(QueryModelVisitor<X> visitor) throws X extends java.lang.Exception
Description copied from interface:QueryModelNodeVisits this node. The node reports itself to the visitor with the proper runtime type.- Throws:
X extends java.lang.Exception
-
visitChildren
public <X extends java.lang.Exception> void visitChildren(QueryModelVisitor<X> visitor) throws X extends java.lang.Exception
Description copied from class:AbstractQueryModelNodeDummy implementation ofQueryModelNode.visitChildren(org.eclipse.rdf4j.query.algebra.QueryModelVisitor<X>)that does nothing. Subclasses should override this method when they have child nodes.- Specified by:
visitChildrenin interfaceQueryModelNode- Overrides:
visitChildrenin classUnaryTupleOperator- Throws:
X extends java.lang.Exception
-
replaceChildNode
public void replaceChildNode(QueryModelNode current, QueryModelNode replacement)
Description copied from class:AbstractQueryModelNodeDefault implementation ofQueryModelNode.replaceChildNode(QueryModelNode, QueryModelNode)that throws anIllegalArgumentExceptionindicating that current is not a child node of this node.- Specified by:
replaceChildNodein interfaceQueryModelNode- Overrides:
replaceChildNodein classUnaryTupleOperator- Parameters:
current- The current child node.replacement- The new child node.
-
equals
public boolean equals(java.lang.Object other)
Description copied from interface:QueryModelNodeReturns true if this query model node and its children are recursively equal to o and its children.- Specified by:
equalsin interfaceQueryModelNode- Overrides:
equalsin classUnaryTupleOperator
-
hashCode
public int hashCode()
- Overrides:
hashCodein classUnaryTupleOperator
-
clone
public Service clone()
Description copied from interface:QueryModelNodeReturns a (deep) clone of this query model node. This method recursively clones the entire node tree, starting from this nodes.- Specified by:
clonein interfaceQueryModelNode- Specified by:
clonein interfaceTupleExpr- Overrides:
clonein classUnaryTupleOperator- Returns:
- A deep clone of this query model node.
-
computeServiceVars
private java.util.Set<java.lang.String> computeServiceVars(TupleExpr serviceExpression)
Compute the variable names occurring in the service expression using tree traversal, since these are necessary for building the SPARQL query.- Returns:
- the set of variable names in the given service expression
-
initPreparedQueryString
private void initPreparedQueryString()
-
computePrefixString
private java.lang.String computePrefixString(java.util.Map<java.lang.String,java.lang.String> prefixDeclarations)
Compute the prefix string only once to avoid computation overhead during evaluation.- Parameters:
prefixDeclarations-- Returns:
- a Prefix String or an empty string if there are no prefixes
-
parseServiceExpression
private java.lang.String parseServiceExpression(java.lang.String serviceExpression)
Parses a service expression to just have the inner expression, e.g. from something like "SERVICE <url> { ... }" becomes " ... ", also appliesString.trim()to remove leading/tailing space- Parameters:
serviceExpression-- Returns:
- the inner expression of the given service expression
-
setBaseURI
public void setBaseURI(java.lang.String baseURI)
- Parameters:
baseURI- The baseURI to set.
-
getBaseURI
public java.lang.String getBaseURI()
- Returns:
- Returns the baseURI.
-
-