Class LanguageIdentifier.Session

java.lang.Object
com.codename1.ai.language.LanguageIdentifier.Session
All Implemented Interfaces:
AutoCloseable
Enclosing class:
LanguageIdentifier

public static final class LanguageIdentifier.Session extends Object implements AutoCloseable

Reusable owner of a native language-identification backend.

A session accepts multiple asynchronous requests. Calling close() prevents new requests immediately and defers native release until requests already in progress have completed.

  • Method Details

    • identify

      public AsyncResource<LanguageCandidate[]> identify(String text)
      Identifies languages without recreating the native backend. Cancelling the returned resource suppresses late callbacks without closing this reusable session.
      Parameters:
      text - text to classify; null is treated as empty
      Returns:
      asynchronous ranked candidates, possibly empty
      Throws:
      IllegalStateException - if this session is closed
    • close

      public void close()
      Closes the session. This method is idempotent; native release is deferred until pending identifications finish.
      Specified by:
      close in interface AutoCloseable