ides.api.plugin.io
Class IOPluginManager

java.lang.Object
  extended by ides.api.plugin.io.IOPluginManager

public class IOPluginManager
extends java.lang.Object

The manager of I/O plugins. Plugins which provide services for the saving/loading of DES models or related meta-data or for the import/export of different file formats must register with this manager in order to be available to the user.

Author:
christiansilvano, Lenko Grigorov
See Also:
FileIOPlugin, ImportExportPlugin

Field Summary
protected  java.util.Comparator<ImportExportPlugin> descriptionComparator
          Comparator which can be used to sort ImportExportPlugins lexically according to their file format descriptions.
 
Method Summary
 java.lang.Object clone()
          Throws RuntimeException to prevent cloning.
 FileIOPlugin getDataLoader(java.lang.String type)
          Returns a plugin which is capable of loading a DESModel of the given type (for example, the type of Finite-State Machines is "FSA").
 FileIOPlugin getDataSaver(java.lang.Class<?> type)
          Returns a plugin which is capable of saving DESModels of the given perspective (e.g.
 java.util.Set<ImportExportPlugin> getExporters()
          Returns the set of plugins registered to export to other file formats.
 java.util.Set<ImportExportPlugin> getExporters(java.lang.Class<?> type)
          Returns the set of plugins registered to export DESModels of the given perspective (e.g., FSAModel) to another file format.
 ImportExportPlugin getImporter(java.lang.String description)
          Returns the importing plugin which has the given file-format description.
 java.util.Set<ImportExportPlugin> getImporters()
          Returns the set of plugins registered to import from other file formats.
 FileIOPlugin getMetaLoaders(java.lang.String type, java.lang.String tag)
          Returns the plugin registered to load meta-data with the given tag when loading DESModels of the given type (e.g., "FSA").
 java.util.Set<FileIOPlugin> getMetaSavers(java.lang.Class<?> type)
          Returns the set of plugins registered to save meta-data when saving DESModels of the given perspective (e.g.
static IOPluginManager instance()
          Provides access to the instance of the manager.
 void registerDataLoader(FileIOPlugin plugin, java.lang.String type)
          Registers a plugin which can load models of the given type (for example, the type of Finite-State Machines is "FSA").
 void registerDataSaver(FileIOPlugin plugin, java.lang.Class<?> type)
          Registers a plugin which can save DESModels of the given perspective (e.g., FSAModel).
 void registerExport(ImportExportPlugin plugin, java.lang.Class<?> type)
          Registers a plugin which can export DESModels of the given perspective (e.g., FSAModel) to another file format.
 void registerImport(ImportExportPlugin plugin)
          Registers a plugin which can import models from other file formats.
 void registerMetaLoader(FileIOPlugin plugin, java.lang.String tag)
          Registers a plugin which can load meta-data with the given "tag" for any type of DES models (a generic plugin).
 void registerMetaLoader(FileIOPlugin plugin, java.lang.String type, java.lang.String tag)
          Registers a plugin which can load meta-data with the given "tag" for the given type of DES models.
 void registerMetaSaver(FileIOPlugin plugin)
          Registers a plugin which can save meta-data for any DESModel perspective (a generic plugin).
 void registerMetaSaver(FileIOPlugin plugin, java.lang.Class<?> type)
          Registers a plugin which can save meta-data for the given DESModel perspective.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

descriptionComparator

protected java.util.Comparator<ImportExportPlugin> descriptionComparator
Comparator which can be used to sort ImportExportPlugins lexically according to their file format descriptions.

See Also:
ImportExportPlugin.getFileDescription()
Method Detail

clone

public java.lang.Object clone()
Throws RuntimeException to prevent cloning.

Overrides:
clone in class java.lang.Object

instance

public static IOPluginManager instance()
Provides access to the instance of the manager.

Returns:
the instance of the manager

getDataSaver

public FileIOPlugin getDataSaver(java.lang.Class<?> type)
Returns a plugin which is capable of saving DESModels of the given perspective (e.g. FSAModel). If no registered plugin is capable, returns null.

Parameters:
type - the DESModel perspective which the plugin should handle
Returns:
a plugin which can handle the given perspective, or null if no such plugin is registered
See Also:
DESModelType

getMetaSavers

public java.util.Set<FileIOPlugin> getMetaSavers(java.lang.Class<?> type)
Returns the set of plugins registered to save meta-data when saving DESModels of the given perspective (e.g. FSAModel). If no such plugin is registered, returns null.

Parameters:
type - the DESModel perspective for which the plugins want to save meta-data
Returns:
the set of plugins registered to save meta-data when saving DESModels of the given perspective, or null if no such plugin is registered
See Also:
DESModelType

getMetaLoaders

public FileIOPlugin getMetaLoaders(java.lang.String type,
                                   java.lang.String tag)
Returns the plugin registered to load meta-data with the given tag when loading DESModels of the given type (e.g., "FSA"). If no such plugin is registered, returns null.

Parameters:
type - string with the type of model being loaded
tag - the "tag" for the meta-data section
Returns:
the plugin registered to load meta-data with the given tag for the given type of models, or null if no such plugin is registered

getDataLoader

public FileIOPlugin getDataLoader(java.lang.String type)
Returns a plugin which is capable of loading a DESModel of the given type (for example, the type of Finite-State Machines is "FSA"). If no such plugin is registered, returns null.

Parameters:
type - string with the type of model being loaded
Returns:
a plugin which can load the given type, or null if no such plugin is registered

registerDataLoader

public void registerDataLoader(FileIOPlugin plugin,
                               java.lang.String type)
Registers a plugin which can load models of the given type (for example, the type of Finite-State Machines is "FSA"). The type of model is read from the IDES model files.

Parameters:
plugin - the plugin to be registered
type - the type of model which the plugin can load

registerDataSaver

public void registerDataSaver(FileIOPlugin plugin,
                              java.lang.Class<?> type)
Registers a plugin which can save DESModels of the given perspective (e.g., FSAModel).

Parameters:
plugin - the plugin to be registered
type - the DESModel perspective which the plugin can save
See Also:
DESModelType

registerMetaLoader

public void registerMetaLoader(FileIOPlugin plugin,
                               java.lang.String type,
                               java.lang.String tag)
Registers a plugin which can load meta-data with the given "tag" for the given type of DES models. The type of model and the "tag" are read from the IDES model files.

Parameters:
plugin - the plugin to be registered
type - the type of model for which the plugin can load meta-data
tag - the "tag" of the meta-data section which the plugin can load

registerMetaLoader

public void registerMetaLoader(FileIOPlugin plugin,
                               java.lang.String tag)
Registers a plugin which can load meta-data with the given "tag" for any type of DES models (a generic plugin). The "tag" is read from the IDES model files.

Parameters:
plugin - the plugin to be registered
tag - the "tag" of the meta-data section which the plugin can load

registerMetaSaver

public void registerMetaSaver(FileIOPlugin plugin,
                              java.lang.Class<?> type)
Registers a plugin which can save meta-data for the given DESModel perspective.

Parameters:
plugin - the plugin to be registered
type - the DESModel perspective for which the plugin can save meta-data
See Also:
DESModelType

registerMetaSaver

public void registerMetaSaver(FileIOPlugin plugin)
Registers a plugin which can save meta-data for any DESModel perspective (a generic plugin).

Parameters:
plugin - the plugin to be registered
See Also:
DESModelType

registerImport

public void registerImport(ImportExportPlugin plugin)
Registers a plugin which can import models from other file formats.

Parameters:
plugin - the plugin to be registered

registerExport

public void registerExport(ImportExportPlugin plugin,
                           java.lang.Class<?> type)
Registers a plugin which can export DESModels of the given perspective (e.g., FSAModel) to another file format.

Parameters:
plugin - the plugin to be registered
type - the DESModel perspective which the plugin can export
See Also:
DESModelType

getExporters

public java.util.Set<ImportExportPlugin> getExporters(java.lang.Class<?> type)
Returns the set of plugins registered to export DESModels of the given perspective (e.g., FSAModel) to another file format. If no such plugin is registered, returns null.

Parameters:
type - the DESModel perspective which the plugins should be able to export
Returns:
the set of plugins registered to export DESModels of the given perspective, or null if no such plugin is registered
See Also:
DESModelType

getImporters

public java.util.Set<ImportExportPlugin> getImporters()
Returns the set of plugins registered to import from other file formats. If no such plugin is registered, returns and empty set.

Returns:
the set of plugins registered to import from other file formats

getExporters

public java.util.Set<ImportExportPlugin> getExporters()
Returns the set of plugins registered to export to other file formats. If no such plugin is registered, returns and empty set.

Returns:
the set of plugins registered to export to other file formats

getImporter

public ImportExportPlugin getImporter(java.lang.String description)
Returns the importing plugin which has the given file-format description. If no such plugin is registered, returns null.

Parameters:
description - the file format description of the plugin
Returns:
the importing plugin which has the given file-format description, or null if no such plugin is registered
See Also:
ImportExportPlugin.getFileDescription()