smartrics.rest.client
Class RestData

java.lang.Object
  extended by smartrics.rest.client.RestData
Direct Known Subclasses:
RestRequest, RestResponse

public abstract class RestData
extends Object

Base class for holding shared data between RestRequest and RestResponse.


Nested Class Summary
static class RestData.Header
          Holds an Http Header.
 
Field Summary
static String DEFAULT_ENCODING
           
static String LINE_SEPARATOR
           
 
Constructor Summary
RestData()
           
 
Method Summary
 RestData addHeader(String name, String value)
          Adds an HTTP header to the current list.
 RestData addHeaders(List<RestData.Header> headers)
          Adds a collection of HTTP headers to the current list of headers.
 RestData addHeaders(Map<String,String> headers)
          Adds a collection of HTTP headers to the current list of headers.
 String getBody()
           
 String getCharset()
           
 String getContentLength()
           
 String getContentType()
           
 List<RestData.Header> getHeader(String name)
           
 List<RestData.Header> getHeaders()
           
 String getHeaderValue(String name)
           
 byte[] getRawBody()
           
 String getResource()
           
 Long getTransactionId()
          A transaction Id is a unique long for this transaction.
 RestData setBody(String body)
           
 RestData setRawBody(byte[] rawBody)
           
 RestData setResource(String resource)
           
 RestData setTransactionId(Long txId)
           
 String toString()
          A visually easy to read representation of this RestData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LINE_SEPARATOR

public static final String LINE_SEPARATOR

DEFAULT_ENCODING

public static String DEFAULT_ENCODING
Constructor Detail

RestData

public RestData()
Method Detail

getBody

public String getBody()
Returns:
the body of this http request/response

getRawBody

public byte[] getRawBody()

setBody

public RestData setBody(String body)

setRawBody

public RestData setRawBody(byte[] rawBody)
Parameters:
body - the body
Returns:
this RestData

getResource

public String getResource()
Returns:
the resource type (for example /resource-type) for this request/response

setResource

public RestData setResource(String resource)
Parameters:
resource - the resource type
Returns:
this RestData

setTransactionId

public RestData setTransactionId(Long txId)
Parameters:
txId - the transaction id
Returns:
this RestData

getTransactionId

public Long getTransactionId()
A transaction Id is a unique long for this transaction. It can be used to tie request and response, especially when debugging or parsing logs.

Returns:
the unique value that ties request and response.

getHeaders

public List<RestData.Header> getHeaders()
Returns:
the list of headers for this request/response

getHeader

public List<RestData.Header> getHeader(String name)
Parameters:
name - the header name
Returns:
the sub-list of headers with the same name

addHeader

public RestData addHeader(String name,
                          String value)
Adds an HTTP header to the current list.

Parameters:
name - the header name
value - the header value
Returns:
this RestData

addHeaders

public RestData addHeaders(Map<String,String> headers)
Adds a collection of HTTP headers to the current list of headers.

Parameters:
headers - the collection of headers
Returns:
this RestData

addHeaders

public RestData addHeaders(List<RestData.Header> headers)
Adds a collection of HTTP headers to the current list of headers.

Parameters:
headers - the list of headers
Returns:
this RestData

toString

public String toString()
A visually easy to read representation of this RestData. It tryes to match the typical Http Request/Response

Overrides:
toString in class Object

getContentType

public String getContentType()

getCharset

public String getCharset()

getContentLength

public String getContentLength()

getHeaderValue

public String getHeaderValue(String name)


Copyright © 2012 smartrics. All Rights Reserved.