Package org.ametys.runtime.model
Class AbstractModelItemParser
java.lang.Object
org.ametys.runtime.model.AbstractModelItemParser
- Direct Known Subclasses:
CompositeDefinitionParser
,ElementDefinitionParser
,RepeaterDefinitionParser
ModelItem
parser from an XML configuration.-
Field Summary
Modifier and TypeFieldDescriptionprotected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType>
The extension point to use to get available model items types -
Constructor Summary
ConstructorDescriptionAbstractModelItemParser
(AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> modelItemTypeExtensionPoint) Creates a model item parser. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ModelItem
_createModelItem
(Configuration itemConfig) Create the model item to populate it.protected String
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 Details
-
_modelItemTypeExtensionPoint
protected AbstractThreadSafeComponentExtensionPoint<? extends ModelItemType> _modelItemTypeExtensionPointThe extension point to use to get available model items types
-
-
Constructor Details
-
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 Details
-
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
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
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
Parses the type.- Parameters:
config
- the model item configuration to use.- Returns:
- the type.
- Throws:
ConfigurationException
- if the configuration is not valid.
-