Class ConsumerFactory

java.lang.Object
org.simpleframework.http.message.ConsumerFactory
Direct Known Subclasses:
PartFactory

class ConsumerFactory extends Object
The ConsumerFactory object is used to create a factory for creating consumers. This allows the request to determine the type of content sent and allows consumption of the request body in a the manner specified by the HTTP header. This will allow multipart and chunked content to be consumed from the pipeline.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Allocator
    This is used to allocate the memory associated with the body.
    protected Segment
    This is the header associated with the request body consumed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConsumerFactory(Allocator allocator, Segment segment)
    Constructor for the ConsumerFactory object.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected byte[]
    This is used to extract information from the HTTP header that can be used to determine the type of the body.
    protected long
    This is a convenience method that can be used to determine the length of the message body.
    This method is used to create a body consumer to read the body from the pipeline.
    getInstance(long length)
    This method is used to create a body consumer to read the body from the pipeline.
    protected boolean
    isChunked(Segment segment)
    This is used to extract information from the HTTP header that can be used to determine the type of the body.
    protected boolean
    isFixed(Segment segment)
    This is used to extract information from the HTTP header that can be used to determine the type of the body.
    protected boolean
    isUpload(Segment segment)
    This is used to extract information from the HTTP header that can be used to determine the type of the body.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • allocator

      protected Allocator allocator
      This is used to allocate the memory associated with the body.
    • segment

      protected Segment segment
      This is the header associated with the request body consumed.
  • Constructor Details

    • ConsumerFactory

      public ConsumerFactory(Allocator allocator, Segment segment)
      Constructor for the ConsumerFactory object. This will create a factory that makes use of the HTTP header in order to determine the type of the body that is to be consumed.
      Parameters:
      allocator - this is the allocator used to allocate memory
      segment - this is the HTTP header used to determine type
  • Method Details

    • getInstance

      public BodyConsumer getInstance()
      This method is used to create a body consumer to read the body from the pipeline. This will examine the HTTP header associated with the body to determine how to consume the data. This will provide an empty consumer if no specific delimiter was provided.
      Returns:
      this returns the consumer used to consume the body
    • getInstance

      public BodyConsumer getInstance(long length)
      This method is used to create a body consumer to read the body from the pipeline. This will examine the HTTP header associated with the body to determine how to consume the data. This will provide an empty consumer if no specific delimiter was provided.
      Parameters:
      length - this is the length of the body to be consumed
      Returns:
      this returns the consumer used to consume the body
    • getBoundary

      protected byte[] getBoundary(Segment header)
      This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.
      Parameters:
      header - this is the header associated with the body
      Returns:
      the boundary for a multipart upload body
    • isUpload

      protected boolean isUpload(Segment segment)
      This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.
      Parameters:
      segment - this is the header associated with the body
      Returns:
      true if the content type is that of a multipart body
    • isChunked

      protected boolean isChunked(Segment segment)
      This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.
      Parameters:
      segment - this is the header associated with the body
      Returns:
      true if the body is to be consumed as a chunked body
    • isFixed

      protected boolean isFixed(Segment segment)
      This is used to extract information from the HTTP header that can be used to determine the type of the body. This will look at the HTTP headers provided to find a specific token which enables it to determine how to consume the body.
      Parameters:
      segment - this is the header associated with the body
      Returns:
      true if there was a content length in the header
    • getContentLength

      protected long getContentLength()
      This is a convenience method that can be used to determine the length of the message body. This will determine if there is a Content-Length header, if it does then the length can be determined, if not then this returns -1.
      Returns:
      the content length, or -1 if it cannot be determined