public abstract class MicrosoftTranslatorAPI extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String |
apiKey |
protected static String |
ENCODING |
protected static String |
PARAM_APP_ID |
protected static String |
PARAM_FROM_LANG |
protected static String |
PARAM_LANGUAGE_CODES |
protected static String |
PARAM_LOCALE |
protected static String |
PARAM_SENTENCES_LANGUAGE |
protected static String |
PARAM_SPOKEN_LANGUAGE |
protected static String |
PARAM_TEXT_ARRAY |
protected static String |
PARAM_TEXT_SINGLE |
protected static String |
PARAM_TO_LANG |
| Constructor and Description |
|---|
MicrosoftTranslatorAPI() |
| Modifier and Type | Method and Description |
|---|---|
protected static String |
buildStringArrayParam(Object[] values) |
static String |
getToken(String clientId,
String clientSecret)
Gets the OAuth access token.
|
protected static Integer[] |
retrieveIntArray(URL url)
Fetches the JSON response, parses the JSON Response, returns the result of the request as an array of integers.
|
protected static String |
retrieveString(URL url)
Fetches the JSON response, parses the JSON Response, returns the result of the request as a String.
|
protected static String[] |
retrieveStringArr(URL url)
Fetches the JSON response, parses the JSON Response as an array of Strings
and returns the result of the request as a String Array.
|
protected static String[] |
retrieveStringArr(URL url,
String jsonProperty)
Fetches the JSON response, parses the JSON Response as an Array of JSONObjects,
retrieves the String value of the specified JSON Property, and returns the result of
the request as a String Array.
|
static void |
setClientId(String pClientId)
Sets the Client ID.
|
static void |
setClientSecret(String pClientSecret)
Sets the Client Secret.
|
static void |
setContentType(String pKey)
Sets the API key.
|
static void |
setHttpReferrer(String pReferrer)
Sets the Http Referrer.
|
static void |
setKey(String pKey)
Sets the API key.
|
protected static void |
validateServiceState() |
protected static final String ENCODING
protected static String apiKey
protected static final String PARAM_APP_ID
protected static final String PARAM_TO_LANG
protected static final String PARAM_FROM_LANG
protected static final String PARAM_TEXT_SINGLE
protected static final String PARAM_TEXT_ARRAY
protected static final String PARAM_SPOKEN_LANGUAGE
protected static final String PARAM_SENTENCES_LANGUAGE
protected static final String PARAM_LOCALE
protected static final String PARAM_LANGUAGE_CODES
public static void setKey(String pKey)
pKey - The API key.public static void setContentType(String pKey)
pKey - The API key.public static void setClientId(String pClientId)
pKey - The Client Id.public static void setClientSecret(String pClientSecret)
pKey - The Client Secret.public static void setHttpReferrer(String pReferrer)
pReferrer - The HTTP client referrer.public static String getToken(String clientId, String clientSecret) throws Exception
clientId - The Client key.clientSecret - The Client SecretExceptionprotected static String retrieveString(URL url) throws Exception
url - The URL to query for a String response.Exception - on error.protected static String[] retrieveStringArr(URL url, String jsonProperty) throws Exception
url - The URL to query for a String response.Exception - on error.protected static String[] retrieveStringArr(URL url) throws Exception
url - The URL to query for a String response.Exception - on error.protected static Integer[] retrieveIntArray(URL url) throws Exception
url - The URL to query for a String response.Exception - on error.protected static void validateServiceState()
throws Exception
ExceptionCopyright © 2013. All Rights Reserved.