Package io.muserver

Interface RequestParameters


  • public interface RequestParameters
    Provides access to QueryString or Form values.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Map<java.lang.String,​java.util.List<java.lang.String>> all()
      Gets all the parameters as a map
      boolean contains​(java.lang.String name)
      Returns true if the given parameter is specified with any value
      java.lang.String get​(java.lang.String name)
      Gets the value with the given name, or null if there is no parameter with that name.
      java.lang.String get​(java.lang.String name, java.lang.String defaultValue)
      Gets the value with the given name, or the default value if there is no parameter with that name.
      java.util.List<java.lang.String> getAll​(java.lang.String name)
      Gets all the parameters with the given name, or an empty list if none are found.
      boolean getBoolean​(java.lang.String name)
      Gets a parameter as a boolean, where values such as true, on and yes as considered true, and other values (or no parameter with the name) is considered false.
      double getDouble​(java.lang.String name, double defaultValue)
      Gets the parameter as a double, or returns the default value if it was not specified or was in an invalid format.
      float getFloat​(java.lang.String name, float defaultValue)
      Gets the parameter as a float, or returns the default value if it was not specified or was in an invalid format.
      int getInt​(java.lang.String name, int defaultValue)
      Gets the parameter as an integer, or returns the default value if it was not specified or was in an invalid format.
      long getLong​(java.lang.String name, long defaultValue)
      Gets the parameter as a long, or returns the default value if it was not specified or was in an invalid format.
    • Method Detail

      • all

        java.util.Map<java.lang.String,​java.util.List<java.lang.String>> all()
        Gets all the parameters as a map
        Returns:
        A map of parameter names to value list
      • get

        java.lang.String get​(java.lang.String name)

        Gets the value with the given name, or null if there is no parameter with that name.

        If there are multiple parameters with the same name, the first one is returned.

        Parameters:
        name - The name of the parameter to get
        Returns:
        The value, or null
      • get

        java.lang.String get​(java.lang.String name,
                             java.lang.String defaultValue)

        Gets the value with the given name, or the default value if there is no parameter with that name.

        If there are multiple parameters with the same name, the first one is returned.

        Parameters:
        name - The name of the parameter to get
        defaultValue - The default value to use if there is no given value
        Returns:
        The value of the parameter, or the default value
      • getInt

        int getInt​(java.lang.String name,
                   int defaultValue)
        Gets the parameter as an integer, or returns the default value if it was not specified or was in an invalid format.
        Parameters:
        name - The name of the parameter.
        defaultValue - The value to use if none was specified, or an invalid format was used.
        Returns:
        Returns the parameter value as an integer.
      • getLong

        long getLong​(java.lang.String name,
                     long defaultValue)
        Gets the parameter as a long, or returns the default value if it was not specified or was in an invalid format.
        Parameters:
        name - The name of the parameter.
        defaultValue - The value to use if none was specified, or an invalid format was used.
        Returns:
        Returns the parameter value as a long.
      • getFloat

        float getFloat​(java.lang.String name,
                       float defaultValue)
        Gets the parameter as a float, or returns the default value if it was not specified or was in an invalid format.
        Parameters:
        name - The name of the parameter.
        defaultValue - The value to use if none was specified, or an invalid format was used.
        Returns:
        Returns the parameter value as a float.
      • getDouble

        double getDouble​(java.lang.String name,
                         double defaultValue)
        Gets the parameter as a double, or returns the default value if it was not specified or was in an invalid format.
        Parameters:
        name - The name of the parameter.
        defaultValue - The value to use if none was specified, or an invalid format was used.
        Returns:
        Returns the parameter value as a double.
      • getBoolean

        boolean getBoolean​(java.lang.String name)

        Gets a parameter as a boolean, where values such as true, on and yes as considered true, and other values (or no parameter with the name) is considered false.

        This can be used to access checkbox values as booleans.

        Parameters:
        name - The name of the parameter.
        Returns:
        Returns true if the value was truthy, or false if it was falsy or not specified.
      • getAll

        java.util.List<java.lang.String> getAll​(java.lang.String name)
        Gets all the parameters with the given name, or an empty list if none are found.
        Parameters:
        name - The parameter name to get
        Returns:
        All values of the parameter with the given name
      • contains

        boolean contains​(java.lang.String name)
        Returns true if the given parameter is specified with any value
        Parameters:
        name - The name of the value
        Returns:
        True if it's specified; otherwise false.