Package org.ametys.runtime.model
Class AbstractModelItemParser
- java.lang.Object
-
- org.ametys.runtime.model.AbstractModelItemParser
-
- Direct Known Subclasses:
CompositeDefinitionParser,ElementDefinitionParser,RepeaterDefinitionParser
public abstract class AbstractModelItemParser extends Object
ModelItemparser from an XML configuration.
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType>_modelItemTypeExtensionPointThe extension point to use to get available model items types
-
Constructor Summary
Constructors Constructor Description AbstractModelItemParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint)Creates a model item parser.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract ModelItem_createModelItem(Configuration itemConfig)Create the model item to populate it.protected String_getNameConfigurationAttribute()Retrieves the name of the configuration attribute that contains the name of the model itemprotected I18nizableText_parseI18nizableText(Configuration config, String catalog, String name)Parses a mandatory i18n text configuration, throwing an exception if empty.protected I18nizableText_parseI18nizableText(Configuration config, String catalog, String name, String defaultValueCatalog, String defaultValue)Parse an optional i18n text configuration, with a default i18n text value.protected String_parseName(Configuration itemConfig)Parses the name of the model item.protected ModelItemType_parseType(Configuration config)Parses the type.<T extends ModelItem>
Tparse(ServiceManager serviceManager, String pluginName, String catalog, Configuration itemConfig, Model model, ModelItemGroup parent)Parses an element definition from a XML configuration.<T extends ModelItem>
Tparse(ServiceManager serviceManager, String pluginName, Configuration itemConfig, Model model, ModelItemGroup parent)Parses an element definition from a XML configuration.
-
-
-
Field Detail
-
_modelItemTypeExtensionPoint
protected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> _modelItemTypeExtensionPoint
The extension point to use to get available model items types
-
-
Constructor Detail
-
AbstractModelItemParser
public AbstractModelItemParser(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint)
Creates a model item parser.- Parameters:
modelItemTypeExtensionPoint- the extension point to use to get available model items types
-
-
Method Detail
-
parse
public <T extends ModelItem> T parse(ServiceManager serviceManager, String pluginName, Configuration itemConfig, Model model, ModelItemGroup parent) throws ConfigurationException
Parses an element definition from a XML configuration.- Type Parameters:
T- type of the parsed item- Parameters:
serviceManager- the service managerpluginName- the plugin name declaring this item.itemConfig- the XML configuration of the model item.model- the model which defines the model itemparent- the parent of the model item to create. Can be null if the model item to parse has no parent- Returns:
- the parsed model item.
- Throws:
ConfigurationException- if the configuration is not valid.
-
parse
public <T extends ModelItem> T parse(ServiceManager serviceManager, String pluginName, String catalog, Configuration itemConfig, Model model, ModelItemGroup parent) throws ConfigurationException
Parses an element definition from a XML configuration.- Type Parameters:
T- type of the parsed item- Parameters:
serviceManager- the service managerpluginName- the plugin name declaring this item.catalog- the catalogitemConfig- the XML configuration of the model item.model- the model which defines the model itemparent- the parent of the model item to create. Can be null if the model item to parse has no parent- Returns:
- the parsed model item.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_createModelItem
protected abstract ModelItem _createModelItem(Configuration itemConfig) throws ConfigurationException
Create the model item to populate it.- Parameters:
itemConfig- the model item configuration to use.- Returns:
- the item instantiated.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_parseName
protected String _parseName(Configuration itemConfig) throws ConfigurationException
Parses the name of the model item.- Parameters:
itemConfig- the model item configuration to use.- Returns:
- the name of the model item.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_getNameConfigurationAttribute
protected String _getNameConfigurationAttribute()
Retrieves the name of the configuration attribute that contains the name of the model item- Returns:
- the name of the configuration attribute that contains the name of the model item
-
_parseI18nizableText
protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name) throws ConfigurationException
Parses a mandatory i18n text configuration, throwing an exception if empty.- Parameters:
config- the configuration to use.catalog- the catalogname- the child name.- Returns:
- the i18n text.
- Throws:
ConfigurationException- if the configuration is not valid.
-
_parseI18nizableText
protected I18nizableText _parseI18nizableText(Configuration config, String catalog, String name, String defaultValueCatalog, String defaultValue)
Parse an optional i18n text configuration, with a default i18n text value.- Parameters:
config- the configuration to use.catalog- the catalogname- the child name.defaultValueCatalog- the catalog of the default i18n text valuedefaultValue- the default i18n text value.- Returns:
- the i18n text.
-
_parseType
protected ModelItemType _parseType(Configuration config) throws ConfigurationException
Parses the type.- Parameters:
config- the model item configuration to use.- Returns:
- the type.
- Throws:
ConfigurationException- if the configuration is not valid.
-
-