Class QueryWhereHandler<C>
- java.lang.Object
-
- com.sodius.oslc.server.process.query.QueryWhereHandler<C>
-
- Type Parameters:
C
- the type of context, which is used byterm handlers
to report processing outputs
public class QueryWhereHandler<C> extends Object
Handles the terms found in anoslc.where
expression. This is for visiting the terms, identifying the OSLC properties used and delegating to specific term handlers for a given context. The context is whatever provides information about the underlying application to term handlers and what may receive their processing output.An naive example of handler can be:
private static class MyQueryWhereTermHandler<T> extends QueryWhereTermHandler<T, StringBuilder> { private MyQueryWhereTermHandler(String propertyDefinition, Class<T> type) { super(propertyDefinition, type); } protected void handle(String property, Operator operator, T value, StringBuilder buffer) { buffer.append("Found " + property + " using " + operator + " and " + value); } }; ... QueryWhereHandler<StringBuilder> whereHandler = new QueryWhereHandler<>(Arrays.asList( new MyQueryWhereTermHandler<>(Dcterms.PROPERTY_TITLE, String.class), new MyQueryWhereTermHandler<>(Dcterms.PROPERTY_IDENTIFIER, String.class))); StringBuilder buffer = new StringBuilder(); whereHandler.apply(whereClause, buffer); System.out.println(buffer.toString());
- Since:
- 3.6.0
-
-
Constructor Summary
Constructors Constructor Description QueryWhereHandler(Collection<QueryWhereTermHandler<?,C>> handlers)
Creates a new instance using the given term handlers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handle(WhereClause whereClause, C context)
Process anoslc.where
expression in a given context.
-
-
-
Constructor Detail
-
QueryWhereHandler
public QueryWhereHandler(Collection<QueryWhereTermHandler<?,C>> handlers)
Creates a new instance using the given term handlers.- Parameters:
handlers
- the term handlers
-
-
Method Detail
-
handle
public void handle(WhereClause whereClause, C context)
Process anoslc.where
expression in a given context.The context is whatever provides information about the underlying application to term handlers and what may receive their processing output.
- Parameters:
whereClause
- the parsed where expressioncontext
- the context that can receive where terms processing output- Throws:
WebApplicationException
- if a term, property, operator or value is not supported- See Also:
QueryParameters.getWhere()
-
-