Package com.e1c.langtool.storage.model
Class StorageSettingsUtils
java.lang.Object
com.e1c.langtool.storage.model.StorageSettingsUtils
The utility class for the
model settings.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final StorageIDstatic final Stringstatic final StringThe Constant FEATURE_FILTER_CAMELCASE.static final StringThe Constant FEATURE_FILTER_ID.static final StringThe Constant FEATURE_FILTER_INTERFACE.static final StringThe Constant FEATURE_FILTER_MODEL.static final StringThe Constant FEATURE_FILTER_MULTILINE.static final StringThe Constant FEATURE_FILTER_PREFERCONTEXT.static final StringThe Constant FEATURE_FILTER_TAGS.static final StringThe Constant FEATURE_FILTER_UNIQUE.static final StringThe Constant RULE_WHEN_FEATURE_KEY_REGEX.static final StringThe Constant RULE_WHEN_LANGUAGE_CODE.static final StringThe Constant RULE_WHEN_RESOURCE_PATH_REGEX.static final StringThe Constant RULE_WHEN_VALUE_REGEX.static final booleanThe Constant SETTINGS_DEFAULT_KEY_CASE_SENSITIVE.static final intThe Constant SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS.static final StringThe Constant SETTINGS_DEFAULT_REPLACE_FILE_NAME.static final booleanThe Constant SETTINGS_DEFAULT_VALUE_CASE_SENSITIVE.static final StringThe Constant SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_POSTFIX.static final StringThe Constant SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_PREFIX.static final booleanThe Constant SETTINGS_DEFAULT_VALUE_UNIQUE.static final StringThe Constant SETTINGS_KEY_CASE_SENSITIVE.static final StringThe Constant SETTINGS_MAX_CONTEXT_FOLDERS.static final StringThe Constant SETTINGS_REPLACE_FILE_NAME.static final StringThe Constant SETTINGS_VALUE_CASE_SENSITIVE.static final StringThe Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX.static final StringThe Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFFIX.static final StringThe Constant SETTINGS_VALUE_UNIQUE. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendFeatureSettingsByStorage(CommonFeatureSettings.Builder builder, StorageSettings settings) Append feature settings by storage feature filter setting.static booleancanStoreByRule(RuleSettings rule, ContextTranslationKey key, TranslateLanguage language) Check that key can store in storage by rule.static booleancanStoreFeature(StorageSettings settings, FeatureSettings featureSettings) Can store feature.static booleancanStoreFeature(Map<String, FeatureSettingsFilter> featureFilter, FeatureSettings featureSettings) Can store feature.static org.yaml.snakeyaml.YamlCreates the new yaml object for dumping the settings model.static org.yaml.snakeyaml.YamlCreates the new yaml to load settings model.static org.yaml.snakeyaml.constructor.ConstructorCreates the new settings constructor.static org.yaml.snakeyaml.YamlcreateNewValidatingYaml(List<Pair<org.yaml.snakeyaml.nodes.Node, Object>> mapping) Creates the new yaml to validate the settings model.static booleangetBooleanSettings(StorageSettings settings, String key, boolean defaultValue) Gets the boolean from the storage settings.static intgetIntSettings(ContextStorageSettings settings, String key, int defaultValue) Gets the integer from the storage settings.static StringgetStringSettings(StorageSettings settings, String key, String defaultValue) Gets the string form the storage settings.static ProjectStorageSettingsloadStorageSettings(org.eclipse.core.resources.IFile file) Load storage settings from file.static voidsaveStorageSettings(ProjectStorageSettings settings, org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor) Save storage settings to file.static voidvalidateStorageSettings(org.eclipse.core.resources.IFile file, org.eclipse.core.runtime.IProgressMonitor monitor) Validate storage settings.
-
Field Details
-
EDIT_PROVIDER_ID
- See Also:
-
EDIT_DEFAULT_SEGMENT
- See Also:
-
EDIT_DEFAULT_STORAGE_ID
-
FEATURE_FILTER_CAMELCASE
The Constant FEATURE_FILTER_CAMELCASE.- See Also:
-
FEATURE_FILTER_ID
The Constant FEATURE_FILTER_ID.- See Also:
-
FEATURE_FILTER_INTERFACE
The Constant FEATURE_FILTER_INTERFACE.- See Also:
-
FEATURE_FILTER_MULTILINE
The Constant FEATURE_FILTER_MULTILINE.- See Also:
-
FEATURE_FILTER_MODEL
The Constant FEATURE_FILTER_MODEL.- See Also:
-
FEATURE_FILTER_PREFERCONTEXT
The Constant FEATURE_FILTER_PREFERCONTEXT.- See Also:
-
FEATURE_FILTER_UNIQUE
The Constant FEATURE_FILTER_UNIQUE.- See Also:
-
FEATURE_FILTER_TAGS
The Constant FEATURE_FILTER_TAGS.- See Also:
-
RULE_WHEN_LANGUAGE_CODE
The Constant RULE_WHEN_LANGUAGE_CODE.- See Also:
-
RULE_WHEN_FEATURE_KEY_REGEX
The Constant RULE_WHEN_FEATURE_KEY_REGEX.- See Also:
-
RULE_WHEN_RESOURCE_PATH_REGEX
The Constant RULE_WHEN_RESOURCE_PATH_REGEX.- See Also:
-
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_SENSITIVEThe Constant SETTINGS_DEFAULT_KEY_CASE_SENSITIVE.- See Also:
-
SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS
public static final int SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERSThe Constant SETTINGS_DEFAULT_MAX_CONTEXT_FOLDERS.- See Also:
-
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_SENSITIVEThe Constant SETTINGS_DEFAULT_VALUE_CASE_SENSITIVE.- See Also:
-
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
The Constant SETTINGS_DEFAULT_VALUE_NON_GLOBAL_UNIQUE_PREFIX.- See Also:
-
SETTINGS_DEFAULT_VALUE_UNIQUE
public static final boolean SETTINGS_DEFAULT_VALUE_UNIQUEThe Constant SETTINGS_DEFAULT_VALUE_UNIQUE.- See Also:
-
SETTINGS_KEY_CASE_SENSITIVE
The Constant SETTINGS_KEY_CASE_SENSITIVE.- See Also:
-
SETTINGS_MAX_CONTEXT_FOLDERS
The Constant SETTINGS_MAX_CONTEXT_FOLDERS.- See Also:
-
SETTINGS_REPLACE_FILE_NAME
The Constant SETTINGS_REPLACE_FILE_NAME.- See Also:
-
SETTINGS_VALUE_CASE_SENSITIVE
The Constant SETTINGS_VALUE_CASE_SENSITIVE.- See Also:
-
SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX
The Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_POSTFIX.- See Also:
-
SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFIX
The Constant SETTINGS_VALUE_NON_GLOBAL_UNIQUE_PREFFIX.- See Also:
-
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 benull.key- the key, cannot benull.language- the language, cannot benull.- 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 benull.featureSettings- the feature settings, cannot benull.- Returns:
- true, if successful
-
canStoreFeature
Can store feature.- Parameters:
settings- the settings, cannot benull.featureSettings- the feature settings, cannot benull.- 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 benull.- 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 benull.key- the key, cannot benull.defaultValue- the default value- Returns:
- the boolean from storage settings or default value,
-
getIntSettings
Gets the integer from the storage settings.- Parameters:
settings- the settings, cannot benull.key- the key, cannot benull.defaultValue- the default value- Returns:
- the integer from the storage settings or default value
-
getStringSettings
Gets the string form the storage settings.- Parameters:
settings- the settings, cannot benull.key- the key, cannot benull.defaultValue- the default value- Returns:
- the string from storage settings or default value if it is null or empty
-
loadStorageSettings
Load storage settings from file.- Parameters:
file- the file, cannot benull.- Returns:
- the project storage settings, can return
nullif 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 benull.file- the file, cannot benull.monitor- the monitor, cannot benull.
-
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 returnnull.monitor- the monitor, cannot returnnull.
-
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 benull.settings- the storage settings, cannot benull.
-