Package org.eclipse.rdf4j.queryrender
Class BaseTupleExprRenderer
- java.lang.Object
-
- org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor<java.lang.Exception>
-
- org.eclipse.rdf4j.queryrender.BaseTupleExprRenderer
-
- All Implemented Interfaces:
QueryModelVisitor<java.lang.Exception>
- Direct Known Subclasses:
SparqlQueryRenderer,SparqlTupleExprRenderer
public abstract class BaseTupleExprRenderer extends AbstractQueryModelVisitor<java.lang.Exception>
Base class for rendering RDF4J query API objects into strings.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanmDistinctWhether or not the query is distinctprotected java.util.Map<java.lang.String,ValueExpr>mExtensionsA map of the extensions specified in the query.protected longmLimitThe limit of results for the query, or -1 for no limitprotected longmOffsetThe query offset, or -1 for no offsetprotected java.util.List<OrderElem>mOrderingThe elements specified in the order by clause of the queryprotected java.util.List<ProjectionElemList>mProjectionThe list of elements include in the projection of the queryprotected booleanmReducedWhether or not the query is reduced
-
Constructor Summary
Constructors Constructor Description BaseTupleExprRenderer()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private ValueasValue(ValueExpr theValue)java.util.Map<java.lang.String,ValueExpr>getExtensions()longgetLimit()longgetOffset()java.util.List<OrderElem>getOrdering()java.util.List<ProjectionElemList>getProjection()booleanisDistinct()booleanisReduced()protected booleanisSelect()Returns whether or not the results of scanning the query model indicates that this represents a select querystatic booleanisSPOElemList(ProjectionElemList theList)Return whether or not this projection looks like an spo binding for a construct queryvoidmeet(Distinct theDistinct)voidmeet(ExtensionElem theExtensionElem)voidmeet(OrderElem theOrderElem)voidmeet(ProjectionElemList theProjectionElemList)voidmeet(Reduced theReduced)voidmeet(Slice theSlice)voidmeet(StatementPattern theStatementPattern)abstract java.lang.Stringrender(TupleExpr theExpr)Render the TupleExpr as a query or query fragment depending on what kind of TupleExpr it isjava.lang.Stringrender(ParsedQuery theQuery)Render the ParsedQuery as a query stringprotected abstract java.lang.StringrenderValueExpr(ValueExpr theExpr)Render the given ValueExprvoidreset()Reset the state of the rendererstatic java.lang.StringscrubVarName(java.lang.String theName)Scrub any illegal characters out of the variable nameStatementPatterntoStatementPattern(ProjectionElemList theList)Turn a ProjectionElemList for a construct query projection (three elements aliased as 'subject', 'predicate' and 'object' in that order) into a StatementPattern.-
Methods inherited from class org.eclipse.rdf4j.query.algebra.helpers.AbstractQueryModelVisitor
meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meet, meetBinaryTupleOperator, meetBinaryValueOperator, meetCompareSubQueryValueOperator, meetNAryValueOperator, meetNode, meetOther, meetSubQueryValueOperator, meetUnaryTupleOperator, meetUnaryValueOperator, meetUpdateExpr
-
-
-
-
Field Detail
-
mExtensions
protected java.util.Map<java.lang.String,ValueExpr> mExtensions
A map of the extensions specified in the query.
-
mProjection
protected java.util.List<ProjectionElemList> mProjection
The list of elements include in the projection of the query
-
mOrdering
protected java.util.List<OrderElem> mOrdering
The elements specified in the order by clause of the query
-
mDistinct
protected boolean mDistinct
Whether or not the query is distinct
-
mReduced
protected boolean mReduced
Whether or not the query is reduced
-
mLimit
protected long mLimit
The limit of results for the query, or -1 for no limit
-
mOffset
protected long mOffset
The query offset, or -1 for no offset
-
-
Method Detail
-
reset
public void reset()
Reset the state of the renderer
-
getExtensions
public java.util.Map<java.lang.String,ValueExpr> getExtensions()
-
getProjection
public java.util.List<ProjectionElemList> getProjection()
-
getOrdering
public java.util.List<OrderElem> getOrdering()
-
isDistinct
public boolean isDistinct()
-
isReduced
public boolean isReduced()
-
getLimit
public long getLimit()
-
getOffset
public long getOffset()
-
render
public java.lang.String render(ParsedQuery theQuery) throws java.lang.Exception
Render the ParsedQuery as a query string- Parameters:
theQuery- the parsed query to render- Returns:
- the query object rendered in the query language syntax
- Throws:
java.lang.Exception- if there is an error while rendering
-
render
public abstract java.lang.String render(TupleExpr theExpr) throws java.lang.Exception
Render the TupleExpr as a query or query fragment depending on what kind of TupleExpr it is- Parameters:
theExpr- the expression to render- Returns:
- the TupleExpr rendered in the query language syntax
- Throws:
java.lang.Exception- if there is an error while rendering
-
renderValueExpr
protected abstract java.lang.String renderValueExpr(ValueExpr theExpr) throws java.lang.Exception
Render the given ValueExpr- Parameters:
theExpr- the expr to render- Returns:
- the rendered expression
- Throws:
java.lang.Exception- if there is an error while rendering
-
toStatementPattern
public StatementPattern toStatementPattern(ProjectionElemList theList) throws java.lang.Exception
Turn a ProjectionElemList for a construct query projection (three elements aliased as 'subject', 'predicate' and 'object' in that order) into a StatementPattern.- Parameters:
theList- the elem list to render- Returns:
- the elem list for a construct projection as a statement pattern
- Throws:
java.lang.Exception- if there is an exception while rendering
-
scrubVarName
public static java.lang.String scrubVarName(java.lang.String theName)
Scrub any illegal characters out of the variable name- Parameters:
theName- the potential variable name- Returns:
- the name scrubbed of any illegal characters
-
asValue
private Value asValue(ValueExpr theValue) throws java.lang.Exception
- Parameters:
theValue- the ValueExpr to convert- Returns:
- the expression as a Value, or null if it cannot be converted
- Throws:
java.lang.Exception- if there is an error converting to a Value
-
isSelect
protected boolean isSelect()
Returns whether or not the results of scanning the query model indicates that this represents a select query- Returns:
- true if its a select query, false if its a construct query
-
isSPOElemList
public static boolean isSPOElemList(ProjectionElemList theList)
Return whether or not this projection looks like an spo binding for a construct query- Parameters:
theList- the projection element list to inspect- Returns:
- true if it has the format of a spo construct projection element, false otherwise
-
meet
public void meet(StatementPattern theStatementPattern) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(Slice theSlice) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(ExtensionElem theExtensionElem) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(ProjectionElemList theProjectionElemList) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(OrderElem theOrderElem) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(Distinct theDistinct) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
meet
public void meet(Reduced theReduced) throws java.lang.Exception
- Specified by:
meetin interfaceQueryModelVisitor<java.lang.Exception>- Overrides:
meetin classAbstractQueryModelVisitor<java.lang.Exception>- Throws:
java.lang.Exception
-
-