mobi.voiceassistant.base
Class Request

java.lang.Object
  extended by mobi.voiceassistant.base.Request
All Implemented Interfaces:
Parcelable

public final class Request
extends Object
implements Parcelable


Nested Class Summary
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
 
Field Summary
static Parcelable.Creator<Request> CREATOR
           
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Constructor Summary
Request(Parcel parcel)
           
Request(PendingRequest pendingRequest, Uri uri, Bundle cookies)
           
 
Method Summary
 void addQuickResponse(Object content)
          Creates and adds Response with specified content.
 void addResponse(Response response)
          Sends Response to assistant.
 void addThrowableResponse(Throwable throwable)
           
 Response createResponse()
          Creates new Response bound to this request.
 Context createSessionContext(Context base)
           
 int describeContents()
           
 Uri generateResponseUri()
           
protected  String generateTag()
           
 String getAction()
          Action of PendingRequest used for this Request.
 Bundle getBundleContent()
          Shortcut method to get not-null content bundle.
 int getBundleIntContent(String key)
           
 int getBundleIntContent(String key, int defaultValue)
           
 Parcelable getBundleParcelableContent(String key)
           
 String getBundleStringContent(String key)
           
 ComponentName getComponent()
          Component of PendingRequest used for this Request.
<T> T
getContent()
          Content of PendingRequest used for this Request.
 Bundle getCookies()
           
 ResId getDispatch()
          Dispatch id of PendingRequest used for this Request.
 int getDispatchId()
          Dispatch PendingRequest used for this Request.
 double getDoubleCookie(String key)
           
 int getIntCookie(String key)
           
 int getIntCookie(String key, int defaultValue)
           
 long getLongCookie(String key)
           
 long getLongCookie(String key, long defaultValue)
           
<T> T
getMarshalContent()
           
<T> T
getMarshalContent(ClassLoader loader)
           
<T> T
getMarshalCookie(String key)
           
<T> T
getMarshalCookie(String key, ClassLoader loader)
           
 Uri getOrigin()
          Origin of PendingRequest used for this Request.
<T extends Parcelable>
T
getParcelableCookie(String key)
           
 Session getSession()
           
 ArrayList<String> getStringArrayListCookie(String key)
           
 String getStringCookie(String key)
           
 Token getToken()
          Deprecated. use getContent()
 Uri getUri()
           
 void processInput(PendingInput input)
           
 void processRequest(PendingRequest request)
           
 void putResponse(Uri uri, Response response)
           
 void removeResponse(Response response)
           
 void replaceResponse(Response oldResponse, Response withResponse)
           
 void updateResponse(Response response)
           
protected  void verifyUri(Uri uri)
           
 void writeToParcel(Parcel parcel, int flags)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CREATOR

public static final Parcelable.Creator<Request> CREATOR
Constructor Detail

Request

public Request(PendingRequest pendingRequest,
               Uri uri,
               Bundle cookies)

Request

public Request(Parcel parcel)
Method Detail

writeToParcel

public void writeToParcel(Parcel parcel,
                          int flags)
Specified by:
writeToParcel in interface Parcelable

getSession

public Session getSession()

getAction

public String getAction()
Action of PendingRequest used for this Request.

See Also:
PendingRequest.getAction()

getUri

public Uri getUri()

getOrigin

public Uri getOrigin()
Origin of PendingRequest used for this Request.

See Also:
PendingRequest.getOrigin()

getComponent

public ComponentName getComponent()
Component of PendingRequest used for this Request.

See Also:
PendingRequest.getComponent()

getDispatch

public ResId getDispatch()
Dispatch id of PendingRequest used for this Request.

See Also:
PendingRequest.getDispatch()

getDispatchId

public int getDispatchId()
Dispatch PendingRequest used for this Request.

See Also:
PendingRequest.getDispatch()

getToken

@Deprecated
public Token getToken()
Deprecated. use getContent()


getContent

public <T> T getContent()
Content of PendingRequest used for this Request.

See Also:
PendingRequest.getContent()

getBundleContent

public Bundle getBundleContent()
Shortcut method to get not-null content bundle.

Returns:
getContent() when content is Bundle and Bundle.EMPTY when content is null
Throws:
ClassCastException - when content is not Bundle

getBundleIntContent

public int getBundleIntContent(String key)
See Also:
getBundleContent(), PendingRequest.Builder.putBundleContent(String, int)

getBundleIntContent

public int getBundleIntContent(String key,
                               int defaultValue)
See Also:
getBundleContent(), PendingRequest.Builder.putBundleContent(String, int)

getBundleParcelableContent

public Parcelable getBundleParcelableContent(String key)
See Also:
getBundleContent(), PendingRequest.Builder.putBundleContent(String, Parcelable)

getBundleStringContent

public String getBundleStringContent(String key)
See Also:
getBundleContent(), PendingRequest.Builder.putBundleContent(String, String)

getMarshalContent

public <T> T getMarshalContent()

getMarshalContent

public <T> T getMarshalContent(ClassLoader loader)

getCookies

public Bundle getCookies()

getDoubleCookie

public double getDoubleCookie(String key)
See Also:
Response.putCookie(int, String, double)

getIntCookie

public int getIntCookie(String key)
See Also:
Response.putCookie(int, String, int)

getIntCookie

public int getIntCookie(String key,
                        int defaultValue)
See Also:
Response.putCookie(int, String, int)

getLongCookie

public long getLongCookie(String key)
See Also:
Response.putCookie(int, String, long)

getLongCookie

public long getLongCookie(String key,
                          long defaultValue)
See Also:
Response.putCookie(int, String, long)

getMarshalCookie

public <T> T getMarshalCookie(String key)

getMarshalCookie

public <T> T getMarshalCookie(String key,
                              ClassLoader loader)

getParcelableCookie

public <T extends Parcelable> T getParcelableCookie(String key)
See Also:
Response.putCookie(int, String, Parcelable)

getStringCookie

public String getStringCookie(String key)
See Also:
Response.putCookie(int, String, String)

getStringArrayListCookie

public ArrayList<String> getStringArrayListCookie(String key)
See Also:
Response.putStringArrayListCookie(int, String, ArrayList)

createResponse

public Response createResponse()
Creates new Response bound to this request. Created response not yet sent to assistant. To display response to user need to call Response.setContent(Object) and addResponse(Response).

Returns:
created Response
See Also:
addQuickResponse(Object)

addResponse

public void addResponse(Response response)
Sends Response to assistant.

See Also:
createResponse(), addQuickResponse(Object)

removeResponse

public void removeResponse(Response response)

updateResponse

public void updateResponse(Response response)

replaceResponse

public void replaceResponse(Response oldResponse,
                            Response withResponse)

addQuickResponse

public void addQuickResponse(Object content)
Creates and adds Response with specified content. Shortcut for createResponse(), Response.setContent(Object) and addResponse(Response).

Parameters:
content - Response's content.

addThrowableResponse

public void addThrowableResponse(Throwable throwable)

generateTag

protected String generateTag()

putResponse

public void putResponse(Uri uri,
                        Response response)

verifyUri

protected void verifyUri(Uri uri)

generateResponseUri

public Uri generateResponseUri()

processRequest

public void processRequest(PendingRequest request)

processInput

public void processInput(PendingInput input)

createSessionContext

public Context createSessionContext(Context base)

describeContents

public int describeContents()
Specified by:
describeContents in interface Parcelable