Class Selection

java.lang.Object
eu.bandm.tools.muli.Selection

public class Selection extends Object
Represents a preference list of languages, to control translation for a GUI, or sim.
  • Field Details

    • LINGUA_FRANCA

      public static final String LINGUA_FRANCA
      A language which is understood everywhere. It contains names which are never translated, because they are product names or ISO-defined entities, or sim.
      See Also:
    • currentLanguage

      protected String currentLanguage
      The top-most language currently selected. (Normally all GUI elements will appear in this language, if possible. If not, the default preference sequence is searched instead.)
    • priorities

      protected final List<String> priorities
      The default preference sequence, as set when constructing.
    • preferences

      protected final List<String> preferences
      The list used for the search for translations, affected by setLanguage(java.lang.String).
    • listeners

      protected final Set<Selection.Listener> listeners
      All subscribing Listeners.
    • prefs

      public final List<String> prefs
      The current list of preferences. ATTENTION Delivers a life-list which will change according to setLanguage(java.lang.String), etc.
  • Constructor Details

    • Selection

      public Selection(String... langs)
      Sets the default preference sequence. The initial state is set equal to this list.
      Parameters:
      langs - default preference sequence.
    • Selection

      public Selection(List<String> langs)
      Sets the default preference sequence. The initial state is set equal to this list.
      Parameters:
      langs - default preference sequence.
  • Method Details

    • getCurrentLanguage

      public String getCurrentLanguage()
      The currently selected language.
      Returns:
      the currently selected language.
    • isMuLi

      public boolean isMuLi()
      Whether more than one language is provided.
      Returns:
      whether more than one language is provided.
    • addListener

      public void addListener(Selection.Listener rec)
      Add a listener as subsrciber. Is idempotent: multiple calls have no further effect.
      Parameters:
      rec - the subscribing listener.
    • removeListener

      public void removeListener(Selection.Listener rec)
      Remove a listener as subsrciber. Is idempotent: multiple calls have no further effect.
      Parameters:
      rec - the no longer subscribing listener. If it is not subscribing, there is no effect.
    • setLanguage

      public void setLanguage(String lang)
      Select the current language. The new prference sequence is calculated. Iff it differs, the listeners are notified.
      Parameters:
      lang - the new current language.
      Throws:
      IllegalStateException - if the languags is not in the list of (currently) supported languages.
    • setPriorities

      public void setPriorities(String... langs)
      Re-define the sequence of supported languages and the default preferences.
      Parameters:
      langs - list of languages
      Throws:
      IllegalArgumentException - if a null value is contained in langs