Class AbbreviationTableManager


  • public class AbbreviationTableManager
    extends java.lang.Object
    The abbreviation table manager facilitates access to the user's preferred abbreviations for the various code types supported by CodeEditors and for markup targets contained in game component editors. The table returned for a given code type or game code is fixed for the life of the application and shared with all callers requesting that table.
    Since:
    3.0
    Author:
    Chris Jennings
    • Method Detail

      • getTable

        public static AbbreviationTableManager.LanguageAwareAbbreviationTable getTable​(java.lang.String gameCode)
        Returns the shared abbreviation table for the game with the specified code. If the user has created a custom table, this will be returned. Otherwise, a default table is returned if one exists (they are defined in resources/abbrv). If no default table exists, an empty table is returned.

        Note: Tables returned from this method are shared and should generally be considered immutable (read-only). If you wish to change the contents of the table, use saveUserTable(ca.cgjennings.ui.textedit.CodeType, ca.cgjennings.ui.textedit.AbbreviationTable).

        Parameters:
        gameCode - the code for the game whose table should be fetched
        Returns:
        the shared abbreviation table for the code type
      • saveUserTable

        public static void saveUserTable​(CodeType type,
                                         AbbreviationTable at)
                                  throws java.io.IOException
        Saves the specified table as the user table for the given code type. After this returns, the table returned by getTable(ca.cgjennings.apps.arkham.editors.CodeEditor.CodeType) will be identical to the saved table.
        Parameters:
        type - the code type whose table should be modified
        at - the new table content for the code type
        Throws:
        java.io.IOException - if an I/O error occurs during the save operation
        java.lang.NullPointerException - if either parameter is null
      • saveUserTable

        public static void saveUserTable​(java.lang.String gameCode,
                                         AbbreviationTable at)
                                  throws java.io.IOException
        Saves the specified table as the user table for the given game code. After this returns, the table returned by getTable(java.lang.String) will be identical to the saved table.
        Parameters:
        gameCode - the code of the game whose table should be modified
        at - the new table content for the code type
        Throws:
        java.io.IOException - if an I/O error occurs during the save operation
        java.lang.NullPointerException - if either parameter is null
      • isCodeTypeMapped

        public static boolean isCodeTypeMapped​(CodeType type)
        Returns true if the specified code type is mapped to another type for the purposes of loading an abbreviation table. For example, the code type for automation scripts is mapped to the code type for regular script files, so they share a common set of definitions.
        Parameters:
        type - the code type to check for mapping
        Returns:
        true if the code type shares another type's abbreviation table