Class TranslationTrial

java.lang.Object
com.iizigo.translate.TranslationTrial

public final class TranslationTrial extends Object
The free translations of the translation engines: until the developer configures the translation engines with keys of their own, the first translations of every translator are free. They are counted per translator class in the preference store, and when the free translations of a translator are used up, the trial ends and the engines must be configured to keep on translating.

The count and the armed flag are stored under the preference keys the Designer has always used for them, so a workspace keeps its count across versions.

Author:
Christopher Mindus
  • Method Details

    • getFreeTranslations

      public static long getFreeTranslations()
      Gets the count of free translations of a translator.
      Returns:
      The count of translations that are free for each translator.
    • arm

      public static void arm(IPreferenceStore store, String translatorClassName)
      Arms the trial for a translator class: its count starts at zero and its translations are counted.
      Parameters:
      store - The preference store.
      translatorClassName - The class name of the translator.
    • isArmed

      public static boolean isArmed(IPreferenceStore store, String translatorClassName)
      Checks if the trial is armed for a translator class, i.e. if its translations are counted and limited.
      Parameters:
      store - The preference store.
      translatorClassName - The class name of the translator.
      Returns:
      true if armed, false if not.
    • getCount

      public static long getCount(IPreferenceStore store, String translatorClassName)
      Gets the count of translations made with a translator class during the trial.
      Parameters:
      store - The preference store.
      translatorClassName - The class name of the translator.
      Returns:
      The count, zero when nothing is counted.
    • countCompleted

      public static boolean countCompleted(IPreferenceStore store, String translatorClassName)
      Counts a completed translation of a translator class. Nothing is counted when the trial is not armed for the class, and nothing is counted after the trial has ended.
      Parameters:
      store - The preference store.
      translatorClassName - The class name of the translator.
      Returns:
      true when this translation was the last free one: the trial is now disarmed for the class and the caller ends it; false otherwise.