Class StorageSettingsUtils

java.lang.Object
com.e1c.langtool.storage.model.StorageSettingsUtils

public class StorageSettingsUtils extends Object
The utility class for the model settings.
  • Field Details

    • EDIT_PROVIDER_ID

      public static final String EDIT_PROVIDER_ID
      See Also:
    • EDIT_DEFAULT_SEGMENT

      public static final String EDIT_DEFAULT_SEGMENT
      See Also:
    • EDIT_DEFAULT_STORAGE_ID

      public static final StorageID EDIT_DEFAULT_STORAGE_ID
    • FEATURE_FILTER_CAMELCASE

      public static final String FEATURE_FILTER_CAMELCASE
      The Constant FEATURE_FILTER_CAMELCASE.
      See Also:
    • FEATURE_FILTER_ID

      public static final String FEATURE_FILTER_ID
      The Constant FEATURE_FILTER_ID.
      See Also:
    • FEATURE_FILTER_INTERFACE

      public static final String FEATURE_FILTER_INTERFACE
      The Constant FEATURE_FILTER_INTERFACE.
      See Also:
    • FEATURE_FILTER_MULTILINE

      public static final String FEATURE_FILTER_MULTILINE
      The Constant FEATURE_FILTER_MULTILINE.
      See Also:
    • FEATURE_FILTER_MODEL

      public static final String FEATURE_FILTER_MODEL
      The Constant FEATURE_FILTER_MODEL.
      See Also:
    • FEATURE_FILTER_PREFERCONTEXT

      public static final String FEATURE_FILTER_PREFERCONTEXT
      The Constant FEATURE_FILTER_PREFERCONTEXT.
      See Also:
    • FEATURE_FILTER_UNIQUE

      public static final String FEATURE_FILTER_UNIQUE
      The Constant FEATURE_FILTER_UNIQUE.
      See Also:
    • FEATURE_FILTER_TAGS

      public static final String FEATURE_FILTER_TAGS
      The Constant FEATURE_FILTER_TAGS.
      See Also:
    • RULE_WHEN_LANGUAGE_CODE

      public static final String RULE_WHEN_LANGUAGE_CODE
      The Constant RULE_WHEN_LANGUAGE_CODE.
      See Also:
    • RULE_WHEN_FEATURE_KEY_REGEX

      public static final String RULE_WHEN_FEATURE_KEY_REGEX
      The Constant RULE_WHEN_FEATURE_KEY_REGEX.
      See Also:
    • RULE_WHEN_RESOURCE_PATH_REGEX

      public static final String RULE_WHEN_RESOURCE_PATH_REGEX
      The Constant RULE_WHEN_RESOURCE_PATH_REGEX.
      See Also:
    • RULE_WHEN_VALUE_REGEX

      public static final String RULE_WHEN_VALUE_REGEX
      The Constant RULE_WHEN_VALUE_REGEX.
      See Also:
    • SETTINGS_DEFAULT_KEY_CASE_SENSITIVE

      public static final boolean SETTINGS_DEFAULT_KEY_CASE_SENSITIVE
      The Constant SETTINGS_DEFAULT_KEY_CASE_SENSITIVE.
      See Also:
    • SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS

      public static final int SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS
      The Constant SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS.
      See Also:
    • SETTINGS_DEFAULT_REPLACE_FILE_NAME

      public static final String SETTINGS_DEFAULT_REPLACE_FILE_NAME
      The Constant SETTINGS_DEFAULT_REPLACE_FILE_NAME.
      See Also:
    • SETTINGS_DEFAULT_VALUE_CASE_SENSITIVE

      public static final boolean SETTINGS_DEFAULT_VALUE_CASE_SENSITIVE
      The Constant SETTINGS_DEFAULT_VALUE_CASE_SENSITIVE.
      See Also:
    • SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_POSTFIX

      public static final String SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_POSTFIX
      The Constant SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_POSTFIX.
      See Also:
    • SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_PREFIX

      public static final String SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_PREFIX
      The Constant SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_PREFIX.
      See Also:
    • SETTINGS_DEFAULT_VALUE_UNIQUE

      public static final boolean SETTINGS_DEFAULT_VALUE_UNIQUE
      The Constant SETTINGS_DEFAULT_VALUE_UNIQUE.
      See Also:
    • SETTINGS_KEY_CASE_SENSITIVE

      public static final String SETTINGS_KEY_CASE_SENSITIVE
      The Constant SETTINGS_KEY_CASE_SENSITIVE.
      See Also:
    • SETTINGS_MAX_CONTEXT_FOLDERS

      public static final String SETTINGS_MAX_CONTEXT_FOLDERS
      The Constant SETTINGS_MAX_CONTEXT_FOLDERS.
      See Also:
    • SETTINGS_REPLACE_FILE_NAME

      public static final String SETTINGS_REPLACE_FILE_NAME
      The Constant SETTINGS_REPLACE_FILE_NAME.
      See Also:
    • SETTINGS_VALUE_CASE_SENSITIVE

      public static final String SETTINGS_VALUE_CASE_SENSITIVE
      The Constant SETTINGS_VALUE_CASE_SENSITIVE.
      See Also:
    • SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX

      public static final String SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX
      The Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX.
      See Also:
    • SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFIX

      public static final String SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFIX
      The Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFFIX.
      See Also:
    • SETTINGS_VALUE_UNIQUE

      public static final String SETTINGS_VALUE_UNIQUE
      The Constant SETTINGS_VALUE_UNIQUE.
      See Also:
  • Method Details

    • canStoreByRule

      public static boolean canStoreByRule(RuleSettings rule, ContextTranslationKey key, TranslateLanguage language)
      Check that key can store in storage by rule.
      Parameters:
      rule - the rule, cannot be null.
      key - the key, cannot be null.
      language - the language, cannot be null.
      Returns:
      true, if the key can store in storage by given rule
    • canStoreFeature

      public static boolean canStoreFeature(Map<String,FeatureSettingsFilter> featureFilter, FeatureSettings featureSettings)
      Can store feature.
      Parameters:
      featureFilter - the feature filter, cannot be null.
      featureSettings - the feature settings, cannot be null.
      Returns:
      true, if successful
    • canStoreFeature

      public static boolean canStoreFeature(StorageSettings settings, FeatureSettings featureSettings)
      Can store feature.
      Parameters:
      settings - the settings, cannot be null.
      featureSettings - the feature settings, cannot be null.
      Returns:
      true, if successful
    • createNewDumpYaml

      public static org.yaml.snakeyaml.Yaml createNewDumpYaml()
      Creates the new yaml object for dumping the settings model.
      Returns:
      the yaml, cannot return null.
    • createNewLoadYaml

      public static org.yaml.snakeyaml.Yaml createNewLoadYaml()
      Creates the new yaml to load settings model.
      Returns:
      the yaml, cannot return null.
    • createNewSettingsConstructor

      public static org.yaml.snakeyaml.constructor.Constructor createNewSettingsConstructor()
      Creates the new settings constructor.
      Returns:
      the constructor, cannot return null.
    • createNewValidatingYaml

      public static org.yaml.snakeyaml.Yaml createNewValidatingYaml(List<Pair<org.yaml.snakeyaml.nodes.Node,Object>> mapping)
      Creates the new yaml to validate the settings model.
      Parameters:
      mapping - the mapping which will filled by created objects and nodes, cannot be null.
      Returns:
      the yaml, cannot return null.
    • getBooleanSettings

      public static boolean getBooleanSettings(StorageSettings settings, String key, boolean defaultValue)
      Gets the boolean from the storage settings.
      Parameters:
      settings - the storage settings, cannot be null.
      key - the key, cannot be null.
      defaultValue - the default value
      Returns:
      the boolean from storage settings or default value,
    • getIntSettings

      public static int getIntSettings(ContextStorageSettings settings, String key, int defaultValue)
      Gets the integer from the storage settings.
      Parameters:
      settings - the settings, cannot be null.
      key - the key, cannot be null.
      defaultValue - the default value
      Returns:
      the integer from the storage settings or default value
    • getStringSettings

      public static String getStringSettings(StorageSettings settings, String key, String defaultValue)
      Gets the string form the storage settings.
      Parameters:
      settings - the settings, cannot be null.
      key - the key, cannot be null.
      defaultValue - the default value
      Returns:
      the string from storage settings or default value if it is null or empty
    • loadStorageSettings

      public static ProjectStorageSettings loadStorageSettings(org.eclipse.core.resources.IFile file)
      Load storage settings from file.
      Parameters:
      file - the file, cannot be null.
      Returns:
      the project storage settings, can return null if an error to load the model form file.
    • saveStorageSettings

      public static void saveStorageSettings(ProjectStorageSettings settings, org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor)
      Save storage settings to file.
      Parameters:
      settings - the settings, cannot be null.
      file - the file, cannot be null.
      monitor - the monitor, cannot be null.
    • validateStorageSettings

      public static void validateStorageSettings(org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor)
      Validate storage settings.
      Parameters:
      file - the file, cannot return null.
      monitor - the monitor, cannot return null.
    • appendFeatureSettingsByStorage

      public static void appendFeatureSettingsByStorage(CommonFeatureSettings.Builder builder, StorageSettings settings)
      Append feature settings by storage feature filter setting.
      Parameters:
      builder - the builder of feature settings, cannot be null.
      settings - the storage settings, cannot be null.