Class AbstractQueryHandler<E>

    • Constructor Detail

      • AbstractQueryHandler

        public AbstractQueryHandler()
    • Method Detail

      • getLogger

        protected abstract org.apache.log4j.Logger getLogger()
      • parseQueryStringParam

        protected abstract void parseQueryStringParam​(java.lang.String paramName,
                                                      java.lang.String[] paramValues)
        Method to be implemented by subclass to decode parameter from queryString.
        Parameters:
        paramName - the parameter name, never null nor empty.
        paramValues - the parameter values, NEVER NULL NOR EMPTY. You can safely invoke paramValues[0]
        Since:
        jcms-5.7.5
      • init

        protected void init​(java.lang.String queryString,
                            javax.servlet.http.HttpServletRequest request)
        Method to be called by constructor to initialize this handler from a querystring and an optional request.
        Parameters:
        queryString - a query String consisting of parameters (key=value) to be set in this handler.
        • Parameters must be separated with ampersand (&).
        • Values must be encoded in UTF-8.
        • Query must not starts with question mark (?)
          e.g : "groupText=welcome&gid=j_42"
        request - the HttpServletRequest to use to retrieve loggedMember, userLang, userLocale that will be used by this handler, ignored if null.
        Since:
        jcms-5.7.4
      • parseQueryString

        public static java.util.Hashtable<java.lang.String,​java.lang.String[]> parseQueryString​(java.lang.String s)
        Parses a query string passed from the client to the server and builds a HashTable object with key-value pairs. The query string should be in the form of a string packaged by the GET or POST method, that is, it should have key-value pairs in the form key=value, with each pair separated from the next by a & character.

        A key can appear more than once in the query string with different values. However, the key appears only once in the hashtable, with its value being an array of strings containing the multiple values sent by the query string.

        The keys and values in the hashtable are stored in their decoded form, so any + characters are converted to spaces, and characters sent in hexadecimal notation (like %wx%yz) are converted to UTF-8 characters.

        Method taken from deprecated package javax.servlet.http.HttpUtils.

        Parameters:
        s - a string containing the query to be parsed
        Returns:
        a HashTable object built from the parsed key-value pairs
        Throws:
        java.lang.IllegalArgumentException - if the query string is invalid
      • setDataSet

        public void setDataSet​(java.util.Set<? extends E> proposedDataSet)
        Defines the base Set of Data to use for the query, results of this query will be taken from this Set. Default is null, which performs a search in all data, invoke this method to provide a smaller set to optimize the query.
        Parameters:
        proposedDataSet - a Set of Data
        Since:
        jcms-5.7.4
      • getDataSet

        public java.util.Set<? extends E> getDataSet()
        Retrieves the base Set of Data to use for the query, results of this query will be taken from this Set.
        Returns:
        a Set of Data of null if no base set has been defined (and that all data will be used).
        Since:
        jcms-5.7.4
        See Also:
        setDataSet(Set)
      • setAttribute

        public java.lang.Object setAttribute​(java.lang.String name,
                                             java.lang.Object obj)
        Stores an attribute in this query.
        If the object passed in is null, the effect is the same as calling removeAttribute(java.lang.String).
        Parameters:
        name - a String specifying the name of the attribute
        obj - the Object to be stored
        Returns:
        previous value associated with specified name, or null if there was no mapping for name. A null return can also indicate that null was associated with the specified name.
        Since:
        jcms-5.7.2
      • removeAttribute

        public java.lang.Object removeAttribute​(java.lang.String name)
        Removes an attribute from this result.
        Parameters:
        name - a String specifying
        Returns:
        previous value associated with specified name, or null if there was no mapping for name. A null return can also indicate that null was associated with the specified name.
        Since:
        jcms-5.7.2
      • getAttribute

        public java.lang.Object getAttribute​(java.lang.String name)
        Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
        Parameters:
        name - a String specifying the name of the attribute
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
        Since:
        jcms-5.7.2
      • getAttributeMap

        public java.util.Map<java.lang.String,​java.lang.Object> getAttributeMap()
        Returns a java.util.Map of the attributes of this results.
        Returns:
        the internal Map used by this results, modify with care.
        Since:
        jcms-5.7.2
      • getQueryString

        public java.lang.String getQueryString()
        Returns all parameters of this handler as a queryString.
        For example :
        "types=Content&cids=c_42"
        Returns:
        a query string, starting with a parameter name (no '?' or '&')
      • getHiddenParams

        public java.lang.String getHiddenParams()
        Returns all parameters of this QueryHandler as a hidden input.
        For example :
          <input type="hidden" name="types" value="Content"/>
          <input type="hidden" name="cids" value="c_42"/>
         
        Returns:
        a html string, containing all hidden inputs.
        Since:
        jcms-5.7.0
      • printParams

        protected abstract java.lang.String printParams​(AbstractQueryHandler.QueryHandlerPrinter printer)
        Method to be implemented by subclass to provide params printing in query or hidden input format.
        Typical implementation :
         protected String printParams(QueryHandlerPrinter printer) {
           printer.printParam("foo", getFoo());
           printer.printParam("bar", getBar());
           return printer.toString();
         }
         
        Parameters:
        printer - a QueryHandlerPrinter to use
        Returns:
        a string containing all parameters of this handler printed using specified QueryHandlerPrinter.
        Since:
        jcms-5.7.4