Class Translator.Session
java.lang.Object
com.codename1.ai.language.Translator.Session
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
Translator
Reusable owner of a native translation backend.
A session can serve multiple language pairs and retains native clients
between calls. Calling close() prevents new requests and
defers release until pending translations finish.
-
Method Summary
-
Method Details
-
translate
Translates text without recreating the native backend. Cancelling the returned resource suppresses late callbacks without closing this reusable session.- Parameters:
text- source text;nullis treated as emptysourceLanguage- supported BCP-47 source language tagtargetLanguage- supported BCP-47 target language tag- Returns:
- asynchronous translated text
- Throws:
IllegalStateException- if this session is closed
-
close
public void close()Closes the session. This method is idempotent; native release is deferred until pending translations finish.- Specified by:
closein interfaceAutoCloseable
-