org.licas.server.model

## Class HttpEntity

- java.lang.Object
- - org.licas.server.model.HttpEntity

-     public class HttpEntity
      extends java.lang.Object

  Container class for an http communication object.
  Author:
    Kieran Greer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>>` | `headers` Lists of headers, key is the type, value is a list of related values
    `protected java.lang.String` | `method` The protocol method to call
    `protected int` | `statusCode` The status code
    `protected java.lang.String` | `type` The entity type, with regard to the communication protocol, for example `Const`.`XMLRPC`, or `REST`.
    `protected java.lang.Object` | `value` Message content, can be multiple types

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpEntity(java.lang.String theType, java.lang.String theMethod)` Create a new instance of HttpEntity.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addHeader(java.lang.String key, java.lang.String value)` Add a header as a key-value pair.
    `static HttpEntity` | `createEntity(java.lang.String type, java.lang.String method, java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> headers, java.lang.Object value)` Create an HttpEntity of the correct type as defined by the value type.
    `java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>>` | `getHeaders()` Get a list of all headers.
    `java.lang.String` | `getMethod()` Get the protocol method name, Get or Post, for example.
    `int` | `getStatusCode()` Get the http status code.
    `java.lang.String` | `getType()` Get the communication type, for example `Const`.{XMLRPC}.
    `java.lang.Object` | `getValue()` Get the content value of the entity.
    `boolean` | `removeHeaders(java.lang.String key)` Remove all headers of the indicated type.
    `void` | `setStatusCode(int theStatusCode)` Set the http status code.
    `void` | `setValue(java.lang.Object theValue)` Set the content value of the entity.

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

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

- - ### Field Detail

    - #### type

          protected java.lang.String type

      The entity type, with regard to the communication protocol, for example `Const`.`XMLRPC`, or `REST`.

    - #### method

          protected java.lang.String method

      The protocol method to call

    - #### headers

          protected java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> headers

      Lists of headers, key is the type, value is a list of related values

    - #### value

          protected java.lang.Object value

      Message content, can be multiple types

    - #### statusCode

          protected int statusCode

      The status code

  - ### Constructor Detail

    - #### HttpEntity

          public HttpEntity(java.lang.String theType,
                            java.lang.String theMethod)

      Create a new instance of HttpEntity.
      Parameters:
        `theType` - the entity protocol type, not null.
        `theMethod` - the protocol method, not null.

  - ### Method Detail

    - #### getType

          public java.lang.String getType()

      Get the communication type, for example `Const`.{XMLRPC}.
      Returns:
        the value of type.

    - #### getMethod

          public java.lang.String getMethod()

      Get the protocol method name, Get or Post, for example.
      Returns:
        the value of method.

    - #### addHeader

          public void addHeader(java.lang.String key,
                                java.lang.String value)

      Add a header as a key-value pair.
      Parameters:
        `key` - the header name.
        `value` - the header value.

    - #### removeHeaders

          public boolean removeHeaders(java.lang.String key)

      Remove all headers of the indicated type.
      Parameters:
        `key` - the header name or type.
      Returns:
        true if headers of that type were removed.

    - #### getHeaders

          public java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> getHeaders()

      Get a list of all headers.
      Returns:
        the value of headers.

    - #### setValue

          public void setValue(java.lang.Object theValue)

      Set the content value of the entity.
      Parameters:
        `theValue` - the value.

    - #### getValue

          public java.lang.Object getValue()

      Get the content value of the entity.
      Returns:
        the value of value.

    - #### setStatusCode

          public void setStatusCode(int theStatusCode)

      Set the http status code.
      Parameters:
        `theStatusCode` - the status code.

    - #### getStatusCode

          public int getStatusCode()

      Get the http status code.
      Returns:
        the value of statusCode.

    - #### createEntity

          public static HttpEntity createEntity(java.lang.String type,
                                                java.lang.String method,
                                                java.util.HashMap<java.lang.String,java.util.ArrayList<java.lang.String>> headers,
                                                java.lang.Object value)

      Create an HttpEntity of the correct type as defined by the value type. This defaults to HttpEntityObject if the type is not recognised.
      Parameters:
        `type` - the communication type.
        `method` - the http method.
        `headers` - optional headers.
        `value` - the content value.
      Returns:
        the appropriate HttpEntity type.