Class CacheTeacher

java.lang.Object
overit.geocall.lang.Teacher
overit.geocall.lang.CacheTeacher

public class CacheTeacher extends Teacher
This class implements a Teacher that does make translations and stores in two separated caches the translations for the field names and the string values to be more efficient and faster when is requested a translation that has already been done before
  • Field Details

  • Constructor Details

    • CacheTeacher

      public CacheTeacher(TeacherDuty td)
      Creates a new CacheTeacher
      Parameters:
      td - The TeacherDuty used to create the Teacher
  • Method Details

    • registerOmissions

      public void registerOmissions(String lang, String pkg, Long factory)
      Register the missing translation
      Parameters:
      lang - The language
      pkg - The applicative package
      factory - The company ID
    • convertName

      public String convertName(String name)
      Converts the field name passed as parameter in the corresponding converted field name. It searches the translation first in the cache, and after that in the Dictionary. If there is a translation it returns it (and registers it in the cache), otherwise it returns null
      Specified by:
      convertName in class Teacher
      Parameters:
      name - A valued and consistent string, with length greater than 0, that must be converted and corresponds to a field name
      Returns:
      The coversion of the field name, or null if the translation is missing
    • convert

      public String convert(String source)
      Converts the source string passed as parameter in the corresponding converted string. It searches the translation first in the cache, and after that in the Dictionary. If there is a translation it returns it (and registers it in the cache), otherwise it returns null
      Specified by:
      convert in class Teacher
      Parameters:
      source - A valued and consistent string, with length greater than 0, that must be translated
      Returns:
      The converted string, or null if the translation is missing
    • convertLabel

      public String convertLabel(String source)
      Converts the label string passed as parameter in the corresponding converted label. It searches the translation first in the cache, and after that in the Dictionary. The @ characters are removed from the strings because they are not considered in dictionaries files; after the translation, if requested, the system tries to reinsert the @ character in the right position.
      If there is a translation it returns it (and registers it in the cache), otherwise it returns null
      Specified by:
      convertLabel in class Teacher
      Parameters:
      source - A valued and consistent string, with length greater than 0, that must be translated and corresponds to a user interface label
      Returns:
      The converted label, or null if the translation is missing
    • register

      protected static void register(Map cache, int maxDim, String source, String dest)
    • reset

      public void reset()
      Description copied from class: Teacher
      Resets the Teacher, ie empties the translations caches
      Specified by:
      reset in class Teacher
    • valueKeySetIterator

      public Iterator valueKeySetIterator()
      Returns an Iterator over the keys of the values's cache
      Returns:
      An Iterator over the entry's keys of the values's cache
    • nameKeySetIterator

      public Iterator nameKeySetIterator()
      Returns an Iterator over the keys of the field names's cache
      Returns:
      An Iterator over the entry's keys of the field names's cache
    • getDictionary

      public Dictionary getDictionary()
      Returns the Dictionary
      Returns:
      The dictionary used by the teacher