name.pehl.piriti.restlet.xml.client
Class XmlModelResponse<T>

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

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

Convinience callback class which can be used together with PiritiXmlRepresentation:

 ClientResource clientResource = new ClientResource("/resource/with/xml/representation");
 clientResource.setOnResponse(new XmlModelResponse<Book>(Book.JSON)
 {
     @Override
     public void onSuccess(Book book, 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
XmlModelResponse(XmlReader<T> xmlReader)
          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 model from the response and calls either onSuccess(Object, 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 model.
abstract  void onSuccess(T model, org.restlet.client.Request request, org.restlet.client.Response response)
          Called when the model was 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

XmlModelResponse

public XmlModelResponse(XmlReader<T> xmlReader)
Construct a new instance with the specified reader.

Parameters:
xmlReader -
Method Detail

handle

public void handle(org.restlet.client.Request request,
                   org.restlet.client.Response response)
Reads and maps the model from the response and calls either onSuccess(Object, 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(T model,
                               org.restlet.client.Request request,
                               org.restlet.client.Response response)
Called when the model was read and mapped successfully from the response.

Parameters:
model -
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 model.

Parameters:
error -
request -
response -


Copyright © 2012 Harald Pehl. All Rights Reserved.