org.jboss.netty.handler.codec.http.multipart

## Class HttpPostRequestDecoder

- java.lang.Object
- - org.jboss.netty.handler.codec.http.multipart.HttpPostRequestDecoder

-     public class HttpPostRequestDecoder
      extends Object

  This decoder will decode Body and can handle POST BODY.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `HttpPostRequestDecoder.EndOfDataDecoderException` Exception when the body is fully decoded, even if there is still data
    `static class` | `HttpPostRequestDecoder.ErrorDataDecoderException` Exception when an error occurs while decoding
    `static class` | `HttpPostRequestDecoder.IncompatibleDataDecoderException` Exception when an unappropriated method was called on a request
    `static class` | `HttpPostRequestDecoder.NotEnoughDataDecoderException` Exception when try reading data from request in chunked format, and not enough data are available (need more chunks)

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)`
    `HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset)`
    `HttpPostRequestDecoder(HttpRequest request)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanFiles()` Clean all HttpDatas (on Disk) for the current request.
    `InterfaceHttpData` | `getBodyHttpData(String name)` This method returns the first InterfaceHttpData with the given name from body.
    `List<InterfaceHttpData>` | `getBodyHttpDatas()` This method returns a List of all HttpDatas from body.
    `List<InterfaceHttpData>` | `getBodyHttpDatas(String name)` This method returns a List of all HttpDatas with the given name from body.
    `boolean` | `hasNext()` True if at current status, there is an available decoded InterfaceHttpData from the Body.
    `boolean` | `isMultipart()` True if this request is a Multipart request
    `InterfaceHttpData` | `next()` Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData.
    `void` | `offer(HttpChunk chunk)` Initialized the internals from a new chunk
    `void` | `removeHttpDataFromClean(InterfaceHttpData data)` Remove the given FileUpload from the list of FileUploads to clean

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

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

- - ### Constructor Detail

    - #### HttpPostRequestDecoder

          public HttpPostRequestDecoder(HttpRequest request)
                                 throws HttpPostRequestDecoder.ErrorDataDecoderException,
                                        HttpPostRequestDecoder.IncompatibleDataDecoderException

      Parameters:
        `request` - the request to decode
      Throws:
        `NullPointerException` - for request
        `HttpPostRequestDecoder.IncompatibleDataDecoderException` - if the request has no body to decode
        `HttpPostRequestDecoder.ErrorDataDecoderException` - if the default charset was wrong when decoding or other errors

    - #### HttpPostRequestDecoder

          public HttpPostRequestDecoder(HttpDataFactory factory,
                                HttpRequest request)
                                 throws HttpPostRequestDecoder.ErrorDataDecoderException,
                                        HttpPostRequestDecoder.IncompatibleDataDecoderException

      Parameters:
        `factory` - the factory used to create InterfaceHttpData
        `request` - the request to decode
      Throws:
        `NullPointerException` - for request or factory
        `HttpPostRequestDecoder.IncompatibleDataDecoderException` - if the request has no body to decode
        `HttpPostRequestDecoder.ErrorDataDecoderException` - if the default charset was wrong when decoding or other errors

    - #### HttpPostRequestDecoder

          public HttpPostRequestDecoder(HttpDataFactory factory,
                                HttpRequest request,
                                Charset charset)
                                 throws HttpPostRequestDecoder.ErrorDataDecoderException,
                                        HttpPostRequestDecoder.IncompatibleDataDecoderException

      Parameters:
        `factory` - the factory used to create InterfaceHttpData
        `request` - the request to decode
        `charset` - the charset to use as default
      Throws:
        `NullPointerException` - for request or charset or factory
        `HttpPostRequestDecoder.IncompatibleDataDecoderException` - if the request has no body to decode
        `HttpPostRequestDecoder.ErrorDataDecoderException` - if the default charset was wrong when decoding or other errors

  - ### Method Detail

    - #### isMultipart

          public boolean isMultipart()

      True if this request is a Multipart request
      Returns:
        True if this request is a Multipart request

    - #### getBodyHttpDatas

          public List<InterfaceHttpData> getBodyHttpDatas()
                                                   throws HttpPostRequestDecoder.NotEnoughDataDecoderException

      This method returns a List of all HttpDatas from body.
      If chunked, all chunks must have been offered using offer() method. If not, NotEnoughDataDecoderException will be raised.
      Returns:
        the list of HttpDatas from Body part for POST method
      Throws:
        `HttpPostRequestDecoder.NotEnoughDataDecoderException` - Need more chunks

    - #### getBodyHttpDatas

          public List<InterfaceHttpData> getBodyHttpDatas(String name)
                                                   throws HttpPostRequestDecoder.NotEnoughDataDecoderException

      This method returns a List of all HttpDatas with the given name from body.
      If chunked, all chunks must have been offered using offer() method. If not, NotEnoughDataDecoderException will be raised.
      Parameters:
        `name` -
      Returns:
        All Body HttpDatas with the given name (ignore case)
      Throws:
        `HttpPostRequestDecoder.NotEnoughDataDecoderException` - need more chunks

    - #### getBodyHttpData

          public InterfaceHttpData getBodyHttpData(String name)
                                            throws HttpPostRequestDecoder.NotEnoughDataDecoderException

      This method returns the first InterfaceHttpData with the given name from body.
      If chunked, all chunks must have been offered using offer() method. If not, NotEnoughDataDecoderException will be raised.
      Parameters:
        `name` -
      Returns:
        The first Body InterfaceHttpData with the given name (ignore case)
      Throws:
        `HttpPostRequestDecoder.NotEnoughDataDecoderException` - need more chunks

    - #### offer

          public void offer(HttpChunk chunk)
                     throws HttpPostRequestDecoder.ErrorDataDecoderException

      Initialized the internals from a new chunk
      Parameters:
        `chunk` - the new received chunk
      Throws:
        `HttpPostRequestDecoder.ErrorDataDecoderException` - if there is a problem with the charset decoding or other errors

    - #### hasNext

          public boolean hasNext()
                          throws HttpPostRequestDecoder.EndOfDataDecoderException

      True if at current status, there is an available decoded InterfaceHttpData from the Body. This method works for chunked and not chunked request.
      Returns:
        True if at current status, there is a decoded InterfaceHttpData
      Throws:
        `HttpPostRequestDecoder.EndOfDataDecoderException` - No more data will be available

    - #### next

          public InterfaceHttpData next()
                                 throws HttpPostRequestDecoder.EndOfDataDecoderException

      Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData. A subsequent call to offer(httpChunk) could enable more data.
      Returns:
        the next available InterfaceHttpData or null if none
      Throws:
        `HttpPostRequestDecoder.EndOfDataDecoderException` - No more data will be available

    - #### cleanFiles

          public void cleanFiles()

      Clean all HttpDatas (on Disk) for the current request.

    - #### removeHttpDataFromClean

          public void removeHttpDataFromClean(InterfaceHttpData data)

      Remove the given FileUpload from the list of FileUploads to clean

Copyright © 2008-2012 The Netty Project. All Rights Reserved.