com.jakewharton.domainr
Class DomainrApiService

java.lang.Object
  extended by com.jakewharton.apibuilder.ApiService
      extended by com.jakewharton.domainr.DomainrApiService
Direct Known Subclasses:
InfoService, SearchService

public abstract class DomainrApiService
extends com.jakewharton.apibuilder.ApiService

Domainr-specific API service extension which facilitates provides helper methods for performing remote method calls as well as deserializing the corresponding JSON responses.

Author:
Jake Wharton

Field Summary
 
Fields inherited from class com.jakewharton.apibuilder.ApiService
CONTENT_ENCODING
 
Constructor Summary
DomainrApiService()
          Create a new Domainr service with our proper default values.
 
Method Summary
 com.google.gson.JsonObject get(String url)
          Execute request using HTTP GET.
protected  com.google.gson.JsonObject unmarshall(InputStream jsonContent)
          Read the entirety of an input stream and parse to a JSON object.
protected
<T> T
unmarshall(com.google.gson.reflect.TypeToken<T> typeToken, com.google.gson.JsonElement response)
          Use GSON to deserialize a JSON object to a native class representation.
 
Methods inherited from class com.jakewharton.apibuilder.ApiService
acceptGzip, addRequestHeader, closeConnection, closeStream, convertStreamToString, executeDelete, executeDelete, executeGet, executeGet, executeMethod, executePost, executePost, getConnectTimeout, getParametersString, getReadTimeout, getWrappedInputStream, removeRequestHeader, setConnectTimeout, setReadTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DomainrApiService

public DomainrApiService()
Create a new Domainr service with our proper default values.

Method Detail

get

public com.google.gson.JsonObject get(String url)
Execute request using HTTP GET.

Parameters:
url - URL to request.
Returns:
JSON object.

unmarshall

protected <T> T unmarshall(com.google.gson.reflect.TypeToken<T> typeToken,
                           com.google.gson.JsonElement response)
Use GSON to deserialize a JSON object to a native class representation.

Type Parameters:
T - Native class type.
Parameters:
typeToken - Native class type wrapper.
response - Serialized JSON object.
Returns:
Deserialized native instance.

unmarshall

protected com.google.gson.JsonObject unmarshall(InputStream jsonContent)
Read the entirety of an input stream and parse to a JSON object.

Parameters:
jsonContent - JSON content input stream.
Returns:
Parsed JSON object.


Copyright © 2011 Jake Wharton. All Rights Reserved.