pl.edu.agh.cast.importer.base.template.internal
Class XmlTemplateProvider

java.lang.Object
  extended by pl.edu.agh.cast.importer.base.template.internal.XmlTemplateProvider
All Implemented Interfaces:
ITemplateProvider

public class XmlTemplateProvider
extends Object
implements ITemplateProvider

Default implementation of ITemplateProvider which reads templates from XML files.

Author:
AGH CAST Team

Constructor Summary
XmlTemplateProvider()
          Constructor.
 
Method Summary
 void exportTemplateToFile(IImportTemplate template, File file)
          Writes given template to the file.
 IImportTemplate importTemplateFromFile(File file)
          Imports template from a given file.
 Collection<ImportTemplateGroup> readTemplateGroups()
          Reads all template groups.
 Collection<IImportTemplate> readTemplates()
          Reads import templates.
 void removeTemplate(UUID templateId)
          Removes template with given id.
 void removeTemplateGroup(UUID groupId)
          Removes templates group with given id.
 void saveTemplate(IImportTemplate template)
          Saves given template.
 void saveTemplateGroup(ImportTemplateGroup group)
          Saves given template group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlTemplateProvider

public XmlTemplateProvider()
                    throws TemplateException
Constructor.

Throws:
TemplateException - when any error occurs during creating templates project
Method Detail

readTemplateGroups

public Collection<ImportTemplateGroup> readTemplateGroups()
                                                   throws TemplateException
Reads all template groups. Groups are not verified if they contain existing templates.

Specified by:
readTemplateGroups in interface ITemplateProvider
Returns:
collection of template groups, if no templates groups are defined an empty collection is returned
Throws:
TemplateException - when any error occurs during reading template groups
See Also:
ITemplateProvider.readTemplateGroups()

readTemplates

public Collection<IImportTemplate> readTemplates()
                                          throws TemplateException
Reads import templates.

Specified by:
readTemplates in interface ITemplateProvider
Returns:
collection of import templates; if no templates are defined an empty collection is returned
Throws:
TemplateException - when any error occurs during reading template
See Also:
ITemplateProvider.readTemplates()

removeTemplate

public void removeTemplate(UUID templateId)
                    throws TemplateException
Removes template with given id.

Specified by:
removeTemplate in interface ITemplateProvider
Parameters:
templateId - id of template to remove
Throws:
TemplateException - when Eclipse core error occurs
See Also:
ITemplateProvider.removeTemplate(java.util.UUID)

removeTemplateGroup

public void removeTemplateGroup(UUID groupId)
                         throws TemplateException
Removes templates group with given id.

Specified by:
removeTemplateGroup in interface ITemplateProvider
Parameters:
groupId - group id
Throws:
TemplateException - when Eclipse core error occurs
See Also:
ITemplateProvider.removeTemplateGroup(java.util.UUID)

saveTemplate

public void saveTemplate(IImportTemplate template)
                  throws TemplateException
Saves given template. If templates with given UUID already exists it will be overridden.

Specified by:
saveTemplate in interface ITemplateProvider
Parameters:
template - template to save
Throws:
TemplateException - when template cannot be saved as a result of core eclipse exceptions
See Also:
#saveTemplate(pl.edu.agh.cast.importer.base.template.IImportTemplate)

saveTemplateGroup

public void saveTemplateGroup(ImportTemplateGroup group)
                       throws TemplateException
Saves given template group. If group with given UUID already exists it will be overridden.

Specified by:
saveTemplateGroup in interface ITemplateProvider
Parameters:
group - group to save
Throws:
TemplateException
See Also:
#saveTemplateGroup(pl.edu.agh.cast.importer.base.template.ImportTemplateGroup)

exportTemplateToFile

public void exportTemplateToFile(IImportTemplate template,
                                 File file)
                          throws TemplateException
Writes given template to the file.

Specified by:
exportTemplateToFile in interface ITemplateProvider
Parameters:
template - template to write
file - destination file
Throws:
TemplateException - when any I/O exception occurs during exporting template
See Also:
#exportTemplateToFile(pl.edu.agh.cast.importer.base.template.IImportTemplate, java.io.File)

importTemplateFromFile

public IImportTemplate importTemplateFromFile(File file)
                                       throws ResourceTemplateException
Imports template from a given file.

Specified by:
importTemplateFromFile in interface ITemplateProvider
Parameters:
file - file which contains an import template
Returns:
a template written in the file
Throws:
ResourceTemplateException
See Also:
ITemplateProvider.importTemplateFromFile(java.io.File)


Copyright © 2007-2009 IISG AGH-UST Krakow, Poland. All Rights Reserved.