org.apache.struts2.dispatcher.multipart

## Class AbstractMultiPartRequest

- java.lang.Object
- - org.apache.struts2.dispatcher.multipart.AbstractMultiPartRequest

- All Implemented Interfaces:
    MultiPartRequest
  Direct Known Subclasses:
    JakartaMultiPartRequest, JakartaStreamMultiPartRequest

      public abstract class AbstractMultiPartRequest
      extends Object
      implements MultiPartRequest

  Abstract class with some helper methods, it should be used when starting development of another implementation of `MultiPartRequest`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BUFFER_SIZE` Defines the internal buffer size used during streaming operations.
    `protected int` | `bufferSize` Specifies the buffer size to use during streaming.
    `protected String` | `defaultEncoding`
    `protected Locale` | `defaultLocale` Localization to be used regarding errors.
    `protected List<LocalizedMessage>` | `errors` Internal list of raised errors to be passed to the the Struts2 framework.
    `protected long` | `maxSize` Specifies the maximum size of the entire request.
    `protected boolean` | `maxSizeProvided`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractMultiPartRequest()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected LocalizedMessage` | `buildErrorMessage(Throwable e, Object[] args)` Build error message.
    `protected String` | `getCanonicalName(String originalFileName)`
    `List<LocalizedMessage>` | `getErrors()` Returns a list of error messages that may have occurred while processing the request.
    `void` | `setBufferSize(String bufferSize)`
    `void` | `setDefaultEncoding(String enc)`
    `protected void` | `setLocale(javax.servlet.http.HttpServletRequest request)`
    `void` | `setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)`
    `void` | `setMaxSize(String maxSize)`

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

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

    - ### Methods inherited from interface org.apache.struts2.dispatcher.multipart.MultiPartRequest

      `cleanUp, getContentType, getFile, getFileNames, getFileParameterNames, getFilesystemName, getParameter, getParameterNames, getParameterValues, parse`

- - ### Field Detail

    - #### BUFFER_SIZE

          public static final int BUFFER_SIZE

      Defines the internal buffer size used during streaming operations.
      See Also:
        Constant Field Values

    - #### errors

          protected List<LocalizedMessage> errors

      Internal list of raised errors to be passed to the the Struts2 framework.

    - #### maxSize

          protected long maxSize

      Specifies the maximum size of the entire request.

    - #### maxSizeProvided

          protected boolean maxSizeProvided

    - #### bufferSize

          protected int bufferSize

      Specifies the buffer size to use during streaming.

    - #### defaultEncoding

          protected String defaultEncoding

    - #### defaultLocale

          protected Locale defaultLocale

      Localization to be used regarding errors.

  - ### Constructor Detail

    - #### AbstractMultiPartRequest

          public AbstractMultiPartRequest()

  - ### Method Detail

    - #### setBufferSize

          public void setBufferSize(String bufferSize)

      Parameters:
        `bufferSize` - Sets the buffer size to be used.

    - #### setDefaultEncoding

          public void setDefaultEncoding(String enc)

    - #### setMaxSize

          public void setMaxSize(String maxSize)

      Parameters:
        `maxSize` - Injects the Struts multiple part maximum size.

    - #### setLocaleProviderFactory

          public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)

    - #### setLocale

          protected void setLocale(javax.servlet.http.HttpServletRequest request)

      Parameters:
        `request` - Inspect the servlet request and set the locale if one wasn't provided by the Struts2 framework.

    - #### buildErrorMessage

          protected LocalizedMessage buildErrorMessage(Throwable e,
                                           Object[] args)

      Build error message.
      Parameters:
        `e` - the Throwable/Exception
        `args` - arguments
      Returns:
        error message

    - #### getErrors

          public List<LocalizedMessage> getErrors()

      Description copied from interface: `MultiPartRequest`
      Returns a list of error messages that may have occurred while processing the request. If there are no errors, an empty list is returned. If the underlying implementation (ie: pell, cos, jakarta, etc) cannot support providing these errors, an empty list is also returned. This list of errors is reported back to the `MultiPartRequestWrapper`'s errors field.
      Specified by:
        `getErrors` in interface `MultiPartRequest`
      Returns:
        a list of Strings that represent various errors during parsing

    - #### getCanonicalName

          protected String getCanonicalName(String originalFileName)

      Parameters:
        `originalFileName` - file name
      Returns:
        the canonical name based on the supplied filename

Copyright © 2000–2020 Apache Software Foundation. All rights reserved.