Class DefaultHttpDataFactory

  • All Implemented Interfaces:
    HttpDataFactory

    public class DefaultHttpDataFactory
    extends java.lang.Object
    implements HttpDataFactory
    Default factory giving Attribute and FileUpload according to constructor.

    According to the constructor, Attribute and FileUpload can be:

    • MemoryAttribute, DiskAttribute or MixedAttribute
    • MemoryFileUpload, DiskFileUpload or MixedFileUpload
    A good example of releasing HttpData once all work is done is as follow:
    
       for (InterfaceHttpData httpData: decoder.getBodyHttpDatas()) {
         httpData.release();
         factory.removeHttpDataFromClean(request, httpData);
       }
       factory.cleanAllHttpData();
       decoder.destroy();
      
    • Field Detail

      • MINSIZE

        public static final long MINSIZE
        Proposed default MINSIZE as 16 KB.
        See Also:
        Constant Field Values
      • MAXSIZE

        public static final long MAXSIZE
        Proposed default MAXSIZE = -1 as UNLIMITED
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultHttpDataFactory

        public DefaultHttpDataFactory()
        HttpData will be in memory if less than default size (16KB). The type will be Mixed.
      • DefaultHttpDataFactory

        public DefaultHttpDataFactory​(java.nio.charset.Charset charset)
      • DefaultHttpDataFactory

        public DefaultHttpDataFactory​(boolean useDisk)
        HttpData will be always on Disk if useDisk is True, else always in Memory if False
      • DefaultHttpDataFactory

        public DefaultHttpDataFactory​(boolean useDisk,
                                      java.nio.charset.Charset charset)
      • DefaultHttpDataFactory

        public DefaultHttpDataFactory​(long minSize)
        HttpData will be on Disk if the size of the file is greater than minSize, else it will be in memory. The type will be Mixed.
      • DefaultHttpDataFactory

        public DefaultHttpDataFactory​(long minSize,
                                      java.nio.charset.Charset charset)
    • Method Detail

      • setMaxLimit

        public void setMaxLimit​(long maxSize)
        Description copied from interface: HttpDataFactory
        To set a max size limitation on fields. Exceeding it will generate an ErrorDataDecoderException. A value of -1 means no limitation (default).
        Specified by:
        setMaxLimit in interface HttpDataFactory
      • createAttribute

        public Attribute createAttribute​(HttpRequest request,
                                         java.lang.String name,
                                         long definedSize)
        Specified by:
        createAttribute in interface HttpDataFactory
        Parameters:
        request - associated request
        name - name of the attribute
        definedSize - defined size from request for this attribute
        Returns:
        a new Attribute with no value
      • createAttribute

        public Attribute createAttribute​(HttpRequest request,
                                         java.lang.String name,
                                         java.lang.String value)
        Specified by:
        createAttribute in interface HttpDataFactory
        Parameters:
        request - associated request
        Returns:
        a new Attribute
      • createFileUpload

        public FileUpload createFileUpload​(HttpRequest request,
                                           java.lang.String name,
                                           java.lang.String filename,
                                           java.lang.String contentType,
                                           java.lang.String contentTransferEncoding,
                                           java.nio.charset.Charset charset,
                                           long size)
        Specified by:
        createFileUpload in interface HttpDataFactory
        Parameters:
        request - associated request
        size - the size of the Uploaded file
        Returns:
        a new FileUpload
      • removeHttpDataFromClean

        public void removeHttpDataFromClean​(HttpRequest request,
                                            InterfaceHttpData data)
        Description copied from interface: HttpDataFactory
        Remove the given InterfaceHttpData from clean list (will not delete the file, except if the file is still a temporary one as setup at construction)
        Specified by:
        removeHttpDataFromClean in interface HttpDataFactory
        Parameters:
        request - associated request
      • cleanRequestHttpData

        public void cleanRequestHttpData​(HttpRequest request)
        Description copied from interface: HttpDataFactory
        Remove all InterfaceHttpData from virtual File storage from clean list for the request
        Specified by:
        cleanRequestHttpData in interface HttpDataFactory
        Parameters:
        request - associated request
      • cleanAllHttpData

        public void cleanAllHttpData()
        Description copied from interface: HttpDataFactory
        Remove all InterfaceHttpData from virtual File storage from clean list for all requests
        Specified by:
        cleanAllHttpData in interface HttpDataFactory