org.fusesource.restygwt.client
Class Method

java.lang.Object
  extended by org.fusesource.restygwt.client.Method
Direct Known Subclasses:
JsonpMethod

public class Method
extends Object

Author:
Hiram Chirino

Field Summary
 RequestBuilder builder
           
 
Constructor Summary
protected Method()
           
  Method(Resource resource, String method)
           
 
Method Summary
 void addData(String key, String value)
          add some information onto the method which could be interesting when this method comes back to the dispatcher.
protected  void defaultAcceptType(String type)
           
protected  void defaultContentType(String type)
           
 Method expect(int... statuses)
          sets the expected response status code.
 Map<String,String> getData()
          get all data fields which was previously added
 Dispatcher getDispatcher()
           
 Request getRequest()
           
 Response getResponse()
           
 Method header(String header, String value)
           
 Method headers(Map<String,String> headers)
           
 boolean isExpected(int status)
          Local file-system (file://) does not return any status codes.
 Method json(JSONValue data)
           
 Method password(String password)
           
 void send(JsonCallback callback)
           
<T extends JavaScriptObject>
void
send(OverlayCallback<T> callback)
           
 void send(RequestCallback callback)
           
 void send(TextCallback callback)
           
 void send(XmlCallback callback)
           
 void setDispatcher(Dispatcher dispatcher)
           
 Method text(String data)
           
 Method timeout(int timeout)
           
 Method user(String user)
           
 Method xml(Document data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

builder

public RequestBuilder builder
Constructor Detail

Method

protected Method()

Method

public Method(Resource resource,
              String method)
Method Detail

user

public Method user(String user)

password

public Method password(String password)

header

public Method header(String header,
                     String value)

headers

public Method headers(Map<String,String> headers)

text

public Method text(String data)

json

public Method json(JSONValue data)

xml

public Method xml(Document data)

timeout

public Method timeout(int timeout)

expect

public Method expect(int... statuses)
sets the expected response status code. If the response status code does not match any of the values specified then the request is considered to have failed. Defaults to accepting 200,201,204. If set to -1 then any status code is considered a success.


isExpected

public boolean isExpected(int status)
Local file-system (file://) does not return any status codes. Therefore - if we read from the file-system we accept all codes. This is for instance relevant when developing a PhoneGap application with restyGwt.


send

public void send(RequestCallback callback)
          throws RequestException
Throws:
RequestException

send

public void send(TextCallback callback)

send

public void send(JsonCallback callback)

send

public void send(XmlCallback callback)

send

public <T extends JavaScriptObject> void send(OverlayCallback<T> callback)

getRequest

public Request getRequest()

getResponse

public Response getResponse()

defaultContentType

protected void defaultContentType(String type)

defaultAcceptType

protected void defaultAcceptType(String type)

getDispatcher

public Dispatcher getDispatcher()

setDispatcher

public void setDispatcher(Dispatcher dispatcher)

addData

public void addData(String key,
                    String value)
add some information onto the method which could be interesting when this method comes back to the dispatcher.

Parameters:
key -
value -

getData

public Map<String,String> getData()
get all data fields which was previously added

Returns:


Copyright © 2010-2011 FuseSource, Corp.. All Rights Reserved.