Class Teacher

java.lang.Object
overit.geocall.lang.Teacher
Direct Known Subclasses:
CacheTeacher, NullTeacher

public abstract class Teacher extends Object
This abstract class it must be extended to define a Teacher object, ie the object that will manages all the translations of the graphic interface (static label translations) and database data (dinamic fields translations) to implement the multi-language support.
  • Field Details

    • TRY

      public static final char TRY
      Character used as the first character of the string to request the translation
      See Also:
    • TRY_OUTPUT

      public static final char TRY_OUTPUT
      Character used as the first character of the string to request the translation for the output
      See Also:
    • AVOID

      public static final char AVOID
      Character used as the first character of the string to avoid the translation
      See Also:
    • _duty

      protected TeacherDuty _duty
  • Constructor Details

  • Method Details

    • getDuty

      public TeacherDuty getDuty()
      Returns the TeacherDuty
      Returns:
      The TeacherDuty
    • convert

      protected abstract String convert(String source)
      Abstract method that must be implemented. Converts the source string passed as parameter in the corresponding converted string
      Parameters:
      source - A valued and consistent string, with length greater than 0, that must be converted
      Returns:
      The coversion of the source
    • convertLabel

      protected abstract String convertLabel(String source)
      Abstract method that must be implemente. Converts the label string passed as parameter in the corresponding converted label
      Parameters:
      source - A valued and consistent string, with length greater than 0, that must be converted
      Returns:
      The conversion of the label
    • convertName

      protected abstract String convertName(String source)
      Abstract method that must be implemented. Converts the field name passed as parameter in the corresponding converted field name
      Parameters:
      source - A valued and consistent string, with length greater than 0, that must be converted
      Returns:
      The coversion of the field name
    • reset

      public abstract void reset()
      Resets the Teacher, ie empties the translations caches
    • translateName

      public final ForeignField translateName(String name)
      Translates the field name passed as parameter, considering the possible presence of the prohibition expressed by the character AVOID, and returns the normalized name that can have the character TRY as first character, to request the translation of the value
      Parameters:
      name - The field name to translate
      Returns:
      The ForeignField that corresponds to the translation of the field name passed as parameter
    • translateName

      public final ForeignField translateName(String name, String def)
      Translates the field name passed as parameter, considering the possible presence of the prohibition expressed by the character AVOID, and returns the normalized name that can have the character TRY as first character, to request the translation of the value
      Parameters:
      name - The field name to translate
      def - The default translation, the name returned if the name translation returns null
      Returns:
      The ForeignField that corresponds to the translation of the field name passed as parameter
    • translateName

      public final ForeignField translateName(String name, Map fieldPosition)
      Translates the field name passed as parameter, considering the possible presence of the prohibition expressed by the character AVOID, and returns the normalized name that can have the character TRY as first character, to request the translation of the value
      Parameters:
      name - The field name to translate
      fieldPosition - Optional map (can be null) which associates the name of the fields with the position in the list
      Returns:
      The ForeignField that corresponds to the translation of the field name passed as parameter
    • translateName

      public final ForeignField translateName(String name, DBView dbv)
      Translates the field name passed as parameter, considering the possible presence of the prohibition expressed by the character AVOID, and returns the normalized name that can have the character TRY as first character, to request the translation of the value
      Parameters:
      name - The field name to translate
      dbv - Optional DBView (can be null) which associates the name of the fields with the position in the list
      Returns:
      The ForeignField that corresponds to the translation of the field name passed as parameter
    • translateContent

      public final String translateContent(ForeignField ff, Map map, String def)
      Translates, if necessary, the static translation of the content of the field retrieved from the map, or simply retrieves the value
      Parameters:
      ff - The ForeignField of which the content must be translated
      map - The map from which we retrieve the field
      def - The default translation
      Returns:
      The translation of the content of the field
    • translateContent

      public final String translateContent(ForeignField ff, Map map, String def, boolean forInput)
      Translates, if necessary, the static translation of the content of the field retrieved from the map, or simply retrieves the value
      Parameters:
      ff - The ForeignField of which the content must be translated
      map - The map from which we retrieve the field
      def - The default translation
      forInput - Defines if the translation is required even for input or only for output
      Returns:
      The translation of the content of the field
    • translateContent

      public final String translateContent(ForeignField ff, List l, String def)
      Translates, if necessary, the static translation of the content of the field retrieved from the map, or simply retrieves the value
      Parameters:
      ff - The ForeignField of which the content must be translated
      l - The list from which we retrieve the field
      def - The default translation
      Returns:
      The translation of the content of the field
    • translateContent

      public final String translateContent(ForeignField ff, List l, String def, boolean forInput)
      Translates, if necessary, the static translation of the content of the field retrieved from the map, or simply retrieves the value
      Parameters:
      ff - The ForeignField of which the content must be translated
      l - The list from which we retrieve the field
      def - The default translation
      forInput - Defines if the translation is required even for input or only for output
      Returns:
      The translation of the content of the field
    • translateContent

      protected final String translateContent(ForeignField ff, Object o, String def, boolean forInput)
    • translate

      public final String translate(String source)
      Translates the string passed as parameter
      Parameters:
      source - The string to translate
      Returns:
      If the source is null, or an empty string, or starts with the AVOID character, the method will returns the source (removing the AVOID) character).
      In the other cases it will returns the translation of the source using the convert(java.lang.String), method, and if the translation is not available it marks the source string and returns it in square brackets
    • translateLabel

      public final String translateLabel(String source)
      Translates the label passed as parameter
      Parameters:
      source - The string to translate
      Returns:
      If the source is null, or an empty string, or starts with the AVOID character, the method will returns the source (removing the AVOID character).
      In the other cases it will returns the translation of the source using the convertLabel(java.lang.String), method, and if the translation is not available it marks the source string and returns it in square brackets
    • adjust

      public final String adjust(String source)
      Adjusts the string passed as parameter; if the string starts with the TRY character, it try to translates it, otherwise it returns it without translation.
      Parameters:
      source - The string to translate
      Returns:
      If the source is null, or an empty string, or don't starts with the TRY character, the method will returns the source string as is.
      In the other cases it will returns the translation of the source using the convert(java.lang.String), method, and if the translation is not available it marks the source string and returns it in square brackets
    • adjustLabel

      public final String adjustLabel(String source)
      Adjusts the label passed as parameter; if the label starts with the TRY character, it try to translates it, otherwise it returns it without translation.
      Parameters:
      source - The string to translate
      Returns:
      If the source is null, or an empty string, or don't starts with the TRY character, the method will returns the source string as is.
      In the other cases it will returns the translation of the source using the convertLabel(java.lang.String), method, and if the translation is not available it marks the label string and returns it in square brackets
    • mark

      protected String mark(String message)
    • isMarked

      protected boolean isMarked(String message)
    • getType4Legacy

      protected static LangType getType4Legacy(boolean partial)
    • getTeacher

      public static Teacher getTeacher(String name, String lang, boolean partial, Identity id, int maxDim)
      Parameters:
      name - Name of the teacher
      lang - Name of the dictionary that must be used, it can be extracted from the Identity
      partial - true to obtain a partial dictionary, that don't marks the omissed translations
      id - The Identity
      maxDim - Maximum dimension of the translations cache
      Returns:
      The Teacher
    • getTeacher

      public static Teacher getTeacher(String name, String lang, LangType type, Identity id, int maxDim)
      Returns the Teacher used for the translations
      Parameters:
      name - Name of the teacher
      lang - Name of the dictionary that must be used, it can be extracted from the Identity
      type - The LangType that contains the configuration for the type of translations (full or partial) or the type of the shortcuts
      id - identity The Identity
      maxDim - Maximum dimension of the translations cache
      Returns:
      The Teacher
    • getTeacher

      @Deprecated public static Teacher getTeacher(String name, String lang, String tableSuffix, boolean partial, String belongingLayer, Identity id, int maxDim)
      Parameters:
      name - Name of the teacher
      lang - Name of the dictionary that must be used, it can be extracted from the Identity
      tableSuffix - Suffix used for the names of the foreign tables, the ones that contains the fields in foreign languages
      partial - true to obtain a partial dictionary, that don't marks the omissed translations
      belongingLayer - The applicative package
      id - The Identity
      maxDim - Maximum dimension of the translations cache
      Returns:
      The Teacher
    • getTeacher

      public static Teacher getTeacher(String name, String lang, String tableSuffix, LangType type, String pkg, Identity id, int maxDim)
      Returns the Teacher used for the translations
      Parameters:
      name - Name of the teacher
      lang - Name of the dictionary that must be used, it can be extracted from the Identity
      tableSuffix - Suffix used for the names of the foreign tables, the ones that contains the fields in foreign languages
      type - The LangType that contains the configuration for the type of translations (full or partial) or the type of the shortcuts
      pkg - The applicative package
      id - the Identity
      maxDim - Maximum dimension of the translations cache
      Returns:
      The Teacher
    • getTeacher

      public static Teacher getTeacher(String name, Identity identity, String belongingLayer)
      Returns the Teacher used for the translations
      Parameters:
      name - Name of the Teacher
      identity - The Identity of the user currently logged in the application
      belongingLayer - The package to which the Teacher belongs
      Returns:
      The Teacher
    • getTeacher

      public static Teacher getTeacher(UIClass uic, Identity identity)
      Returns the Teacher used for the translations
      Parameters:
      uic - The UIClass
      identity - The Identity from which extract the teacher
      Returns:
      The Teacher