Class TextTable

All Implemented Interfaces:
EventListener, IGProp<GProp<?>[]>, IPropCnr, IReferenceOwner<TextTable>, IReferencingPropCnr, ITextTableReferenceOwner, Cloneable
Direct Known Subclasses:
EditorTextTable

public class TextTable extends PropCnr implements ITextTableReferenceOwner, IReferencingPropCnr
The text table property holds the text table items consisting of KStrings. A text table
Author:
Christopher Mindus
  • Field Details

    • AUTO_TRANSLATE_TO

      public static final String AUTO_TRANSLATE_TO
      Constant for the atom name of the property: automatic translation to this table.
      See Also:
    • AUTO_TRANSLATE_FROM

      public static final String AUTO_TRANSLATE_FROM
      Constant for the atom name of the property: automatic translation from this table.
      See Also:
    • MUST_DEFINE

      public static final String MUST_DEFINE
      Constant for the atom name of the property: must defined every derived entry.
      See Also:
    • VERIFY

      public static final String VERIFY
      Constant for the atom name of the property: enable verification of entries.
      See Also:
    • EMPTY_ARRAY

      public static final TextTable[] EMPTY_ARRAY
      An empty array.
  • Constructor Details

    • TextTable

      protected TextTable()
      Creates the text table property container without a name. The name must be set in all cases using the setPropertyAtom call.
    • TextTable

      public TextTable(Atom propertyAtom)
      Creates the text table with the specified name. All system-reserved names for components begins with "$".
      Parameters:
      propertyAtom - the name of the component, unique within it's parent.
  • Method Details

    • clone

      public TextTable clone()
      Clone must be overridden.
      Overrides:
      clone in class PropCnr
    • getReferenceType

      public IPropReference.IRefType getReferenceType()
      Gets the reference Type.
      Specified by:
      getReferenceType in interface IReferencingPropCnr
      Returns:
      IPropReference.RefType.TextTable.
    • usesMultipleReferencing

      public boolean usesMultipleReferencing()
      Checks if this referencing Property Container has single or multiple referencing properties at maximum.
      Specified by:
      usesMultipleReferencing in interface IReferencingPropCnr
      Returns:
      Always false as only a single referencing property is supported. Use the method getReferencingProp() to retrieve it.
    • getReferencingProp

      public IReferencingGProp getReferencingProp()
      Gets the single potential instance of a referencing property instance.
      Specified by:
      getReferencingProp in interface IReferencingPropCnr
      Returns:
      The single referencing property, or null if none is found.
    • getReferencingProps

      public IReferencingGProp[] getReferencingProps()
      Gets the array of referencing property instances.
      Specified by:
      getReferencingProps in interface IReferencingPropCnr
      Returns:
      Always null as there is only support for a single referencing property. Use the method getReferencingProp() to retrieve it.
    • onResolved

      public void onResolved(Atom refAtom, TextTable target)
      Called when the reference has been resolved.
      Specified by:
      onResolved in interface IReferenceOwner<TextTable>
      Parameters:
      refAtom - The atom of the reference property.
      target - The target reference.
    • onBroken

      public void onBroken(Atom refAtom, TextTable target)
      Called when the reference has been broken, i.e. unresolved.
      Specified by:
      onBroken in interface IReferenceOwner<TextTable>
      Parameters:
      refAtom - The atom of the reference property.
      target - The target reference.
    • getDerivesReference

      public String getDerivesReference()
      Gets the text table reference string that this tables derives.
      Returns:
      The reference string, or null for no table derived.
    • getDerives

      public TextTable getDerives()
      Gets the text table that is derived.
      Returns:
      The derived table, or null for none (or reference not found).
    • getDerivedTextTables

      public TextTable[] getDerivedTextTables()
      Gets all tables in all open projects that derives from this text table.

      The return value is cached for subsequent calls to the method.

      Returns:
      An array of all derived tables, in runtime always empty, only defined in the Designer!
    • getAllDerivedTextTablesRecursive

      public TextTable[] getAllDerivedTextTablesRecursive()
      Gets all tables in all open projects that derives from this text table and also the ones deriving from a derived text table recursively.

      The return value is cached for subsequent calls to the method.

      Returns:
      An array of all derived tables, in runtime always empty, only defined in the Designer!
    • getDerivedTextTable

      public TextTable getDerivedTextTable(String languageCode)
      Gets the derived text table to this text table with the specified language code.
      Parameters:
      languageCode - The language code is case insensitive.
      Returns:
      The derived text table, or null if not found.
    • getAllLanguagesMapRecursive

      public Map<String,TextTable> getAllLanguagesMapRecursive()
      Gets the language map recursively. The search starts with this text tables language code, and if defined, it is added to the map. Then all derived text tables are added for their language codes recursively and if present, they are added to the map if the language code was absent.

      This value is cached for subsequent calls to the method.

      Returns:
      An unmodifiable map of all supported languages with its text tables, where the keys are the Language Code in LOWER CASE.
    • getDerivedTextTableRecursive

      public TextTable getDerivedTextTableRecursive(String languageCode)
      Gets the derived text table to this text table with the specified language code recursively, searching the chain of derived table, derived-derived tables, and so on.
      Parameters:
      languageCode - The language code is case insensitive.
      Returns:
      The derived text table, or null if not found.
    • getAllLanguageCodesRecursive

      public String[] getAllLanguageCodesRecursive()
      Gets all the language codes supported by this text table and the derived text tables recursively.

      The return value is cached for subsequent calls to the method.

      Returns:
      An array of language codes.
    • isLanguageCodeSupportedRecursive

      public boolean isLanguageCodeSupportedRecursive(String languageCode)
      Checks if the specified language code is supported by this text table or any of the derived text tables recursively.
      Parameters:
      languageCode - The language code to look-up is case insensitive.
      Returns:
      true if the language code is supported by any of the text tables, false if not supported.
    • getTextID

      public KString getTextID(String id)
      Gets the text entry in this table. If the text is not found, the derived table is verified in order, recursing upwards to the base derived text table.
      Parameters:
      id - The text ID to look-up.
      Returns:
      The text string or null if not found.
    • getTextID

      public KString getTextID(String id, KString fallback)
      Gets the text entry in this table. If the text is not found, the derived table is verified in order, recursing upwards to the base derived text table.
      Parameters:
      id - The text ID to look-up.
      fallback - The fallback text if text ID is not found.
      Returns:
      The text string or fallback if not found.
    • getTextID

      public KString getTextID(String id, String languageCode)
      Gets the text entry with the specified ID for a language. The specific language code is first looked up from the text tables that derives from this text table, then it falls back on the derived tables in order recursively until the base text table is found.
      Parameters:
      id - The text ID to look-up.
      languageCode - The language code, or {code null} for this table.
      Returns:
      The text string or null if not found.
    • getTextID

      public KString getTextID(String id, String languageCode, KString fallback)
      Gets the text entry with the specified ID for a language. The specific language code is first looked up from the text tables that derives from this text table, then it falls back on the derived tables in order recursively until the base text table is found.
      Parameters:
      id - The text ID to look-up.
      languageCode - The language code, or {code null} for this table.
      fallback - The fallback text if text ID is not found.
      Returns:
      The text string or fallback if not found.
    • getPlainTextID

      public String getPlainTextID(String id, IKStringInfoProvider infoProvider)
      Gets the text entry in this table. If the text is not found, the derived table is verified in order, recursing upwards to the base derived text table.
      Parameters:
      id - The text ID to look-up.
      infoProvider - The KString info provider to resolve a KString to a plain string, or null for none.
      Returns:
      The text string or null if not found.
    • getPlainTextID

      public String getPlainTextID(String id, String fallback, IKStringInfoProvider infoProvider)
      Gets the text entry in this table. If the text is not found, the derived table is verified in order, recursing upwards to the base derived text table.
      Parameters:
      id - The text ID to look-up.
      fallback - The fallback text if text ID is not found.
      infoProvider - The KString info provider to resolve a KString to a plain string, or null for none.
      Returns:
      The text string or fallback if not found.
    • getPlainTextID

      public String getPlainTextID(String id, String languageCode, String fallback, IKStringInfoProvider infoProvider)
      Gets the text entry with the specified ID for a language. The specific language code is first looked up from the text tables that derives from this text table, then it falls back on the derived tables in order recursively until the base text table is found.
      Parameters:
      id - The text ID to look-up.
      languageCode - The language code, or {code null} for this table.
      fallback - The fallback text if text ID is not found.
      infoProvider - The KString info provider to resolve a KString to a plain string, or null for none.
      Returns:
      The text string or fallback if not found.
    • getKStringProp

      public KStringProp getKStringProp(String id)
      Gets the text entry in this table. If the text is not found, the derived table is verified in order upwards the chain recursively until the base text table is found.
      Parameters:
      id - The text ID to look-up.
      Returns:
      The text string or null if not found.
    • getKStringProp

      public KStringProp getKStringProp(String id, String languageCode)
      Gets the text entry with the specified ID for a language. The specific language code is first looked up from the text tables that derives from this text table, then it falls back on the derived tables in order recursively until the base text table is found.
      Parameters:
      id - The text ID to look-up.
      languageCode - The language code, or null for this table.
      Returns:
      The text string or null if not found.
    • getDescription

      public String getDescription()
      Gets the description of this text table.
    • setDescription

      public void setDescription(String descr)
      Sets the description of this text table.
      Parameters:
      descr - The description text, non-null.
    • getLanguageCode

      public String getLanguageCode()
      Gets the language for this text table.
      Returns:
      The language code in proper case (not all in lower case), or null for none.
    • setLanguageCode

      public void setLanguageCode(String languageCode)
      Sets a valid language code.
      Parameters:
      languageCode - The language code is case insensitive, non-null.
      Throws:
      IllegalArgumentException - If the language code is not valid.
    • hasLanguageCode

      public boolean hasLanguageCode()
      Checks if a valid language code is set, i.e. not null or empty. This means a generic language or auto-detect for auto-translate.
      Returns:
      true if the language code is defined and not empty string, false otherwise.
    • getLanguageDescription

      public String getLanguageDescription()
      Gets the language description for the language of this text table.
      Returns:
      The language description, or null for none (or invalid language code).
    • setAutomaticTranslationFromTableEnabled

      public void setAutomaticTranslationFromTableEnabled(boolean on)
      Sets automatic translation is enabled from this table.
      Parameters:
      on - The enabled flag.
    • isAutomaticTranslationFromTableEnabled

      public boolean isAutomaticTranslationFromTableEnabled()
      Checks if automatic translation is enabled from this table.
    • setAutomaticTranslationToTableEnabled

      public void setAutomaticTranslationToTableEnabled(boolean on)
      Checks if automatic translation to this table is enabled.
      Parameters:
      on - The enabled flag.
    • isAutomaticTranslationToTableEnabled

      public boolean isAutomaticTranslationToTableEnabled()
      Checks if automatic translation to this table is enabled.
    • isTableDerived

      public boolean isTableDerived()
      Checks if the table derives another.
      Returns:
      true if configured for table derivation AND the derived table is found.
    • setMustDefineDerivedEntries

      public void setMustDefineDerivedEntries(boolean on)
      Sets if all derived entries must be defined.
      Parameters:
      on - The enabling flag.
    • mustDefineDerivedEntries

      public boolean mustDefineDerivedEntries()
      Checks if all derived entries must be defined.
    • setEntryVerificationEnabled

      public void setEntryVerificationEnabled(boolean on)
      Sets if entry verification is enabled.
      Parameters:
      on - The enabling flag.
    • isEntryVerificationEnabled

      public boolean isEntryVerificationEnabled()
      Checks if entry verification is enabled.
    • getText

      public KString getText(String name)
      Get the text associated with the specified text name or text ID.
      Parameters:
      name - The name of the text or text ID.
      Returns:
      The associated text, null for not found.
    • getTextProp

      public KStringProp getTextProp(Atom atom)
      Get the text property associated with the specified text name or text ID.
      Parameters:
      atom - The atom of the text or text ID.
      Returns:
      The associated text, null for not found.
    • getTextProp

      public KStringProp getTextProp(String name)
      Get the text property associated with the specified text name or text ID.
      Parameters:
      name - The name of the text or text ID.
      Returns:
      The associated text, null for not found.