Class MixedAttribute

    • Constructor Detail

      • MixedAttribute

        public MixedAttribute​(String name,
                              long limitSize)
      • MixedAttribute

        public MixedAttribute​(String name,
                              long definedSize,
                              long limitSize)
      • MixedAttribute

        public MixedAttribute​(String name,
                              long limitSize,
                              Charset charset)
      • MixedAttribute

        public MixedAttribute​(String name,
                              long limitSize,
                              Charset charset,
                              String baseDir,
                              boolean deleteOnExit)
      • MixedAttribute

        public MixedAttribute​(String name,
                              long definedSize,
                              long limitSize,
                              Charset charset)
      • MixedAttribute

        public MixedAttribute​(String name,
                              long definedSize,
                              long limitSize,
                              Charset charset,
                              String baseDir,
                              boolean deleteOnExit)
      • MixedAttribute

        public MixedAttribute​(String name,
                              String value,
                              long limitSize)
      • MixedAttribute

        public MixedAttribute​(String name,
                              String value,
                              long limitSize,
                              Charset charset)
      • MixedAttribute

        public MixedAttribute​(String name,
                              String value,
                              long limitSize,
                              Charset charset,
                              String baseDir,
                              boolean deleteOnExit)
    • Method Detail

      • getMaxSize

        public long getMaxSize()
        Description copied from interface: HttpData
        Returns the maxSize for this HttpData.
        Specified by:
        getMaxSize in interface HttpData
      • setMaxSize

        public void setMaxSize​(long maxSize)
        Description copied from interface: HttpData
        Set the maxSize for this HttpData. When limit will be reached, an exception will be raised. Setting it to (-1) means no limitation. By default, to be set from the HttpDataFactory.
        Specified by:
        setMaxSize in interface HttpData
      • checkSize

        public void checkSize​(long newSize)
                       throws IOException
        Description copied from interface: HttpData
        Check if the new size is not reaching the max limit allowed. The limit is always computed in terms of bytes.
        Specified by:
        checkSize in interface HttpData
        Throws:
        IOException
      • delete

        public void delete()
        Description copied from interface: HttpData
        Deletes the underlying storage for a file item, including deleting any associated temporary disk file.
        Specified by:
        delete in interface HttpData
      • get

        public byte[] get()
                   throws IOException
        Description copied from interface: HttpData
        Returns the contents of the file item as an array of bytes.
        Note: this method will allocate a lot of memory, if the data is currently stored on the file system.
        Specified by:
        get in interface HttpData
        Returns:
        the contents of the file item as an array of bytes.
        Throws:
        IOException
      • getByteBuf

        public ByteBuf getByteBuf()
                           throws IOException
        Description copied from interface: HttpData
        Returns the content of the file item as a ByteBuf.
        Note: this method will allocate a lot of memory, if the data is currently stored on the file system.
        Specified by:
        getByteBuf in interface HttpData
        Returns:
        the content of the file item as a ByteBuf
        Throws:
        IOException
      • getCharset

        public Charset getCharset()
        Description copied from interface: HttpData
        Returns the Charset passed by the browser or null if not defined.
        Specified by:
        getCharset in interface HttpData
        Returns:
        the Charset passed by the browser or null if not defined.
      • getString

        public String getString()
                         throws IOException
        Description copied from interface: HttpData
        Returns the contents of the file item as a String, using the default character encoding.
        Specified by:
        getString in interface HttpData
        Returns:
        the contents of the file item as a String, using the default character encoding.
        Throws:
        IOException
      • getString

        public String getString​(Charset encoding)
                         throws IOException
        Description copied from interface: HttpData
        Returns the contents of the file item as a String, using the specified charset.
        Specified by:
        getString in interface HttpData
        Parameters:
        encoding - the charset to use
        Returns:
        the contents of the file item as a String, using the specified charset.
        Throws:
        IOException
      • isCompleted

        public boolean isCompleted()
        Specified by:
        isCompleted in interface HttpData
        Returns:
        True if the InterfaceHttpData is completed (all data are stored)
      • isInMemory

        public boolean isInMemory()
        Description copied from interface: HttpData
        Provides a hint as to whether or not the file contents will be read from memory.
        Specified by:
        isInMemory in interface HttpData
        Returns:
        True if the file contents is in memory.
      • length

        public long length()
        Description copied from interface: HttpData
        Returns the size in byte of the InterfaceHttpData
        Specified by:
        length in interface HttpData
        Returns:
        the size of the InterfaceHttpData
      • definedLength

        public long definedLength()
        Description copied from interface: HttpData
        Returns the defined length of the HttpData. If no Content-Length is provided in the request, the defined length is always 0 (whatever during decoding or in final state). If Content-Length is provided in the request, this is this given defined length. This value does not change, whatever during decoding or in the final state. This method could be used for instance to know the amount of bytes transmitted for one particular HttpData, for example one FileUpload or any known big Attribute.
        Specified by:
        definedLength in interface HttpData
        Returns:
        the defined length of the HttpData
      • renameTo

        public boolean renameTo​(File dest)
                         throws IOException
        Description copied from interface: HttpData
        A convenience getMethod to write an uploaded item to disk. If a previous one exists, it will be deleted. Once this getMethod is called, if successful, the new file will be out of the cleaner of the factory that creates the original InterfaceHttpData object.
        Specified by:
        renameTo in interface HttpData
        Parameters:
        dest - destination file - must be not null
        Returns:
        True if the write is successful
        Throws:
        IOException
      • setCharset

        public void setCharset​(Charset charset)
        Description copied from interface: HttpData
        Set the Charset passed by the browser if defined
        Specified by:
        setCharset in interface HttpData
        Parameters:
        charset - Charset to set - must be not null
      • setContent

        public void setContent​(File file)
                        throws IOException
        Description copied from interface: HttpData
        Set the content from the file (erase any previous data)
        Specified by:
        setContent in interface HttpData
        Parameters:
        file - must be not null
        Throws:
        IOException
      • setContent

        public void setContent​(InputStream inputStream)
                        throws IOException
        Description copied from interface: HttpData
        Set the content from the inputStream (erase any previous data)
        Specified by:
        setContent in interface HttpData
        Parameters:
        inputStream - must be not null
        Throws:
        IOException
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getChunk

        public ByteBuf getChunk​(int length)
                         throws IOException
        Description copied from interface: HttpData
        Returns a ChannelBuffer for the content from the current position with at most length read bytes, increasing the current position of the Bytes read. Once it arrives at the end, it returns an EMPTY_BUFFER and it resets the current position to 0.
        Specified by:
        getChunk in interface HttpData
        Returns:
        a ChannelBuffer for the content from the current position or an EMPTY_BUFFER if there is no more data to return
        Throws:
        IOException
      • getFile

        public File getFile()
                     throws IOException
        Specified by:
        getFile in interface HttpData
        Returns:
        the associated File if this data is represented in a file
        Throws:
        IOException - if this data is not represented by a file
      • refCnt

        public int refCnt()
        Description copied from interface: ReferenceCounted
        Returns the reference count of this object. If 0, it means this object has been deallocated.
        Specified by:
        refCnt in interface ReferenceCounted
      • release

        public boolean release()
        Description copied from interface: ReferenceCounted
        Decreases the reference count by 1 and deallocates this object if the reference count reaches at 0.
        Specified by:
        release in interface ReferenceCounted
        Returns:
        true if and only if the reference count became 0 and this object has been deallocated
      • release

        public boolean release​(int decrement)
        Description copied from interface: ReferenceCounted
        Decreases the reference count by the specified decrement and deallocates this object if the reference count reaches at 0.
        Specified by:
        release in interface ReferenceCounted
        Returns:
        true if and only if the reference count became 0 and this object has been deallocated