Package org.ametys.runtime.model
Class ItemParserHelper
java.lang.Object
org.ametys.runtime.model.ItemParserHelper
Helper for all
ModelItem parsers-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordStores a configuration and the name of the plugin in which is declared the configurationstatic interfaceDefault value parser -
Method Summary
Modifier and TypeMethodDescriptionstatic ObjectparseDefaultValue(Configuration defaultValueConfig, ElementDefinition definition, String defaultValueType) Parses the default value.parseDefaultValues(Configuration itemConfig, ElementDefinition definition, ItemParserHelper.DefaultValueParser defaultValueParser) Parses the default values.static I18nizableTextparseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name) Parse an i18n text.static I18nizableTextparseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name, String defaultValue) Parse an i18n text.static I18nizableTextparseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name, I18nizableText defaultValue) Parse an i18n text.static BooleanparseMultiple(Configuration itemConfig) Parses the multiple attribute.static StringparseName(Configuration itemConfig, String nameConfigurationAttribute) Parses the name of the model itemstatic StringparseName(Configuration itemConfig, String nameConfigurationAttribute, boolean acceptDots) Parses the name of the model itemstatic StringparseWidget(Configuration itemConfig) Parses the widget.static Map<String, I18nizableText> parseWidgetParameters(Configuration itemConfig, String pluginName) Parses the widget's parameters
-
Method Details
-
parseName
public static String parseName(Configuration itemConfig, String nameConfigurationAttribute) throws ConfigurationException Parses the name of the model item- Parameters:
itemConfig- the model item's configuration to parsenameConfigurationAttribute- the name of the attribute containing the item's name- Returns:
- the name of the model item
- Throws:
ConfigurationException- if an error occurs
-
parseName
public static String parseName(Configuration itemConfig, String nameConfigurationAttribute, boolean acceptDots) throws ConfigurationException Parses the name of the model item- Parameters:
itemConfig- the model item's configuration to parsenameConfigurationAttribute- the name of the attribute containing the item's nameacceptDots-trueif the name to parse can contain dots,falseotherwise- Returns:
- the name of the model item
- Throws:
ConfigurationException- if an error occurs
-
parseMultiple
Parses the multiple attribute.- Parameters:
itemConfig- the item configuration to use.- Returns:
trueif the item is multiple,falseotherwise.- Throws:
ConfigurationException- if the configuration is not valid.
-
parseDefaultValues
public static List<Pair<String,Object>> parseDefaultValues(Configuration itemConfig, ElementDefinition definition, ItemParserHelper.DefaultValueParser defaultValueParser) throws ConfigurationException Parses the default values.- Parameters:
itemConfig- the item configuration.definition- the element definition.defaultValueParser- TheItemParserHelper.DefaultValueParserto use to parse single default values- Returns:
- the default values and their types or
nullif none default value is defined. - Throws:
ConfigurationException- if the configuration is not valid.
-
parseDefaultValue
public static Object parseDefaultValue(Configuration defaultValueConfig, ElementDefinition definition, String defaultValueType) throws ConfigurationException Parses the default value.- Parameters:
defaultValueConfig- the default value configuration.definition- the element definition.defaultValueType- the type of the default value- Returns:
- the default value or
nullif none default value is defined. - Throws:
ConfigurationException- if the configuration is not valid.
-
parseWidget
Parses the widget.- Parameters:
itemConfig- the item configuration to use.- Returns:
- the widget or
nullif none defined. - Throws:
ConfigurationException- if the configuration is not valid.
-
parseWidgetParameters
public static Map<String,I18nizableText> parseWidgetParameters(Configuration itemConfig, String pluginName) throws ConfigurationException Parses the widget's parameters- Parameters:
itemConfig- the item configuration to use.pluginName- the current plugin name.- Returns:
- the widget's parameters in a Map
- Throws:
ConfigurationException- if the configuration is not valid.
-
parseI18nizableText
public static I18nizableText parseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name) throws ConfigurationException Parse an i18n text.- Parameters:
configurationAndPluginName- the configuration to use.name- the child name.- Returns:
- the i18n text.
- Throws:
ConfigurationException- if the configuration is not valid.
-
parseI18nizableText
public static I18nizableText parseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name, String defaultValue) throws ConfigurationException Parse an i18n text.- Parameters:
configurationAndPluginName- the configuration to use.name- the child name.defaultValue- the default value if no present- Returns:
- the i18n text.
- Throws:
ConfigurationException- if the configuration is not valid.
-
parseI18nizableText
public static I18nizableText parseI18nizableText(ItemParserHelper.ConfigurationAndPluginName configurationAndPluginName, String name, I18nizableText defaultValue) throws ConfigurationException Parse an i18n text.- Parameters:
configurationAndPluginName- the configuration to use.name- the child name.defaultValue- the default value if no present- Returns:
- the i18n text.
- Throws:
ConfigurationException- if the configuration is not valid.
-