Class RequestParams


  • public class RequestParams
    extends Object
    Class that contains the parameters of the user's request. Parameter names are not case sensitive.
    Author:
    Jon Blower, Guy Griffiths
    • Constructor Summary

      Constructors 
      Constructor Description
      RequestParams​(Map<?,​?> httpRequestParamMap)
      Creates a new RequestParams object from the given Map of parameter names and values (normally gained from HttpServletRequest.getParameterMap()).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean getBoolean​(String paramName, boolean defaultValue)
      Returns the value of the parameter with the given name as a boolean value, or the provided default if no parameter with the given name has been supplied.
      float getFloat​(String paramName, float defaultValue)
      Returns the value of the parameter with the given name, or the supplied default value if the parameter does not exist.
      int getInt​(String paramName, int defaultValue)
      Returns the value of the parameter with the given name as a positive integer, or the provided default if no parameter with the given name has been supplied.
      float getMandatoryFloat​(String paramName)
      Returns the value of the parameter with the given name, or throws an exception if the parameter is not available
      int getMandatoryPositiveInt​(String paramName)
      Returns the value of the parameter with the given name as a positive integer, throwing a WmsException if the parameter does not exist or if the value is not a valid positive integer.
      String getMandatoryString​(String paramName)
      Returns the value of the parameter with the given name, throwing an EdalException if the parameter does not exist.
      String getMandatoryWmsVersion()
      Finds the WMS version that the user has requested, throwing a WmsException if a version has not been set.
      int getPositiveInt​(String paramName, int defaultValue)
      Returns the value of the parameter with the given name as a positive integer, or the provided default if no parameter with the given name has been supplied.
      String getString​(String paramName)
      Returns the value of the parameter with the given name as a String, or null if the parameter does not have a value.
      String getString​(String paramName, String defaultValue)
      Returns the value of the parameter with the given name, or the supplied default value if the parameter does not exist.
      String getWmsVersion()
      Finds the WMS version that the user has requested.
      RequestParams mergeParameters​(Map<String,​String> mergeParameters)
      Create a new RequestParams from this one, merging in new values
      String toString()  
    • Constructor Detail

      • RequestParams

        public RequestParams​(Map<?,​?> httpRequestParamMap)
        Creates a new RequestParams object from the given Map of parameter names and values (normally gained from HttpServletRequest.getParameterMap()). The Map matches parameter names (Strings) to parameter values (String arrays).
        Parameters:
        httpRequestParamMap - The Map to generate request values from. This is unparameterised, since it most often comes from ServletRequest.getParameterMap(), which is unparameterised
    • Method Detail

      • mergeParameters

        public RequestParams mergeParameters​(Map<String,​String> mergeParameters)
        Create a new RequestParams from this one, merging in new values
        Parameters:
        mergeParameters - The new values to merge in
        Returns:
        A new instance of RequestParams containing these parameters plus the required new ones. In the case of a name conflict existing parameters will be overwritten by the merged ones.
      • getString

        public String getString​(String paramName)
        Returns the value of the parameter with the given name as a String, or null if the parameter does not have a value. This method is not sensitive to the case of the parameter name. Use getWmsVersion() to get the requested WMS version.
      • getMandatoryString

        public String getMandatoryString​(String paramName)
                                  throws EdalException
        Returns the value of the parameter with the given name, throwing an EdalException if the parameter does not exist. Use getMandatoryWmsVersion() to get the requested WMS version.
        Throws:
        EdalException
      • getWmsVersion

        public String getWmsVersion()
        Finds the WMS version that the user has requested. This looks for both WMTVER and VERSION, the latter taking precedence. WMTVER is used by older versions of WMS and older clients may use this in version negotiation.
        Returns:
        The request WMS version as a string, or null if not set
      • getMandatoryWmsVersion

        public String getMandatoryWmsVersion()
                                      throws EdalException
        Finds the WMS version that the user has requested, throwing a WmsException if a version has not been set.
        Returns:
        The request WMS version as a string
        Throws:
        EdalException - if neither VERSION nor WMTVER have been requested
      • getInt

        public int getInt​(String paramName,
                          int defaultValue)
                   throws EdalException
        Returns the value of the parameter with the given name as a positive integer, or the provided default if no parameter with the given name has been supplied. Throws a WmsException if the parameter does not exist or if the value is not a valid positive integer. Zero is counted as a positive integer.
        Throws:
        EdalException
      • getPositiveInt

        public int getPositiveInt​(String paramName,
                                  int defaultValue)
                           throws EdalException
        Returns the value of the parameter with the given name as a positive integer, or the provided default if no parameter with the given name has been supplied. Throws a WmsException if the parameter does not exist or if the value is not a valid positive integer. Zero is counted as a positive integer.
        Throws:
        EdalException
      • getMandatoryPositiveInt

        public int getMandatoryPositiveInt​(String paramName)
                                    throws EdalException
        Returns the value of the parameter with the given name as a positive integer, throwing a WmsException if the parameter does not exist or if the value is not a valid positive integer. Zero is counted as a positive integer.
        Throws:
        EdalException
      • getString

        public String getString​(String paramName,
                                String defaultValue)
        Returns the value of the parameter with the given name, or the supplied default value if the parameter does not exist.
      • getBoolean

        public boolean getBoolean​(String paramName,
                                  boolean defaultValue)
                           throws EdalException
        Returns the value of the parameter with the given name as a boolean value, or the provided default if no parameter with the given name has been supplied.
        Throws:
        EdalException - if the value is not a valid boolean string ("true" or "false", case-insensitive).
      • getFloat

        public float getFloat​(String paramName,
                              float defaultValue)
                       throws EdalException
        Returns the value of the parameter with the given name, or the supplied default value if the parameter does not exist.
        Throws:
        EdalException - if the value of the parameter is not a valid floating-point number
      • getMandatoryFloat

        public float getMandatoryFloat​(String paramName)
                                throws EdalException
        Returns the value of the parameter with the given name, or throws an exception if the parameter is not available
        Throws:
        EdalException - if the value of the parameter is not a valid floating-point number, or is not available