ides.api.plugin.io
Interface FileIOPlugin


public interface FileIOPlugin

Interface for plugins which save/load DESModels or which save/load meta-data sections in DESModel files.

For meta-data sections, refer to external documentation.

Author:
christiansilvano, Lenko Grigorov

Method Summary
 java.lang.String getIOTypeDescriptor()
          Return the string describing the type of model handled by the plugin.
 java.util.Set<java.lang.String> getMetaTags()
          Returns the set of meta-data "tags" handled by the plugin.
 java.lang.String getSaveDataVersion()
          Returns the version of the format in which the model data is saved.
 java.lang.String getSaveMetaVersion(java.lang.String tag)
          Returns the version of the format in which the meta-data section with the given "tag" is saved.
 DESModel loadData(java.lang.String version, java.io.InputStream stream, java.lang.String fileName)
          Load a DES model from the provided stream.
 void loadMeta(java.lang.String version, java.io.InputStream stream, DESModel model, java.lang.String tag)
          Loads meta-data for a given DES model from a meta-data section.
 void saveData(java.io.PrintStream stream, DESModel model, java.lang.String fileName)
          Save the description of the DES model into the provided stream.
 void saveMeta(java.io.PrintStream stream, DESModel model, java.lang.String tag)
          Save the meta-data section with the given "tag" for a given DES model.
 

Method Detail

getIOTypeDescriptor

java.lang.String getIOTypeDescriptor()
Return the string describing the type of model handled by the plugin. This string is matched against the type in IDES model files.

For example, the type of Finite-State Machines is "FSA".

This method is relevant only to data-handling plugins. Meta-data plugins do not need to implement this method.

Returns:
the string describing the type of model handled by the plugin

getSaveDataVersion

java.lang.String getSaveDataVersion()
Returns the version of the format in which the model data is saved.

This method is relevant only to plugins which save model data.

Returns:
the version of the format in which the model data is saved

getMetaTags

java.util.Set<java.lang.String> getMetaTags()
Returns the set of meta-data "tags" handled by the plugin. These tags are matched against the meta-data tags in IDES model files.

For example, the tag for layout meta-data in FSA files is "layout".

Returns:
the set of meta-data "tags" handled by the plugin

getSaveMetaVersion

java.lang.String getSaveMetaVersion(java.lang.String tag)
Returns the version of the format in which the meta-data section with the given "tag" is saved.

This method is relevant only to plugins which save model meta-data.

Parameters:
tag - the "tag" for which version information is requested
Returns:
the version of the format in which the meta-data section with the given "tag" is saved; if the "tag" is not supported by this plugin, the return value is unspecified

saveData

void saveData(java.io.PrintStream stream,
              DESModel model,
              java.lang.String fileName)
              throws FileSaveException
Save the description of the DES model into the provided stream. It is highly recommended that the data conforms to the XML format.

The provided file name can be used if the plugin needs to work with additional files in the directory or needs the name of the save file. The file name is only for information purposes. All data must be written to the provided stream.

Parameters:
stream - stream where to write the data (will be encoded into UTF-8)
model - DES model to save
fileName - absolute path to the file where the model will be saved
Throws:
FileSaveException - when there is a problem saving the data

loadData

DESModel loadData(java.lang.String version,
                  java.io.InputStream stream,
                  java.lang.String fileName)
                  throws FileLoadException
Load a DES model from the provided stream.

The provided file name can be used if the plugin needs to work with additional files in the directory or needs the name of the loaded file. The file name is only for information purposes. All data must be read from the provided stream.

Parameters:
version - the version of the format of the model data
stream - UTF-8 encoded stream with the model data
fileName - absolute path to the file from where the model is loaded
Returns:
the loaded model
Throws:
FileLoadException - when there is a problem loading the model

loadMeta

void loadMeta(java.lang.String version,
              java.io.InputStream stream,
              DESModel model,
              java.lang.String tag)
              throws FileLoadException
Loads meta-data for a given DES model from a meta-data section.

Parameters:
version - the version of the format of the meta-data section
stream - UTF-8 encoded stream from where meta-data should be read
model - the DES model for which the meta-data is to be loaded
tag - the "tag" of the meta-data section to be loaded
Throws:
FileLoadException - when there is a problem loading the meta-data

saveMeta

void saveMeta(java.io.PrintStream stream,
              DESModel model,
              java.lang.String tag)
              throws FileSaveException
Save the meta-data section with the given "tag" for a given DES model. It is highly recommended that the data conforms to the XML format.

Parameters:
stream - stream where to write the meta-data (will be encoded into UTF-8)
model - the DES model for which the meta-data is to be saved
tag - the "tag" of the meta-data section to be saved
Throws:
FileSaveException - when there is a problem saving the mata-data