Class QueryParser


  • public class QueryParser
    extends java.lang.Object
    Useful class to parse the query. (We should have had this class years ago). This class replaces all replicated code about how to parse a String query into a Query tree, and add it to a pre-existing search request. This is most often called from Manager.newSearchRequest(String,String), although client code can use this method when other forms of Manager.newSearchRequest() are used. Note that this class throws QueryParserException when it gets upset.
    Since:
    2.0
    Author:
    Craig Macdonald
    • Constructor Summary

      Constructors 
      Constructor Description
      QueryParser()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Query parseQuery​(java.lang.String query)
      Parse the specified query.
      static Query parseQuery​(java.lang.String query, java.lang.String qid)
      Parse the specified query.
      static void parseQuery​(java.lang.String query, Request srq)
      Parse the query specified in String query, and use it for the specified search request.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryParser

        public QueryParser()
    • Method Detail

      • parseQuery

        public static void parseQuery​(java.lang.String query,
                                      Request srq)
                               throws QueryParserException
        Parse the query specified in String query, and use it for the specified search request. Under normal usage, called by newSearchRequest(String,String).
        Parameters:
        query - The string query to parse
        srq - The request object that the manager can use
        Throws:
        QueryParserException - when the query cannot be parsed
        Since:
        2.0
      • parseQuery

        public static Query parseQuery​(java.lang.String query)
                                throws QueryParserException
        Parse the specified query.
        Parameters:
        query - The string query to parse
        Throws:
        QueryParserException - when the query cannot be parsed
        Since:
        2.0
      • parseQuery

        public static Query parseQuery​(java.lang.String query,
                                       java.lang.String qid)
                                throws QueryParserException
        Parse the specified query. Qid is optionally provided for exception handling
        Parameters:
        query - The string query to parse
        qid - qid of this query
        Throws:
        QueryParserException - when the query cannot be parsed
        Since:
        5.5