Back to project page ReadabilitySDK.
The source code is released under:
MIT License
If you think the Android project ReadabilitySDK listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.idemidov.readability.util; /* w w w . j a v a 2 s. c o m*/ import android.content.Context; import com.idemidov.readability.command.Command; import com.idemidov.readability.data.CommandResponse; import com.idemidov.readability.exception.AuthorizationException; import com.idemidov.readability.exception.BadRequestException; import com.idemidov.readability.exception.ForbiddenException; import com.idemidov.readability.exception.InternalErrorException; import com.idemidov.readability.exception.NoConnectionException; import com.idemidov.readability.exception.NotFoundException; import org.json.JSONException; import java.io.IOException; import java.net.URISyntaxException; import oauth.signpost.exception.OAuthCommunicationException; import oauth.signpost.exception.OAuthExpectationFailedException; import oauth.signpost.exception.OAuthMessageSignerException; /** Created by Ilya on 25/02/14. */ public class CommandExecutor { public static CommandResponse execute(Command command, Context context) { CommandResponse result = new CommandResponse(); try { result = command.execute(context); } catch (ForbiddenException e) { result.setCode(ResultCode.CODE_FORBIDDEN_ERROR); e.printStackTrace(); } catch (BadRequestException e) { result.setCode(ResultCode.CODE_BAD_REQUEST_ERROR); e.printStackTrace(); } catch (IOException e) { result.setCode(ResultCode.CODE_IO_ERROR); e.printStackTrace(); } catch (JSONException e) { result.setCode(ResultCode.CODE_JSON_ERROR); e.printStackTrace(); } catch (InternalErrorException e) { result.setCode(ResultCode.CODE_INTERNAL_ERROR); e.printStackTrace(); } catch (NotFoundException e) { result.setCode(ResultCode.CODE_NOT_FOUND_ERROR); e.printStackTrace(); } catch (AuthorizationException e) { result.setCode(ResultCode.CODE_AUTHORIZATION_ERROR); e.printStackTrace(); } catch (NoConnectionException e) { result.setCode(ResultCode.CODE_NO_CONNECTION_ERROR); e.printStackTrace(); } catch (OAuthExpectationFailedException e) { result.setCode(ResultCode.CODE_OAUTH_EXPECTATION_FAILED_ERROR); e.printStackTrace(); } catch (OAuthCommunicationException e) { result.setCode(ResultCode.CODE_OAUTH_COMMUNICATION_ERROR); e.printStackTrace(); } catch (OAuthMessageSignerException e) { result.setCode(ResultCode.CODE_OAUTH_MESSAGE_SIGNER_ERROR); e.printStackTrace(); } catch (URISyntaxException e) { result.setCode(ResultCode.CODE_URI_SYNTAX_ERROR); e.printStackTrace(); } return result; } }