Class Query


  • public class Query
    extends Object
    Represents a query to a source. Subclasses may enforce stricter typing or more verbose setting of parameters.
    Author:
    Roeland Dillen (roeland at atmire dot com)
    • Constructor Detail

      • Query

        public Query()
    • Method Detail

      • getParameters

        public org.apache.commons.collections4.MultiValuedMap getParameters()
        Retrieve the parameters set to this Query object
        Returns:
        the MultiValuedMap set to this object
      • addParameter

        public void addParameter​(String key,
                                 Object value)
        In the parameters variable, adds the value to the collection associated with the specified key.

        Unlike a normal Map the previous value is not replaced. Instead the new value is added to the collection stored against the key.

        Parameters:
        key - the key to store against
        value - the value to add to the collection at the key
      • addSingletonParameter

        protected void addSingletonParameter​(String key,
                                             Object value)
        In the parameters variable, adds the value to the collection associated with the specified key.

        Unlike addParameter(String, Object) the previous value is overridden. First, any existing values are removed, then the new value is added to the collection at the specified key

        Parameters:
        key - the key to store against
        value - the value to add to the collection at the key
      • getParameterAsClass

        public <T> T getParameterAsClass​(String key,
                                         Class<T> clazz)
        Retrieve a parameter as a certain given class
        Type Parameters:
        T - the type of parameter returned.
        Parameters:
        key - the key to retrieve the parameter from
        clazz - the type to retrieve. (If no parameter with that class is found, a null value is returned.)
        Returns:
        the selected parameter, or null.
      • getParameter

        public Collection getParameter​(String key)
        Gets the collection mapped to the specified key. This method is a convenience method to typecast the result of get(key).
        Parameters:
        key - the key used to retrieve the collection
        Returns:
        the collection mapped to the key, null if no mapping
      • setParameters

        public void setParameters​(org.apache.commons.collections4.MultiValuedMap parameters)
        Set the parameters of this query object based on a given MultiValuedMap
        Parameters:
        parameters - a org.apache.commons.collections.map.MultiValuedMap to set to this Query object