Class Dictionary

java.lang.Object
overit.geocall.lang.Dictionary

public class Dictionary extends Object
This class implements the object that manages the storing and conversion of the string translations
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Long
    The company ID for which the dictionary is written
    protected String
    The language with which the dictionary is written
     
    protected Lazy<Chapter[]>
    The Chapter that contains the translations for the standard module (geocall)
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Dictionary(String lang, String layer, Long factory)
    Creates the dictionary.
    It instantiates the Chapter for the standard module (geocall) and the custom applicative modules
  • Method Summary

    Modifier and Type
    Method
    Description
    convert(String source, Omission omissions)
    Translates the string passed as parameter, searching for the translations first in the custom chapters and then in the standard one.
    boolean
    Gets if the language has been found or not.
    find(String pattern, String type, boolean searchOnKeys, boolean searchOnValues)
    Find all the dictionary's translations that match a pattern passed in input.
    static Dictionary
    get(String lang, String layer, Long factory)
    Extracts the dictionary starting from the language, the applicative packages and the company.
    If the dictionary does not exist, it is instantiated.
    static Dictionary
    get(TeacherDuty teacherDuty)
    Extracts the dictionary starting from the teacher duty.
    If the dictionary does not exist, it is instantiated.
    Returns the Chapter that contains the translations for the standard module (geocall)
    Returns the company ID for which the dictionary is written
    Returns the language with which the dictionary is written

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _lang

      protected String _lang
      The language with which the dictionary is written
    • _factory

      protected Long _factory
      The company ID for which the dictionary is written
    • chapters

      protected Lazy<Chapter[]> chapters
      The Chapter that contains the translations for the standard module (geocall)
    • chapterChain

      protected Lazy<SupplierChain<String,String>> chapterChain
  • Constructor Details

    • Dictionary

      protected Dictionary(String lang, String layer, Long factory)
      Creates the dictionary.
      It instantiates the Chapter for the standard module (geocall) and the custom applicative modules
      Parameters:
      lang - The language
      layer - The name of the layer
      factory - The id of the company
  • Method Details

    • get

      public static Dictionary get(String lang, String layer, Long factory)
      Extracts the dictionary starting from the language, the applicative packages and the company.
      If the dictionary does not exist, it is instantiated.
      Parameters:
      lang - The language
      layer - The name of the layer
      factory - The id of the company
      Returns:
      The instance of the dictionary
    • get

      public static Dictionary get(TeacherDuty teacherDuty)
      Extracts the dictionary starting from the teacher duty.
      If the dictionary does not exist, it is instantiated.
      Parameters:
      teacherDuty - the TeacherDuty instance
      Returns:
      The instance of the dictionary
    • getLang

      public String getLang()
      Returns the language with which the dictionary is written
      Returns:
      The language, that corresponds to the name of the Dictionary
    • getFactory

      public Long getFactory()
      Returns the company ID for which the dictionary is written
      Returns:
      The company ID for which the dictionary is written
    • exists

      public boolean exists()
      Gets if the language has been found or not.
      Returns:
      true if the language has been found, false otherwise false
    • convert

      public String convert(String source, Omission omissions)
      Translates the string passed as parameter, searching for the translations first in the custom chapters and then in the standard one. If there isn't the translation for the string, it register the omission with Omission.logOmission(java.lang.String)
      Parameters:
      source - The string to translate
      omissions - The Omission used to record the missing translations
      Returns:
      The translated string, or null if there isn't a translation
    • find

      public TreeMap<String,String> find(String pattern, String type, boolean searchOnKeys, boolean searchOnValues)
      Find all the dictionary's translations that match a pattern passed in input.
      Parameters:
      pattern - The pattern to match
      type - The type of match. P (Phrase) means that the translation's key or value, must contains the entire pattern string to be retrieved. W (Words) means that the translation's key or value, must contains at least one of the words present within the pattern.
      searchOnKeys - true if you want to search on the translations's keys, false otherwise.
      searchOnValues - true if you want to search on the translations's values, false otherwise.
      Returns:
      All the dictionary's translations that match a pattern passed in input.
    • getChapters

      public Chapter[] getChapters()
      Returns the Chapter that contains the translations for the standard module (geocall)
      Returns:
      The Chapter that contains the translations for the standard module (geocall)