Class QueryWhereHandler<C>

  • Type Parameters:
    C - the type of context, which is used by term handlers to report processing outputs

    public class QueryWhereHandler<C>
    extends Object
    Handles the terms found in an oslc.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 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 an oslc.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 expression
        context - 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()