org.appng.forms.impl

## Class RequestBean

- java.lang.Object
- - org.appng.forms.impl.RequestBean

- All Implemented Interfaces:
    Request, RequestContainer

      public class RequestBean
      extends Object
      implements Request

  The default `Request`-implementation.
  Author:
    Matthias Müller

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,List<FormUpload>>` | `formUploads`
    `protected String` | `host`
    `protected Map<String,List<String>>` | `parameters`

    - ### Fields inherited from interface org.appng.forms.Request

      `REQUEST_PARSED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestBean()`
    `RequestBean(long maxSize)`
    `RequestBean(long maxSize, File tempDir)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addParameter(String key, String value)` Adds the given parameter to this `Request`, but only if such a parameter not already exists.
    `void` | `addParameters(Map<String,String> singleParameters)` Adds the given parameters to this `Request`, but only for those parameters not already existsing.
    `void` | `addParameters(String key, List<String> values)` Adds the given parameters to this `Request`, but only if such a parameter not already exists.
    `List<String>` | `getAcceptedTypes(String uploadName)` Returns the accepted file-extensions/content-types for the input field with the given name.
    `String` | `getEncoding()` Return the encoding for this request
    `Map<String,List<FormUpload>>` | `getFormUploads()` Returns all `FormUpload`s for the request as immutable map.
    `List<FormUpload>` | `getFormUploads(String name)` Returns an immutable `List` of all `FormUpload`s for the parameter with the given name.
    `String` | `getHost()` Returns the host name for this request
    `javax.servlet.http.HttpServletRequest` | `getHttpServletRequest()` Returns the previously processed `HttpServletRequest`
    `String` | `getParameter(String name)` Returns the value for the parameter with the given name. Note that for a multi-valued parameter, any of the submitted values is returned.
    `List<String>` | `getParameterList(String name)` Returns a `List` containing all the values for the parameter with the given name.
    `Set<String>` | `getParameterNames()` Returns an immutable `Set` containing the names of all request parameters.
    `Map<String,String>` | `getParameters()` Returns an immutable `Map` containing the name of each request-parameter as a key and a single parameter value as the map's value. Note that for multi-valued parameters, the returned map contains any of the submitted values.
    `Map<String,List<String>>` | `getParametersList()` Returns an immutable `Map` containing the name of each request-parameter as a key and the list of submitted values as value.
    `XSSUtil` | `getXssUtil()`
    `boolean` | `hasParameter(String name)` Checks whether a parameter with the given name exists.
    `boolean` | `isGet()` Returns `true` if this is a HTPP GET request.
    `boolean` | `isMultiPart()` Returns `true` if this is a multipart request.
    `boolean` | `isPost()` Returns `true` if this is a HTPP POST request.
    `boolean` | `isValid()` Checks whether this is a valid `Request`, i.e.
    `void` | `process(javax.servlet.http.HttpServletRequest servletRequest)` Processes the given `HttpServletRequest`.
    `void` | `setAcceptedTypes(String uploadName, String... types)` Sets the accepted mime-types or filetype-extensions for the given field
    `void` | `setEncoding(String encoding)` Sets the encoding for this request
    `void` | `setHost(String host)`
    `void` | `setMaxSize(long maxSize)` Sets the maximum size for a `FormUpload` within this `Request`.
    `void` | `setMaxSize(long maxSize, boolean isStrict)` Sets the maximum size for a `FormUpload` within this `Request`, and additionally defines if violations should be handled strict.
    `void` | `setTempDir(File tempDir)` Sets the (absolute) temporary directory for storing `FormUpload`s.
    `void` | `setXssUtil(XSSUtil xssUtil)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### formUploads

          protected Map<String,List<FormUpload>> formUploads

    - #### parameters

          protected Map<String,List<String>> parameters

    - #### host

          protected String host

  - ### Constructor Detail

    - #### RequestBean

          public RequestBean()

    - #### RequestBean

          public RequestBean(long maxSize)

    - #### RequestBean

          public RequestBean(long maxSize,
                             File tempDir)

  - ### Method Detail

    - #### getFormUploads

          public List<FormUpload> getFormUploads(String name)

      Description copied from interface: `RequestContainer`
      Returns an immutable `List` of all `FormUpload`s for the parameter with the given name.
      Specified by:
        `getFormUploads` in interface `RequestContainer`
      Parameters:
        `name` - the name of the parameters
      Returns:
        a list if `FormUpload`s (never `null`, but may be empty)

    - #### process

          public void process(javax.servlet.http.HttpServletRequest servletRequest)

      Description copied from interface: `Request`
      Processes the given `HttpServletRequest`. Must only be called once per `HttpServletRequest`.
      Specified by:
        `process` in interface `Request`
      Parameters:
        `servletRequest` - the `HttpServletRequest` to process

    - #### getEncoding

          public String getEncoding()

      Description copied from interface: `Request`
      Return the encoding for this request
      Specified by:
        `getEncoding` in interface `Request`
      Returns:
        the encoding

    - #### setEncoding

          public void setEncoding(String encoding)

      Description copied from interface: `Request`
      Sets the encoding for this request
      Specified by:
        `setEncoding` in interface `Request`
      Parameters:
        `encoding` - the encoding

    - #### isMultiPart

          public boolean isMultiPart()

      Description copied from interface: `Request`
      Returns `true` if this is a multipart request.
      Specified by:
        `isMultiPart` in interface `Request`
      Returns:
        `true` if this is a multipart request, `false` otherwise

    - #### isPost

          public boolean isPost()

      Description copied from interface: `Request`
      Returns `true` if this is a HTPP POST request.
      Specified by:
        `isPost` in interface `Request`
      Returns:
        `true` if this is a HTPP POST request, `false` otherwise

    - #### isGet

          public boolean isGet()

      Description copied from interface: `Request`
      Returns `true` if this is a HTPP GET request.
      Specified by:
        `isGet` in interface `Request`
      Returns:
        `true` if this is a HTPP GET request, `false` otherwise

    - #### setTempDir

          public void setTempDir(File tempDir)

      Description copied from interface: `Request`
      Sets the (absolute) temporary directory for storing `FormUpload`s. Note that, if not set or not existent, the directory specified by the `System` propertey `java.io.tmpdir` is used.
      Specified by:
        `setTempDir` in interface `Request`
      Parameters:
        `tempDir` - the directory for storing `FormUpload`s

    - #### setMaxSize

          public void setMaxSize(long maxSize)

      Description copied from interface: `Request`
      Sets the maximum size for a `FormUpload` within this `Request`.
      Specified by:
        `setMaxSize` in interface `Request`
      Parameters:
        `maxSize` - the maximum size of a `FormUpload`
      See Also:
        `FormUpload.getMaxSize()`

    - #### setMaxSize

          public void setMaxSize(long maxSize,
                                 boolean isStrict)

      Description copied from interface: `Request`
      Sets the maximum size for a `FormUpload` within this `Request`, and additionally defines if violations should be handled strict.
      Specified by:
        `setMaxSize` in interface `Request`
      Parameters:
        `maxSize` - the maximum size of a `FormUpload`
        `isStrict` - if set to `true`, and a `FormUpload` exceeds the given size, the whole `Request` will be marked as invalid.
      See Also:
        `Request.isValid()`

    - #### setAcceptedTypes

          public void setAcceptedTypes(String uploadName,
                                       String... types)

      Description copied from interface: `Request`
      Sets the accepted mime-types or filetype-extensions for the given field
      Specified by:
        `setAcceptedTypes` in interface `Request`
      Parameters:
        `uploadName` - the name of the input-field (type="file")
        `types` - the accepted mimetypes (e.g. image/jpeg, image/png) or file extensions (e.g jgp,png), those can be used in combination

    - #### getAcceptedTypes

          public List<String> getAcceptedTypes(String uploadName)

      Description copied from interface: `Request`
      Returns the accepted file-extensions/content-types for the input field with the given name.
      Specified by:
        `getAcceptedTypes` in interface `Request`
      Parameters:
        `uploadName` - the name of the input field
      Returns:
        a list of accepted tyes
      See Also:
        `FormUpload.getAcceptedTypes()`

    - #### isValid

          public boolean isValid()

      Description copied from interface: `Request`
      Checks whether this is a valid `Request`, i.e. no `Exception` occurred during `Request.process(HttpServletRequest)`.
      Specified by:
        `isValid` in interface `Request`
      Returns:
        `true` if this `Request` is valid, `false` otherwise

    - #### getHttpServletRequest

          public javax.servlet.http.HttpServletRequest getHttpServletRequest()

      Description copied from interface: `Request`
      Returns the previously processed `HttpServletRequest`
      Specified by:
        `getHttpServletRequest` in interface `Request`
      Returns:
        the `HttpServletRequest`

    - #### addParameter

          public void addParameter(String key,
                                   String value)

      Description copied from interface: `Request`
      Adds the given parameter to this `Request`, but only if such a parameter not already exists. This prevents overwriting a parameter which is already present in the original `HttpServletRequest`.
      Specified by:
        `addParameter` in interface `Request`
      Parameters:
        `key` - the parameter name
        `value` - the parameter value

    - #### addParameters

          public void addParameters(String key,
                                    List<String> values)

      Description copied from interface: `Request`
      Adds the given parameters to this `Request`, but only if such a parameter not already exists. This prevents overwriting a parameter which is already present in the original `HttpServletRequest`.
      Specified by:
        `addParameters` in interface `Request`
      Parameters:
        `key` - the parameter name
        `values` - the parameter values

    - #### addParameters

          public void addParameters(Map<String,String> singleParameters)

      Description copied from interface: `Request`
      Adds the given parameters to this `Request`, but only for those parameters not already existsing. This prevents overwriting a parameter which is already present in the original `HttpServletRequest`. The given `Map` uses the parameter name as the key and the parameter value as the value.
      Specified by:
        `addParameters` in interface `Request`
      Parameters:
        `singleParameters` - the parameters to add
      See Also:
        `Request.addParameter(String, String)`, `RequestContainer.getParameter(String)`

    - #### getFormUploads

          public Map<String,List<FormUpload>> getFormUploads()

      Description copied from interface: `RequestContainer`
      Returns all `FormUpload`s for the request as immutable map. Returns a `Map` using the parameters name as a key and a `List` of `FormUpload`s as the value.
      Specified by:
        `getFormUploads` in interface `RequestContainer`
      Returns:
        a `Map` containing the `FileUpload`s

    - #### getHost

          public String getHost()

      Description copied from interface: `RequestContainer`
      Returns the host name for this request
      Specified by:
        `getHost` in interface `RequestContainer`
      Returns:
        the host name

    - #### getParameter

          public String getParameter(String name)

      Description copied from interface: `RequestContainer`
      Returns the value for the parameter with the given name.
      Note that for a multi-valued parameter, any of the submitted values is returned. Use `RequestContainer.getParameterList(String)` instead if you want to deal with a multi-valued parameter.
      Specified by:
        `getParameter` in interface `RequestContainer`
      Parameters:
        `name` - the name of the parameter
      Returns:
        the value of the parameter (may be null)

    - #### getParameterList

          public List<String> getParameterList(String name)

      Description copied from interface: `RequestContainer`
      Returns a `List` containing all the values for the parameter with the given name.
      Specified by:
        `getParameterList` in interface `RequestContainer`
      Parameters:
        `name` - the name of the parameter
      Returns:
        a `List` (never `null`, but may be empty) containing all the values for the given parameter

    - #### getParameterNames

          public Set<String> getParameterNames()

      Description copied from interface: `RequestContainer`
      Returns an immutable `Set` containing the names of all request parameters.
      Specified by:
        `getParameterNames` in interface `RequestContainer`
      Returns:
        the parameters names

    - #### getParameters

          public Map<String,String> getParameters()

      Description copied from interface: `RequestContainer`
      Returns an immutable `Map` containing the name of each request-parameter as a key and a single parameter value as the map's value.
      Note that for multi-valued parameters, the returned map contains any of the submitted values. Use `RequestContainer.getParametersList()` instead if you want to deal with multi-valued parameters.
      Specified by:
        `getParameters` in interface `RequestContainer`
      Returns:
        a `Map` containing the request parameters

    - #### getParametersList

          public Map<String,List<String>> getParametersList()

      Description copied from interface: `RequestContainer`
      Returns an immutable `Map` containing the name of each request-parameter as a key and the list of submitted values as value.
      Specified by:
        `getParametersList` in interface `RequestContainer`
      Returns:
        a `Map` containing the request parameters (including multi-valued ones)

    - #### hasParameter

          public boolean hasParameter(String name)

      Description copied from interface: `RequestContainer`
      Checks whether a parameter with the given name exists.
      Specified by:
        `hasParameter` in interface `RequestContainer`
      Parameters:
        `name` - the name of the parameter
      Returns:
        `true` if such a parameter exists, `false` otherwise

    - #### setHost

          public void setHost(String host)

    - #### getXssUtil

          public XSSUtil getXssUtil()

    - #### setXssUtil

          public void setXssUtil(XSSUtil xssUtil)

Copyright © 2011–2023 aiticon GmbH. All rights reserved.