Package com.iizix.translate
Interface ITranslationEngine
- All Known Implementing Classes:
- EditorTranslationEngine,- TestEngine,- TranslationEngine
 - public interface ITranslationEngineThe translation engine interface.- Author:
- Christopher Mindus
 
- Field Summary- Fields - Modifier and Type - Field - Description - static int- REQTYPE_POSTType of request: normal POST.- static int- REQTYPE_POST_OVERRIDES_GETType of request: POST with "X-HTTP-Method-Override" to GET.
 - Method Summary- All Methods Instance Methods Abstract Methods - Modifier and Type - Method - Description - void- cancel()Cancels pending or running translation job.- boolean- canTranslate(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode)Checks if a translation is handled between two language codes.- void- configureProxy(java.net.HttpURLConnection urlConnection)Configures a Http(s)URLConnection for proxy information.- java.net.Proxy- getProxy(java.net.URL url)Gets a proxy to use for an URL.- TranslationQueue[]- getQueues()Gets the translation queues.- java.lang.String- getReadyState()Gets the ready state of this translation engine.- ITranslator- getTranslator(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode)Gets the translator to use for a particular language combination.- boolean- isLanguageHandled(java.lang.String languageCode)Verifies if a Language Code is handled by this translator.- java.lang.String- postRequestJSON(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String data)Requests a function using HTTPS POST, configured for proxy as specified in Eclipse or the Server.- JSONObject- requestJSON(java.lang.String httpRequest, java.lang.String params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit)Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- JSONObject- requestJSON(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit)Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- java.lang.String- requestString(java.lang.String httpRequest, java.lang.String params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit)Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- java.lang.String- requestString(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit)Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- boolean- translate(KString sourceText, java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode, ITranslationReply replyCallback)Translates a text in plain text or HTML.
 
- Field Detail- REQTYPE_POST- static final int REQTYPE_POST Type of request: normal POST.- See Also:
- Constant Field Values
 
 - REQTYPE_POST_OVERRIDES_GET- static final int REQTYPE_POST_OVERRIDES_GET Type of request: POST with "X-HTTP-Method-Override" to GET.- See Also:
- Constant Field Values
 
 
 - Method Detail- getTranslator- ITranslator getTranslator(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode) Gets the translator to use for a particular language combination.- Parameters:
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- Returns:
- The translator, null for not found or not configured.
 
 - getQueues- TranslationQueue[] getQueues() Gets the translation queues.- Returns:
- The array of translation queues.
 
 - getReadyState- java.lang.String getReadyState() Gets the ready state of this translation engine.- Returns:
- An error message describing the state (e.g. "Not configured"), or null for OK.
 
 - isLanguageHandled- boolean isLanguageHandled(java.lang.String languageCode) Verifies if a Language Code is handled by this translator.- Parameters:
- languageCode- The language code.
- Returns:
- true if supported, false if not.
 
 - canTranslate- boolean canTranslate(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode)Checks if a translation is handled between two language codes.- Parameters:
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- Returns:
- true if supported, false if not.
 
 - translate- boolean translate(KString sourceText, java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode, ITranslationReply replyCallback) Translates a text in plain text or HTML.- Parameters:
- sourceText- The source text to translate.
- sourceLanguageCode- The source language code, null for automatic detection.
- targetLanguageCode- The target language code.
- replyCallback- Callback when translation completes.
- Returns:
- true for success, false for failure (error is logged).
 
 - cancel- void cancel() Cancels pending or running translation job.
 - getProxy- java.net.Proxy getProxy(java.net.URL url) Gets a proxy to use for an URL.- Parameters:
- url- The URL.
- Returns:
- The Proxy to use.
 
 - configureProxy- void configureProxy(java.net.HttpURLConnection urlConnection) Configures a Http(s)URLConnection for proxy information.- Parameters:
- urlConnection- The HttpURLConnection or HttpsURLConnection.
 
 - requestJSON- JSONObject requestJSON(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit) throws java.io.IOException, JSONException Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The parsed JSON object.
- Throws:
- java.io.IOException- For I/O errors.
- JSONException- For JSON exceptions.
 
 - requestJSON- JSONObject requestJSON(java.lang.String httpRequest, java.lang.String params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit) throws java.io.IOException, JSONException Requests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The parsed JSON object.
- Throws:
- java.io.IOException- For I/O errors.
- JSONException- For JSON exceptions.
 
 - requestString- java.lang.String requestString(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit) throws java.io.IOExceptionRequests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The reply string.
- Throws:
- java.io.IOException- For I/O errors.
 
 - requestString- java.lang.String requestString(java.lang.String httpRequest, java.lang.String params, java.util.Map<java.lang.String,java.lang.String> headers, int type, int sizeLimit) throws java.io.IOExceptionRequests a function using HTTPS GET or POST with "X-HTTP-Method-Override: GET", configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- params- The parameters, null for none.
- headers- The HTTP headers, null for none.
- type- Type of request: REQTYPE_* value.
- sizeLimit- The size limit imposed, 5120 for Google, 10K for Microsoft.
- Returns:
- The reply string.
- Throws:
- java.io.IOException- For I/O errors.
 
 - postRequestJSON- java.lang.String postRequestJSON(java.lang.String httpRequest, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String data) throws java.io.IOExceptionRequests a function using HTTPS POST, configured for proxy as specified in Eclipse or the Server.- Parameters:
- httpRequest- The request string.
- headers- The HTTP headers, never null.
- data- The data string.
- Returns:
- The reply string.
- Throws:
- java.io.IOException- For I/O errors.