Class AbbreviationTableManager
- java.lang.Object
-
- ca.cgjennings.apps.arkham.editors.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 byCodeEditor
s 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbbreviationTableManager.LanguageAwareAbbreviationTable
An abbreviation table that also expands @string and #string (when placed in braces) to user interface and game language strings, respectively.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AbbreviationTableManager.LanguageAwareAbbreviationTable
getTable(CodeType type)
Returns the shared abbreviation table for the given code type.static AbbreviationTableManager.LanguageAwareAbbreviationTable
getTable(java.lang.String gameCode)
Returns the shared abbreviation table for the game with the specified code.static boolean
isCodeTypeMapped(CodeType type)
Returnstrue
if the specified code type is mapped to another type for the purposes of loading an abbreviation table.static void
saveUserTable(CodeType type, AbbreviationTable at)
Saves the specified table as the user table for the given code type.static void
saveUserTable(java.lang.String gameCode, AbbreviationTable at)
Saves the specified table as the user table for the given game code.
-
-
-
Method Detail
-
getTable
public static AbbreviationTableManager.LanguageAwareAbbreviationTable getTable(CodeType type)
Returns the shared abbreviation table for the given code type. If the user has created a custom table, this will be returned. Otherwise, a default table is returned if one exists (they are defined inresources/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:
type
- the code type whose table should be fetched- Returns:
- the shared abbreviation table for the code type
-
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 inresources/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 bygetTable(ca.cgjennings.apps.arkham.editors.CodeEditor.CodeType)
will be identical to the saved table.- Parameters:
type
- the code type whose table should be modifiedat
- the new table content for the code type- Throws:
java.io.IOException
- if an I/O error occurs during the save operationjava.lang.NullPointerException
- if either parameter isnull
-
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 bygetTable(java.lang.String)
will be identical to the saved table.- Parameters:
gameCode
- the code of the game whose table should be modifiedat
- the new table content for the code type- Throws:
java.io.IOException
- if an I/O error occurs during the save operationjava.lang.NullPointerException
- if either parameter isnull
-
isCodeTypeMapped
public static boolean isCodeTypeMapped(CodeType type)
Returnstrue
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
-
-