Class Configuration


  • public class Configuration
    extends java.lang.Object
    Configuration like list of disabled rule IDs, server mode etc. Configuration is loaded from and stored to a properties file.
    • Field Detail

      • STYLE_COLOR

        static final java.awt.Color STYLE_COLOR
      • CURRENT_PROFILE_KEY

        private static final java.lang.String CURRENT_PROFILE_KEY
        See Also:
        Constant Field Values
      • DEFINED_PROFILES_KEY

        private static final java.lang.String DEFINED_PROFILES_KEY
        See Also:
        Constant Field Values
      • DISABLED_RULES_KEY

        private static final java.lang.String DISABLED_RULES_KEY
        See Also:
        Constant Field Values
      • ENABLED_RULES_KEY

        private static final java.lang.String ENABLED_RULES_KEY
        See Also:
        Constant Field Values
      • DISABLED_CATEGORIES_KEY

        private static final java.lang.String DISABLED_CATEGORIES_KEY
        See Also:
        Constant Field Values
      • ENABLED_CATEGORIES_KEY

        private static final java.lang.String ENABLED_CATEGORIES_KEY
        See Also:
        Constant Field Values
      • ENABLED_RULES_ONLY_KEY

        private static final java.lang.String ENABLED_RULES_ONLY_KEY
        See Also:
        Constant Field Values
      • MOTHER_TONGUE_KEY

        private static final java.lang.String MOTHER_TONGUE_KEY
        See Also:
        Constant Field Values
      • WORD2VEC_DIR_KEY

        private static final java.lang.String WORD2VEC_DIR_KEY
        See Also:
        Constant Field Values
      • TAGGER_SHOWS_DISAMBIG_LOG_KEY

        private static final java.lang.String TAGGER_SHOWS_DISAMBIG_LOG_KEY
        See Also:
        Constant Field Values
      • NO_MULTI_RESET_KEY

        private static final java.lang.String NO_MULTI_RESET_KEY
        See Also:
        Constant Field Values
      • DO_FULL_CHECK_AT_FIRST_KEY

        private static final java.lang.String DO_FULL_CHECK_AT_FIRST_KEY
        See Also:
        Constant Field Values
      • USE_DOC_LANG_KEY

        private static final java.lang.String USE_DOC_LANG_KEY
        See Also:
        Constant Field Values
      • ERROR_COLORS_KEY

        private static final java.lang.String ERROR_COLORS_KEY
        See Also:
        Constant Field Values
      • UNDERLINE_COLORS_KEY

        private static final java.lang.String UNDERLINE_COLORS_KEY
        See Also:
        Constant Field Values
      • CONFIGURABLE_RULE_VALUES_KEY

        private static final java.lang.String CONFIGURABLE_RULE_VALUES_KEY
        See Also:
        Constant Field Values
      • LT_SWITCHED_OFF_KEY

        private static final java.lang.String LT_SWITCHED_OFF_KEY
        See Also:
        Constant Field Values
      • IS_MULTI_THREAD_LO_KEY

        private static final java.lang.String IS_MULTI_THREAD_LO_KEY
        See Also:
        Constant Field Values
      • EXTERNAL_RULE_DIRECTORY

        private static final java.lang.String EXTERNAL_RULE_DIRECTORY
        See Also:
        Constant Field Values
      • DO_REMOTE_CHECK_KEY

        private static final java.lang.String DO_REMOTE_CHECK_KEY
        See Also:
        Constant Field Values
      • OTHER_SERVER_URL_KEY

        private static final java.lang.String OTHER_SERVER_URL_KEY
        See Also:
        Constant Field Values
      • USE_OTHER_SERVER_KEY

        private static final java.lang.String USE_OTHER_SERVER_KEY
        See Also:
        Constant Field Values
      • COLOR_SPLITTER_REGEXP

        private static final java.lang.String COLOR_SPLITTER_REGEXP
        See Also:
        Constant Field Values
      • COLOR_SPLITTER_REGEXP_COLON

        private static final java.lang.String COLOR_SPLITTER_REGEXP_COLON
        See Also:
        Constant Field Values
      • CONFIGURABLE_RULE_SPLITTER_REGEXP

        private static final java.lang.String CONFIGURABLE_RULE_SPLITTER_REGEXP
        See Also:
        Constant Field Values
      • PROFILE_DELIMITER

        private static final java.lang.String PROFILE_DELIMITER
        See Also:
        Constant Field Values
      • configForOtherProfiles

        private final java.util.Map<java.lang.String,​java.lang.String> configForOtherProfiles
      • configForOtherLanguages

        private final java.util.Map<java.lang.String,​java.lang.String> configForOtherLanguages
      • errorColors

        private final java.util.Map<org.languagetool.rules.ITSIssueType,​java.awt.Color> errorColors
      • underlineColors

        private final java.util.Map<java.lang.String,​java.awt.Color> underlineColors
      • configurableRuleValues

        private final java.util.Map<java.lang.String,​java.lang.Integer> configurableRuleValues
      • styleLikeCategories

        private final java.util.Set<java.lang.String> styleLikeCategories
      • specialTabCategories

        private final java.util.Map<java.lang.String,​java.lang.String> specialTabCategories
      • disabledRuleIds

        private java.util.Set<java.lang.String> disabledRuleIds
      • enabledRuleIds

        private java.util.Set<java.lang.String> enabledRuleIds
      • disabledCategoryNames

        private java.util.Set<java.lang.String> disabledCategoryNames
      • enabledCategoryNames

        private java.util.Set<java.lang.String> enabledCategoryNames
      • definedProfiles

        private java.util.List<java.lang.String> definedProfiles
      • allProfileKeys

        private java.util.List<java.lang.String> allProfileKeys
      • allProfileLangKeys

        private java.util.List<java.lang.String> allProfileLangKeys
      • lang

        private org.languagetool.Language lang
      • configFile

        private java.io.File configFile
      • oldConfigFile

        private java.io.File oldConfigFile
      • enabledRulesOnly

        private boolean enabledRulesOnly
      • language

        private org.languagetool.Language language
      • motherTongue

        private org.languagetool.Language motherTongue
      • ngramDirectory

        private java.io.File ngramDirectory
      • word2vecDirectory

        private java.io.File word2vecDirectory
      • runServer

        private boolean runServer
      • autoDetect

        private boolean autoDetect
      • taggerShowsDisambigLog

        private boolean taggerShowsDisambigLog
      • guiConfig

        private boolean guiConfig
      • fontName

        private java.lang.String fontName
      • fontStyle

        private int fontStyle
      • fontSize

        private int fontSize
      • serverPort

        private int serverPort
      • numParasToCheck

        private int numParasToCheck
      • doResetCheck

        private boolean doResetCheck
      • noMultiReset

        private boolean noMultiReset
      • doFullCheckAtFirst

        private boolean doFullCheckAtFirst
      • externalRuleDirectory

        private java.lang.String externalRuleDirectory
      • lookAndFeelName

        private java.lang.String lookAndFeelName
      • switchOff

        private boolean switchOff
      • useDocLanguage

        private boolean useDocLanguage
      • isMultiThreadLO

        private boolean isMultiThreadLO
      • currentProfile

        private java.lang.String currentProfile
      • doRemoteCheck

        private boolean doRemoteCheck
      • useOtherServer

        private boolean useOtherServer
      • otherServerUrl

        private java.lang.String otherServerUrl
    • Constructor Detail

      • Configuration

        public Configuration​(org.languagetool.Language lang)
                      throws java.io.IOException
        Uses the configuration file from the default location.
        Parameters:
        lang - The language for the configuration, used to distinguish rules that are enabled or disabled per language.
        Throws:
        java.io.IOException
      • Configuration

        public Configuration​(java.io.File baseDir,
                             org.languagetool.Language lang)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • Configuration

        public Configuration​(java.io.File baseDir,
                             java.lang.String filename,
                             org.languagetool.Language lang)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • Configuration

        public Configuration​(java.io.File baseDir,
                             java.lang.String filename,
                             org.languagetool.Language lang,
                             org.languagetool.LinguServices linguServices)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • Configuration

        public Configuration​(java.io.File baseDir,
                             java.lang.String filename,
                             java.io.File oldConfigFile,
                             org.languagetool.Language lang,
                             org.languagetool.LinguServices linguServices)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • Configuration

        private Configuration()
    • Method Detail

      • initOptions

        public void initOptions()
        Initialize variables and clears Maps, Sets and Lists
      • copy

        Configuration copy​(Configuration configuration)
        Returns a copy of the given configuration.
        Parameters:
        configuration - the object to copy.
        Since:
        2.6
      • restoreState

        void restoreState​(Configuration configuration)
        Restore the state of this object from configuration.
        Parameters:
        configuration - the object from which we will read the state
        Since:
        2.6
      • getDisabledRuleIds

        public java.util.Set<java.lang.String> getDisabledRuleIds()
      • getEnabledRuleIds

        public java.util.Set<java.lang.String> getEnabledRuleIds()
      • getDisabledCategoryNames

        public java.util.Set<java.lang.String> getDisabledCategoryNames()
      • getEnabledCategoryNames

        public java.util.Set<java.lang.String> getEnabledCategoryNames()
      • setDisabledRuleIds

        public void setDisabledRuleIds​(java.util.Set<java.lang.String> ruleIds)
      • addDisabledRuleIds

        public void addDisabledRuleIds​(java.util.Set<java.lang.String> ruleIds)
      • removeDisabledRuleIds

        public void removeDisabledRuleIds​(java.util.Set<java.lang.String> ruleIds)
      • setEnabledRuleIds

        public void setEnabledRuleIds​(java.util.Set<java.lang.String> ruleIds)
      • setDisabledCategoryNames

        public void setDisabledCategoryNames​(java.util.Set<java.lang.String> categoryNames)
      • setEnabledCategoryNames

        public void setEnabledCategoryNames​(java.util.Set<java.lang.String> categoryNames)
      • getEnabledRulesOnly

        public boolean getEnabledRulesOnly()
      • getLanguage

        public org.languagetool.Language getLanguage()
      • setLanguage

        public void setLanguage​(org.languagetool.Language language)
      • getMotherTongue

        public org.languagetool.Language getMotherTongue()
      • setMotherTongue

        public void setMotherTongue​(org.languagetool.Language motherTongue)
      • getDefaultLanguage

        public org.languagetool.Language getDefaultLanguage()
      • setUseDocLanguage

        public void setUseDocLanguage​(boolean useDocLang)
      • getUseDocLanguage

        public boolean getUseDocLanguage()
      • getAutoDetect

        public boolean getAutoDetect()
      • setAutoDetect

        public void setAutoDetect​(boolean autoDetect)
      • setRemoteCheck

        public void setRemoteCheck​(boolean doRemoteCheck)
      • doRemoteCheck

        public boolean doRemoteCheck()
      • setUseOtherServer

        public void setUseOtherServer​(boolean useOtherServer)
      • useOtherServer

        public boolean useOtherServer()
      • setOtherServerUrl

        public void setOtherServerUrl​(java.lang.String otherServerUrl)
      • getServerUrl

        public java.lang.String getServerUrl()
      • getTaggerShowsDisambigLog

        public boolean getTaggerShowsDisambigLog()
        Determines whether the tagger window will also print the disambiguation log.
        Returns:
        true if the tagger window will print the disambiguation log, false otherwise
        Since:
        3.3
      • setTaggerShowsDisambigLog

        public void setTaggerShowsDisambigLog​(boolean taggerShowsDisambigLog)
        Enables or disables the disambiguation log on the tagger window, depending on the value of the parameter taggerShowsDisambigLog.
        Parameters:
        taggerShowsDisambigLog - If true, the tagger window will print the
        Since:
        3.3
      • getRunServer

        public boolean getRunServer()
      • setRunServer

        public void setRunServer​(boolean runServer)
      • getServerPort

        public int getServerPort()
      • setUseGUIConfig

        public void setUseGUIConfig​(boolean useGUIConfig)
      • getUseGUIConfig

        public boolean getUseGUIConfig()
      • setServerPort

        public void setServerPort​(int serverPort)
      • getExternalRuleDirectory

        public java.lang.String getExternalRuleDirectory()
      • setExternalRuleDirectory

        public void setExternalRuleDirectory​(java.lang.String path)
      • getNumParasToCheck

        public int getNumParasToCheck()
        get the number of paragraphs to be checked for TextLevelRules
        Since:
        4.0
      • setNumParasToCheck

        public void setNumParasToCheck​(int numParas)
        set the number of paragraphs to be checked for TextLevelRules
        Since:
        4.0
      • isResetCheck

        public boolean isResetCheck()
        will all paragraphs check after every change of text?
        Since:
        4.2
      • setDoResetCheck

        public void setDoResetCheck​(boolean resetCheck)
        set all paragraphs to be checked after every change of text
        Since:
        4.2
      • isNoMultiReset

        public boolean isNoMultiReset()
        will all paragraphs not checked after every change of text if more than one document loaded?
        Since:
        4.5
      • setNoMultiReset

        public void setNoMultiReset​(boolean noMultiReset)
        set all paragraphs to be not checked after every change of text if more than one document loaded?
        Since:
        4.5
      • setFullCheckAtFirst

        public void setFullCheckAtFirst​(boolean doFullCheckAtFirst)
        set option to do a full check at first iteration
        Since:
        4.7
      • doFullCheckAtFirst

        public boolean doFullCheckAtFirst()
        do a full check at first iteration?
        Since:
        4.7
      • getCurrentProfile

        public java.lang.String getCurrentProfile()
        get the current profile
        Since:
        4.7
      • setCurrentProfile

        public void setCurrentProfile​(java.lang.String profile)
        set the current profile
        Since:
        4.7
      • getDefinedProfiles

        public java.util.List<java.lang.String> getDefinedProfiles()
        get the current profile
        Since:
        4.7
      • addProfile

        public void addProfile​(java.lang.String profile)
        add a new profile
        Since:
        4.7
      • addProfiles

        public void addProfiles​(java.util.List<java.lang.String> profiles)
        add a list of profiles
        Since:
        4.7
      • removeProfile

        public void removeProfile​(java.lang.String profile)
        remove an existing profile
        Since:
        4.7
      • setMultiThreadLO

        public void setMultiThreadLO​(boolean isMultiThread)
        run LO in multi thread mode
        Since:
        4.6
      • isMultiThread

        public boolean isMultiThread()
        shall LO run in multi thread mode
        Since:
        4.6
      • getFontName

        public java.lang.String getFontName()
        Returns the name of the GUI's editing textarea font.
        Returns:
        the name of the font.
        Since:
        2.6
        See Also:
        Font.getFamily()
      • setFontName

        public void setFontName​(java.lang.String fontName)
        Sets the name of the GUI's editing textarea font.
        Parameters:
        fontName - the name of the font.
        Since:
        2.6
        See Also:
        Font.getFamily()
      • getFontStyle

        public int getFontStyle()
        Returns the style of the GUI's editing textarea font.
        Returns:
        the style of the font.
        Since:
        2.6
        See Also:
        Font.getStyle()
      • setFontStyle

        public void setFontStyle​(int fontStyle)
        Sets the style of the GUI's editing textarea font.
        Parameters:
        fontStyle - the style of the font.
        Since:
        2.6
        See Also:
        Font.getStyle()
      • getFontSize

        public int getFontSize()
        Returns the size of the GUI's editing textarea font.
        Returns:
        the size of the font.
        Since:
        2.6
        See Also:
        Font.getSize()
      • setFontSize

        public void setFontSize​(int fontSize)
        Sets the size of the GUI's editing textarea font.
        Parameters:
        fontSize - the size of the font.
        Since:
        2.6
        See Also:
        Font.getSize()
      • getLookAndFeelName

        public java.lang.String getLookAndFeelName()
        Returns the name of the GUI's LaF.
        Returns:
        the name of the LaF.
        Since:
        2.6
        See Also:
        UIManager.LookAndFeelInfo.getName()
      • setLookAndFeelName

        public void setLookAndFeelName​(java.lang.String lookAndFeelName)
        Sets the name of the GUI's LaF.
        Parameters:
        lookAndFeelName - the name of the LaF.
        Since:
        2.6 @see
        See Also:
        UIManager.LookAndFeelInfo.getName()
      • getNgramDirectory

        @Nullable
        public @Nullable java.io.File getNgramDirectory()
        Directory with ngram data or null.
        Since:
        3.0
      • setNgramDirectory

        public void setNgramDirectory​(java.io.File dir)
        Sets the directory with ngram data (may be null).
        Since:
        3.0
      • getWord2VecDirectory

        @Nullable
        public @Nullable java.io.File getWord2VecDirectory()
        Directory with word2vec data or null.
        Since:
        4.0
      • setWord2VecDirectory

        public void setWord2VecDirectory​(java.io.File dir)
        Sets the directory with word2vec data (may be null).
        Since:
        4.0
      • getErrorColors

        public java.util.Map<org.languagetool.rules.ITSIssueType,​java.awt.Color> getErrorColors()
        Since:
        2.8
      • isStyleCategory

        public boolean isStyleCategory​(java.lang.String category)
        Since:
        4.3 Returns true if category is style like
      • initStyleCategories

        public void initStyleCategories​(java.util.List<org.languagetool.rules.Rule> allRules)
        Since:
        4.4 Initialize set of style like categories
      • isSpecialTabCategory

        public boolean isSpecialTabCategory​(java.lang.String category)
        Since:
        4.3 Returns true if category is a special Tab category
      • isInSpecialTab

        public boolean isInSpecialTab​(java.lang.String category,
                                      java.lang.String tabName)
        Since:
        4.3 Returns true if category is member of named special Tab
      • getSpecialTabNames

        public java.lang.String[] getSpecialTabNames()
        Since:
        4.3 Returns all special tab names
      • getSpecialTabCategories

        public java.util.Set<java.lang.String> getSpecialTabCategories​(java.lang.String tabName)
        Since:
        4.3 Returns all categories for a named special tab
      • getUnderlineColors

        public java.util.Map<java.lang.String,​java.awt.Color> getUnderlineColors()
        Since:
        4.2
      • getUnderlineColor

        public java.awt.Color getUnderlineColor​(java.lang.String category)
        Since:
        4.2 Get the color to underline a rule match by the Name of its category
      • setUnderlineColor

        public void setUnderlineColor​(java.lang.String category,
                                      java.awt.Color col)
        Since:
        4.2 Set the color to underline a rule match for its category
      • setDefaultUnderlineColor

        public void setDefaultUnderlineColor​(java.lang.String category)
        Since:
        4.2 Set the color back to default (removes category from map)
      • getConfigurableValues

        public java.util.Map<java.lang.String,​java.lang.Integer> getConfigurableValues()
        returns all configured values
        Since:
        4.2
      • getConfigurableValue

        public int getConfigurableValue​(java.lang.String ruleID)
        Since:
        4.2 Get the configurable value of a rule by ruleID returns -1 if no value is set by configuration
      • setConfigurableValue

        public void setConfigurableValue​(java.lang.String ruleID,
                                         int value)
        Since:
        4.2 Set the value for a rule with ruleID
      • isSwitchedOff

        public boolean isSwitchedOff()
        Since:
        4.4 if true: LT is switched Off, else: LT is switched On
      • setSwitchedOff

        public void setSwitchedOff​(boolean switchOff,
                                   org.languagetool.Language lang)
                            throws java.io.IOException
        Throws:
        java.io.IOException
        Since:
        4.4 Set LT is switched Off or On save configuration
      • loadConfiguration

        private void loadConfiguration()
                                throws java.io.IOException
        Throws:
        java.io.IOException
      • loadConfiguration

        public void loadConfiguration​(java.lang.String profile)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • parseErrorColors

        private void parseErrorColors​(java.lang.String colorsString)
      • parseUnderlineColors

        private void parseUnderlineColors​(java.lang.String colorsString)
      • parseConfigurableRuleValues

        private void parseConfigurableRuleValues​(java.lang.String rulesValueString)
      • getQualifier

        private java.lang.String getQualifier​(org.languagetool.Language lang)
      • loadConfigForOtherLanguages

        private void loadConfigForOtherLanguages​(org.languagetool.Language lang,
                                                 java.util.Properties prop,
                                                 java.lang.String prefix)
      • storeConfigKeyFromProp

        private void storeConfigKeyFromProp​(java.util.Properties prop,
                                            java.lang.String key)
      • getListFromProperties

        private java.util.Collection<? extends java.lang.String> getListFromProperties​(java.util.Properties props,
                                                                                       java.lang.String key)
      • saveConfiguration

        public void saveConfiguration​(org.languagetool.Language lang)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • addListToProperties

        private void addListToProperties​(java.util.Properties props,
                                         java.lang.String key,
                                         java.util.Set<java.lang.String> list)
      • setAllProfileKeys

        private void setAllProfileKeys()
      • storeConfigforAllProfiles

        private void storeConfigforAllProfiles​(java.util.Properties props)
      • saveConfigforProfile

        private void saveConfigforProfile​(java.util.Properties props,
                                          java.lang.String prefix)