org.apache.olingo.odata2.api.processor
Class ODataResponse

java.lang.Object
  extended by org.apache.olingo.odata2.api.processor.ODataResponse

public abstract class ODataResponse
extends Object

An ODataResponse is usually created by an ODataProcessor during request handling.

The handler can use a serializer to create an OData body (== response entity) and can set various response headers. A response can be created using the builder pattern:

 ODataResponse response = ODataResponse.entity("hello world").setStatus(HttpStatusCodes.OK).build();
  


Nested Class Summary
static class ODataResponse.ODataResponseBuilder
          Implementation of the builder pattern to create instances of this type of object.
 
Constructor Summary
protected ODataResponse()
          Do not subclass ODataResponse!
 
Method Summary
abstract  void close()
          Close the underlying entity input stream (if such a stream is available) and release all with this repsonse associated resources.
abstract  boolean containsHeader(String header)
          Case insensitive check if the header is available in this ODataResponse
static ODataResponse.ODataResponseBuilder contentHeader(String value)
           
static ODataResponse.ODataResponseBuilder entity(Object entity)
           
static ODataResponse.ODataResponseBuilder fromResponse(ODataResponse response)
           
abstract  String getContentHeader()
           
abstract  Object getEntity()
           
 InputStream getEntityAsStream()
           
abstract  String getETag()
           
abstract  String getHeader(String name)
           
abstract  Set<String> getHeaderNames()
           
abstract  String getIdLiteral()
           
abstract  HttpStatusCodes getStatus()
           
static ODataResponse.ODataResponseBuilder header(String name, String value)
           
static ODataResponse.ODataResponseBuilder newBuilder()
           
static ODataResponse.ODataResponseBuilder status(HttpStatusCodes status)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ODataResponse

protected ODataResponse()
Do not subclass ODataResponse!

Method Detail

getStatus

public abstract HttpStatusCodes getStatus()
Returns:
HTTP status code of this response

getEntity

public abstract Object getEntity()
Returns:
a response entity which becomes the body part of a response message

getEntityAsStream

public InputStream getEntityAsStream()
                              throws ODataException
Returns:
a response entity as inputStream which becomes the body part of a response message
Throws:
ODataException - throws ODataException in case of entity is not a stream (internal ClassCastException)

close

public abstract void close()
                    throws IOException
Close the underlying entity input stream (if such a stream is available) and release all with this repsonse associated resources.

Throws:
IOException - if something goes wrong during close of ODataResponse

getHeader

public abstract String getHeader(String name)
Parameters:
name - HTTP response header name
Returns:
a header value or null if not set

getContentHeader

public abstract String getContentHeader()
Returns:
Content-Type header value or null if not set

getIdLiteral

public abstract String getIdLiteral()
Returns:
Location header value or null if not set

getETag

public abstract String getETag()
Returns:
ETag header value or null if not available

getHeaderNames

public abstract Set<String> getHeaderNames()
Returns:
a set of all available header names

containsHeader

public abstract boolean containsHeader(String header)
Case insensitive check if the header is available in this ODataResponse

Parameters:
header - header name
Returns:
true/false

status

public static ODataResponse.ODataResponseBuilder status(HttpStatusCodes status)
Parameters:
status - HTTP status code
Returns:
a builder object

fromResponse

public static ODataResponse.ODataResponseBuilder fromResponse(ODataResponse response)
Parameters:
response -
Returns:
a new builder object

entity

public static ODataResponse.ODataResponseBuilder entity(Object entity)
Parameters:
entity -
Returns:
a builder object

header

public static ODataResponse.ODataResponseBuilder header(String name,
                                                        String value)
Parameters:
name - HTTP header name
value - associated value
Returns:
a builder object

contentHeader

public static ODataResponse.ODataResponseBuilder contentHeader(String value)
Parameters:
value - content header value
Returns:
a builder object

newBuilder

public static ODataResponse.ODataResponseBuilder newBuilder()
Returns:
returns a new builder object


Copyright © 2013-2015 The Apache Software Foundation. All Rights Reserved.