Package com.iizix.translate
Class AbstractTranslationRequest
- java.lang.Object
- com.iizix.translate.AbstractTranslationRequest
- All Implemented Interfaces:
ITranslationRequest
public abstract class AbstractTranslationRequest extends java.lang.Object implements ITranslationRequest
The abstract translation request class.- Author:
- Christopher Mindus
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractTranslationRequest.RequestItem
Class for a RequestItem.
Field Summary
Fields Modifier and Type Field Description protected java.util.ArrayList<AbstractTranslationRequest.RequestItem>
requests
Request array.protected java.lang.String
sourceLanguageCode
The source language code, null for automatic detection.protected java.lang.String
targetLanguageCode
The target language code.
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTranslationRequest(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode)
Constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addRequest(KString sourceText, ITranslationReply reply)
Adds a requests to perform at the same time as the others.
Field Detail
requests
protected final java.util.ArrayList<AbstractTranslationRequest.RequestItem> requests
Request array.
sourceLanguageCode
protected final java.lang.String sourceLanguageCode
The source language code, null for automatic detection.
targetLanguageCode
protected final java.lang.String targetLanguageCode
The target language code.
Constructor Detail
AbstractTranslationRequest
protected AbstractTranslationRequest(java.lang.String sourceLanguageCode, java.lang.String targetLanguageCode)
Constructor.- Parameters:
sourceLanguageCode
- The source language code, null for automatic detection.targetLanguageCode
- The target language code.
Method Detail
addRequest
public boolean addRequest(KString sourceText, ITranslationReply reply)
Adds a requests to perform at the same time as the others. The amount of simultaneous requests depends on the size of the entire data transaction usually in UTF-8 bytes.- Specified by:
addRequest
in interfaceITranslationRequest
- Parameters:
sourceText
- The source text to translate.reply
- The reply callback when translation completes.- Returns:
- true for successfully added, false for no more room.