Class WebParameters

java.lang.Object
java.util.AbstractMap
java.util.HashMap
overit.geocall.servlet.WebParameters
All Implemented Interfaces:
Serializable, Cloneable, Map, Getter

public class WebParameters extends HashMap implements Getter
This class represents the http parameters of a GET or a POST session.
Every WebParameters object implements the Getter interface and adds also indexed methods in order to access the i-th parameter of a session.
See Also:
  • Field Details

    • _requestTraceFile

      protected static String _requestTraceFile
    • _userAgent

      protected overit.geocall.servlet.UserAgent _userAgent
    • _hs

      protected HttpServlet _hs
    • _ref

      protected overit.geocall.servlet.Reference _ref
    • _error

      protected overit.geocall.servlet.WebParametersError _error
    • _userPrincipal

      protected Principal _userPrincipal
    • _agentHeader

      protected String _agentHeader
    • _cookies

      protected PropertyGetter _cookies
    • _remoteAddress

      protected String _remoteAddress
    • _acceptLanguage

      protected String _acceptLanguage
  • Constructor Details

  • Method Details

    • getRequestTraceFile

      public String getRequestTraceFile()
      Returns the file used to trace the interaction
      Returns:
      The path of the file used to trace
    • setRequestTraceFile

      public void setRequestTraceFile(String requestTraceFile)
      Sets the file used to trace the interaction
      Parameters:
      requestTraceFile - The path of the file used to trace
    • getUserAgent

      public overit.geocall.servlet.UserAgent getUserAgent()
      Returns the UserAgent, ie the parser that can recognize the user Agent. It returns a new parser for every WebParameters object, so it is preferable to use the one stored in the Identity
      Returns:
      The UserAgent that can recognize the User Agent
    • getError

      public String getError()
      Returns the WebParametersError.error
      Returns:
      Returns the WebParametersError.error, or null
    • getWebParametersError

      public overit.geocall.servlet.WebParametersError getWebParametersError()
      Returns the WebParametersError object, the one that defines any errors
      Returns:
      Returns the WebParametersError object
    • getStringArray

      public String[] getStringArray(String key)
      Allows to retrieve the entire array of string parameters with a certain name
      Parameters:
      key - Name of the parameter or parameters
      Returns:
      The array of parameters with that name
    • getString

      public String getString(String key, int i, String def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to String
    • stringValue

      public static String stringValue(Object value, int i, String def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to String
    • getString

      public String getString(String key, String def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getString(java.lang.String, int, java.lang.String)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getString in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to String
    • getLong

      public Long getLong(String key, int i, Long def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Long
    • longValue

      public static Long longValue(Object value, int i, Long def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to Long
    • getDouble

      public Double getDouble(String key, int i, Double def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Double
    • doubleValue

      public static Double doubleValue(Object value, int i, Double def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to Double
    • getDouble

      public Double getDouble(String key, Double def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getDouble(java.lang.String, int, java.lang.Double)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getDouble in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Double
    • getdouble

      public double getdouble(String key, int i, double def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to double
    • doublevalue

      public static double doublevalue(Object value, int i, double def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to double
    • getdouble

      public double getdouble(String key, double def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getdouble(java.lang.String, int, double)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getdouble in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to double
    • getBoolean

      public Boolean getBoolean(String key, int i, Boolean def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Boolean
    • booleanValue

      public static Boolean booleanValue(Object value, int i, Boolean def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to Boolean
    • getBoolean

      public Boolean getBoolean(String key, Boolean def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getBoolean(java.lang.String, int, java.lang.Boolean)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getBoolean in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Boolean
    • getboolean

      public boolean getboolean(String key, int i, boolean def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to boolean
    • booleanValue

      public static boolean booleanValue(Object value, int i, boolean def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to boolean
    • getboolean

      public boolean getboolean(String key, boolean def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getdouble(java.lang.String, int, double)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getboolean in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to boolean
    • getInteger

      public Integer getInteger(String key, int i, Integer def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Integer
    • intValue

      public static Integer intValue(Object value, int i, Integer def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to Integer
    • getInteger

      public Integer getInteger(String key, Integer def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getdouble(java.lang.String, int, double)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getInteger in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Integer
    • getint

      public int getint(String key, int i, int def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to int
    • intvalue

      public static int intvalue(Object value, int i, int def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to int
    • getint

      public int getint(String key, int def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getdouble(java.lang.String, int, double)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getint in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to int
    • getDate

      public Date getDate(String key, int i, Date def, SimpleDateFormat sdf)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      sdf - The SimpleDateFormat that defines the format for the conversion
      Returns:
      The required parameter appropriately converted to Date
    • dateValue

      public static Date dateValue(Object value, int i, Date def, SimpleDateFormat sdf)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      sdf - The SimpleDateFormat that defines the format for the conversion
      Returns:
      The parameter appropriately converted to Date
    • getDate

      public Date getDate(String key, Date def, SimpleDateFormat sdf)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getDate(java.lang.String, int, java.util.Date, java.text.SimpleDateFormat)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getDate in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      sdf - The SimpleDateFormat that defines the format for the conversion
      Returns:
      The required parameter appropriately converted to Date
    • length

      public int length(String key)
      Returns the number of parameters with the same name
      Parameters:
      key - Name of the parameter searched
      Returns:
      Number of parameters with the same name
    • length

      public static int length(Object value)
      Returns the number of parameters equals to the one passed to the method
      Parameters:
      value - The parameter searched
      Returns:
      Number of equal parameters
    • getFloat

      public Float getFloat(String key, int i, Float def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Float
    • floatValue

      public static Float floatValue(Object value, int i, Float def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to Float
    • floatValue

      public float floatValue(Object value, int i, float def)
      Converts a parameter in the http parameter list
      Parameters:
      value - The value to convert
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The parameter appropriately converted to float
    • getfloat

      public float getfloat(String key, int i, float def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to float
    • getlong

      public long getlong(String key, int i, long def)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      i - Index of the i-th parameter with the same name
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to long
    • getFloat

      public Float getFloat(String key, Float def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getFloat(java.lang.String, int, java.lang.Float)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getFloat in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Float
    • getLong

      public Long getLong(String key, Long def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getLong(java.lang.String, int, java.lang.Long)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getLong in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to Long
    • getfloat

      public float getfloat(String key, float def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getfloat(java.lang.String, int, float)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getfloat in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to float
    • getlong

      public long getlong(String key, long def)
      Represents a shortcut for the equivalent indexed method assuming the index to 0 (getlong(java.lang.String, int, long)). This method should be used if the parameter you are looking for is not a multiple parameter.
      Implements the Getter interface
      Specified by:
      getlong in interface Getter
      Parameters:
      key - Parameter name in the http parameter list
      def - Default value, returned in case the required parameter does not exist or is not valid
      Returns:
      The required parameter appropriately converted to long
    • keyIterator

      public Iterator keyIterator()
      Extracts an Iterator that allows you to browse through all the elements of the WebParametrs
      Specified by:
      keyIterator in interface Getter
      Returns:
      The iterator over the WebParameters elements
    • get

      public Object get(String key)
      Extracts the object corresponding to the key from the WebParameters. In this case no default is provided.
      Specified by:
      get in interface Getter
      Parameters:
      key - The key to access to the object
      Returns:
      The object associated to the key passed as parameter
    • get

      public Object get(String key, Object def)
      Extracts the object corresponding to the key from the WebParameters. If the object does not exists, it returns the default one.
      Specified by:
      get in interface Getter
      Parameters:
      key - The key to access to the object
      def - The default object
      Returns:
      The object associated to the key passed as parameter, or the default one
    • containsKey

      public boolean containsKey(String key)
      Checks if in the Getter there is an entry with the kay passed as parameter
      Specified by:
      containsKey in interface Getter
      Parameters:
      key - The key to check
      Returns:
      true if there is at least one entry with the specified key, false otherwise specificata, false in caso contrario.
    • getServlet

      public HttpServlet getServlet()
      Deprecated.
      Needed by the Axis engine to know the Servlet and retrieve the list of deploied services
      Returns:
      The HttpServlet
    • getUserPrincipal

      public Principal getUserPrincipal()
      Returns the Principal of the HttpServletRequest, ie the object containing the name of the current authenticated user
      Returns:
      The object that contains the name of the current authenticated user
    • toString

      public String toString()
      Returns the string version of the WebParameters
      Overrides:
      toString in class AbstractMap
      Returns:
      The string that represents the Webparameters
    • toRequestString

      public String toRequestString()
      Returns the string version of the WebParameters formatted as request
      Returns:
      The string that represents the Webparameters
    • getFile

      public UpFile getFile(String key)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      Returns:
      The required parameter appropriately converted to UpFile
    • getFiles

      public UpFile[] getFiles(String key)
      Retrieves a parameter from the list of http parameters and converts it appropriately
      Parameters:
      key - Parameter name in the http parameter list
      Returns:
      The required parameter appropriately converted to UpFile
    • getCookies

      public PropertyGetter getCookies()
      Returns a PropertyGetter containing all of the Cookie objects the client sent with this request.
      Returns:
      The cookie sent by the client
    • getReference

      public overit.geocall.servlet.Reference getReference()
      Returns the Reference created starting from the HttpServletRequest
      Returns:
      The Reference created starting from the HttpServletRequest
    • getRemoteAddress

      public String getRemoteAddress()
      Returns the IP address of the client or last proxy that sent the request
      Returns:
      The IP address of the client or last proxy that sent the request
    • getAcceptLanguage

      public String getAcceptLanguage()
      Returns the value of the http header "Accept-Language"
      Returns:
      The value of the http header "Accept-Language"
    • sanitizeValues

      public void sanitizeValues()
      Sanitize collected values by removing those that should not be kept in memory/session (e.g. UpFiles)