Java Code Examples for com.codename1.io.ConnectionRequest#getResponseErrorMessage()

The following examples show how to use com.codename1.io.ConnectionRequest#getResponseErrorMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestBuilder.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Executes the request synchronously
 * 
 * @return Response Object
 */ 
public Response<String> getAsString() {
    ConnectionRequest request = createRequest(false);
    fetched = true;
    CN.addToQueueAndWait(request);
    Response res = null;
    try {
        byte[] respData = request.getResponseData();
        String resp = null;
        if(respData != null) {
            resp = new String(respData, "UTF-8");
        }
        res = new Response(request.getResponseCode(), resp, 
            request.getResponseErrorMessage());
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    }
    return res;
}
 
Example 2
Source File: RequestBuilder.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Executes the request synchronously
 * 
 * @param type the type of the business object to create
 * @return Response Object
 */ 
public Response<List<PropertyBusinessObject>> getAsPropertyList(Class type) {
    ConnectionRequest request = createRequest(true);
    fetched = true;
    CN.addToQueueAndWait(request);
    Map response = ((Connection)request).json;
    try {
        List<Map> lst = (List<Map>)response.get("root");
        List<PropertyBusinessObject> result = new ArrayList<PropertyBusinessObject>();
        for(Map m : lst) {
            PropertyBusinessObject pb = (PropertyBusinessObject)type.newInstance();
            pb.getPropertyIndex().populateFromMap(m);
            result.add(pb);
        }
        return new Response(request.getResponseCode(), result, request.getResponseErrorMessage());
    } catch(Exception err) {
        Log.e(err);
        throw new RuntimeException(err.toString());
    }
}
 
Example 3
Source File: RequestBuilder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes the request synchronously
 * 
 * @return Response Object
 */ 
public Response<byte[]> getAsBytes() {
    ConnectionRequest request = createRequest(false);
    fetched = true;
    CN.addToQueueAndWait(request);
    Response res = new Response(request.getResponseCode(), request.getResponseData(), request.getResponseErrorMessage());
    return res;
}
 
Example 4
Source File: RequestBuilder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes the request synchronously
 * 
 * @return Response Object
 */ 
public Response<Map> getAsJsonMap() {
    ConnectionRequest request = createRequest(true);
    fetched = true;
    CN.addToQueueAndWait(request);
    Map response = ((Connection)request).json;
    return new Response(request.getResponseCode(), response, request.getResponseErrorMessage());
}
 
Example 5
Source File: RequestBuilder.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Executes the request synchronously
 * 
 * @param type the type of the business object to create
 * @return Response Object
 */ 
public Response<PropertyBusinessObject> getAsProperties(Class type) {
    ConnectionRequest request = createRequest(true);
    fetched = true;
    CN.addToQueueAndWait(request);
    Map response = ((Connection)request).json;
    try {
        PropertyBusinessObject pb = (PropertyBusinessObject)type.newInstance();
        pb.getPropertyIndex().populateFromMap(response);
        return new Response(request.getResponseCode(), pb, request.getResponseErrorMessage());
    } catch(Exception err) {
        Log.e(err);
        throw new RuntimeException(err.toString());
    }
}