AeroGear Android Libary 1.0.0.M1

org.jboss.aerogear.android.impl.pipeline
Class RestAdapter<T>

java.lang.Object
  extended by org.jboss.aerogear.android.impl.pipeline.RestAdapter<T>
All Implemented Interfaces:
Pipe<T>

public final class RestAdapter<T>
extends Object
implements Pipe<T>

Rest implementation of Pipe.


Constructor Summary
RestAdapter(Class<T> klass, URL baseURL)
           
RestAdapter(Class<T> klass, URL baseURL, com.google.gson.GsonBuilder gsonBuilder)
           
 
Method Summary
 PipeType getType()
          Returns the connection type of this Pipe object (e.g.
 URL getUrl()
          Returns the URL to which this Pipe object points.
 void read(Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void readWithFilter(ReadFilter filter, Callback<List<T>> callback)
          Reads all the data from the underlying server connection.
 void remove(String id, Callback<Void> callback)
          Removes an object from the underlying server connection.
 void save(T data, Callback<T> callback)
          Saves or updates a given object on the server.
 void setAuthenticationModule(AuthenticationModule module)
          Sets the authentication module for the Pipe.
 void setEncoding(Charset encoding)
          Sets the encoding of the Pipe.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestAdapter

public RestAdapter(Class<T> klass,
                   URL baseURL)

RestAdapter

public RestAdapter(Class<T> klass,
                   URL baseURL,
                   com.google.gson.GsonBuilder gsonBuilder)
Method Detail

getType

public PipeType getType()
Returns the connection type of this Pipe object (e.g. REST).

Specified by:
getType in interface Pipe<T>
Returns:
the connection type

getUrl

public URL getUrl()
Returns the URL to which this Pipe object points.

Specified by:
getUrl in interface Pipe<T>
Returns:
the endpoint URL

readWithFilter

public void readWithFilter(ReadFilter filter,
                           Callback<List<T>> callback)
Description copied from interface: Pipe
Reads all the data from the underlying server connection.

Specified by:
readWithFilter in interface Pipe<T>
Parameters:
filter - a ReadFilter for performing pagination and querying.
callback - The callback for consuming the result from the Pipe invocation.

read

public void read(Callback<List<T>> callback)
Reads all the data from the underlying server connection.

Specified by:
read in interface Pipe<T>
Parameters:
callback - The callback for consuming the result from the Pipe invocation.

save

public void save(T data,
                 Callback<T> callback)
Description copied from interface: Pipe
Saves or updates a given object on the server.

Specified by:
save in interface Pipe<T>
Parameters:
data - the item to save or update
callback - The callback for consuming the result from the Pipe invocation.

remove

public void remove(String id,
                   Callback<Void> callback)
Removes an object from the underlying server connection. The given key argument is used as the objects ID.

Specified by:
remove in interface Pipe<T>
Parameters:
id - representing the ‘id’ of the object to be removed
callback - The callback for consuming the result from the Pipe invocation.

setAuthenticationModule

public void setAuthenticationModule(AuthenticationModule module)
Description copied from interface: Pipe
Sets the authentication module for the Pipe. It should already be logged in.

Specified by:
setAuthenticationModule in interface Pipe<T>

setEncoding

public void setEncoding(Charset encoding)
Sets the encoding of the Pipe. May not be null.

Parameters:
encoding -
Throws:
IllegalArgumentException - if encoding is null

AeroGear Android Libary 1.0.0.M1

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.