Package cdc.impex.api
Class ImpExCatalog
- java.lang.Object
-
- cdc.impex.api.ImpExCatalog
-
public class ImpExCatalog extends Object
Catalog ofSheetTemplates andImportHandlers.- Author:
- Damien Carbonne
-
-
Constructor Summary
Constructors Constructor Description ImpExCatalog()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImportHandlercreateImportHandlerFor(ImportHandler def, String... templateNames)Creates a delegating import handler for an array of template names.ImportHandlercreateImportHandlerFor(ImportHandler def, Collection<String> templateNames)Creates a delegating import handler for a collection of template names.Set<String>getImportableTemplateNames()ImportHandlergetImportHandler(String templateName)Return The import handler associated to template name.ImportHandlergetImportHandlerOrNull(String templateName)Returns import handler associated to a template name ornull.SheetTemplategetTemplate(String templateName)Set<String>getTemplateNames()SheetTemplategetTemplateOrNull(String templateName)Set<SheetTemplate>getTemplates()Set<SheetTemplate>getTemplates(String... templateNames)Set<SheetTemplate>getTemplates(Collection<String> templateNames)ImpExCatalogregister(SheetTemplate template)Registers a SheetTemplate.ImpExCatalogregister(SheetTemplate... templates)Registers an array of SheetTemplates.ImpExCatalogregister(SheetTemplate template, ImportHandler importHandler)Registers a SheetTemplate (if not already done) and associate it to an ImportHandler.ImpExCatalogregister(String templateName, ImportHandler importHandler)Registers an ImportHandler and associate it to a template name.ImpExCatalogregister(Collection<SheetTemplate> templates)Registers a collection of SheetTemplates.
-
-
-
Method Detail
-
register
public ImpExCatalog register(SheetTemplate template)
Registers a SheetTemplate.- Parameters:
template- The sheet template.- Returns:
- This catalog.
- Throws:
IllegalArgumentException- Whentemplateisnull, or another template with that name is already registered.
-
register
public ImpExCatalog register(Collection<SheetTemplate> templates)
Registers a collection of SheetTemplates.- Parameters:
templates- The sheet templates.- Returns:
- This catalog.
- Throws:
IllegalArgumentException- Whentemplatesisnull, or another template with same name is already registered.
-
register
public ImpExCatalog register(SheetTemplate... templates)
Registers an array of SheetTemplates.- Parameters:
templates- The sheet templates.- Returns:
- This catalog.
- Throws:
IllegalArgumentException- Whentemplatesisnull, or another template with same name is already registered.
-
register
public ImpExCatalog register(String templateName, ImportHandler importHandler)
Registers an ImportHandler and associate it to a template name.- Parameters:
templateName- The template name.importHandler- The import handler.- Returns:
- This catalog.
- Throws:
IllegalArgumentException- WhentemplateNameorimportHandlerisnull,
or that would create a duplicate or no corresponding template is found.
-
register
public ImpExCatalog register(SheetTemplate template, ImportHandler importHandler)
Registers a SheetTemplate (if not already done) and associate it to an ImportHandler.- Parameters:
template- The sheet template.importHandler- The import handler.- Returns:
- This catalog.
- Throws:
IllegalArgumentException- WhentemplateorimportHandlerisnull,
or that would create a duplicate.
-
getTemplateNames
public Set<String> getTemplateNames()
- Returns:
- A set of names of registered sheet templates.
-
getTemplateOrNull
public SheetTemplate getTemplateOrNull(String templateName)
- Parameters:
templateName- The template name.- Returns:
- The registered sheet template named
nameornull.
-
getTemplate
public SheetTemplate getTemplate(String templateName)
- Parameters:
templateName- The template name.- Returns:
- The registered sheet template named
name. - Throws:
cdc.util.lang.NotFoundException- When no sheet template namedtemplateNameis registered.
-
getTemplates
public Set<SheetTemplate> getTemplates(Collection<String> templateNames)
- Parameters:
templateNames- The template names.- Returns:
- A set if templates from
templateNames. - Throws:
IllegalArgumentException- WhentemplateNamesisnull.
-
getTemplates
public Set<SheetTemplate> getTemplates(String... templateNames)
- Parameters:
templateNames- The template names.- Returns:
- A set if templates from
templateNames. - Throws:
IllegalArgumentException- WhentemplateNamesisnull.
-
getImportableTemplateNames
public Set<String> getImportableTemplateNames()
- Returns:
- A set of sheet template names for which an import handler is registered.
-
getTemplates
public Set<SheetTemplate> getTemplates()
- Returns:
- A set of all registered templates.
-
getImportHandlerOrNull
public ImportHandler getImportHandlerOrNull(String templateName)
Returns import handler associated to a template name ornull.- Parameters:
templateName- The template name.- Returns:
- The import handler associated to
templateNameornull.
-
getImportHandler
public ImportHandler getImportHandler(String templateName)
Return The import handler associated to template name.- Parameters:
templateName- The template name.- Returns:
- The import handler associated to
templateName. - Throws:
cdc.util.lang.NotFoundException- When no import handler is associated totemplateName.
-
createImportHandlerFor
public ImportHandler createImportHandlerFor(ImportHandler def, Collection<String> templateNames)
Creates a delegating import handler for a collection of template names.- Parameters:
def- The default import handler.templateNames- The template names.- Returns:
- A new created import handler.
-
createImportHandlerFor
public ImportHandler createImportHandlerFor(ImportHandler def, String... templateNames)
Creates a delegating import handler for an array of template names.- Parameters:
def- The default import handler.templateNames- The template names.- Returns:
- A new created import handler.
-
-