name.pehl.piriti.restlet.json.client
Class JsonModelsResponse<T>

java.lang.Object
  extended by name.pehl.piriti.restlet.json.client.JsonModelsResponse<T>
Type Parameters:
T - The model type
All Implemented Interfaces:
org.restlet.client.Uniform

public abstract class JsonModelsResponse<T>
extends Object
implements org.restlet.client.Uniform

Convinience callback class which can be used together with PiritiJsonRepresentation:

 ClientResource clientResource = new ClientResource("/resource/with/json/representation");
 clientResource.setOnResponse(new JsonModelsResponse<Book>(Book.JSON)
 {
     @Override
     public void onSuccess(List<Book> books, Request request, Response response)
     {
         ...
     }
     
     @Override
     public void onError(IOException error, Request request, Response response)
     {
         ...
     }
 });
 

Version:
$Date: 2011-03-20 21:02:59 +0100 (So, 20 Mär 2011) $ $Revision: 1478 $
Author:
$Author: harald.pehl $

Constructor Summary
JsonModelsResponse(JsonReader<T> jsonReader)
          Construct a new instance with the specified reader.
 
Method Summary
 void handle(org.restlet.client.Request request, org.restlet.client.Response response)
          Reads and maps the models from the response and calls either onSuccess(List, Request, Response) or onError(IOException, Request, Response).
abstract  void onError(IOException error, org.restlet.client.Request request, org.restlet.client.Response response)
          Called when there was an IO error when reading the models.
abstract  void onSuccess(List<T> models, org.restlet.client.Request request, org.restlet.client.Response response)
          Called when the models were read and mapped successfully from the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonModelsResponse

public JsonModelsResponse(JsonReader<T> jsonReader)
Construct a new instance with the specified reader.

Parameters:
jsonReader -
Method Detail

handle

public void handle(org.restlet.client.Request request,
                   org.restlet.client.Response response)
Reads and maps the models from the response and calls either onSuccess(List, Request, Response) or onError(IOException, Request, Response).

Specified by:
handle in interface org.restlet.client.Uniform
Parameters:
request -
response -
See Also:
Uniform.handle(org.restlet.client.Request, org.restlet.client.Response)

onSuccess

public abstract void onSuccess(List<T> models,
                               org.restlet.client.Request request,
                               org.restlet.client.Response response)
Called when the models were read and mapped successfully from the response.

Parameters:
models -
request -
response -

onError

public abstract void onError(IOException error,
                             org.restlet.client.Request request,
                             org.restlet.client.Response response)
Called when there was an IO error when reading the models.

Parameters:
error -
request -
response -


Copyright © 2012 Harald Pehl. All Rights Reserved.