templates.io
Class TemplateFileIO

java.lang.Object
  extended by templates.io.TemplateFileIO
All Implemented Interfaces:
ides.api.plugin.io.FileIOPlugin

public class TemplateFileIO
extends java.lang.Object
implements ides.api.plugin.io.FileIOPlugin

Provides IO for TemplateModels. Also stores and loads the graphical layout information needed for the associated TemplateDiagrams, as well as manages the storing and loading of the separate files with the models of the TemplateComponents in TemplateModels.

Author:
Lenko Grigorov

Field Summary
protected static java.lang.String ATTRIBUTE_COLOR
          "COLOR" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_COMPONENT
          "COMPONENT" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_FLAG
          "FLAG" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_FSA
          "MODEL" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_ICON
          "ICON" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_ID
          "ID" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_LABEL
          "LABEL" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_LEFT
          "COMPONENT1" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_LEFTEVENT
          "EVENT1" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_RIGHT
          "COMPONENT2" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_RIGHTEVENT
          "EVENT2" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_TAG
          "TAG" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_TYPE
          "TYPE" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_X
          "X" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ATTRIBUTE_Y
          "Y" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ELEMENT_COMPONENT
          "COMPONENT" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ELEMENT_CONNECTOR
          "CONNECTOR" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ELEMENT_DATA
          "DATA" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ELEMENT_ENTITY
          "ENTITY" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String ELEMENT_LINK
          "LINK" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram.
protected static java.lang.String FILE
          Key for the annotation of a FSAModel component of a TemplateModel with information about the location of the file where the component is saved.
protected static java.lang.String LAST_SAVE_FILE
          Key for the annotation of a TemplateModel with information about the location of the last file to which the model was saved.
protected static java.lang.String META
          The meta tag for the layout information of TemplateDiagrams.
protected static java.lang.String TYPE
          The string description of TemplateModels.
protected static java.lang.String VERSION
          The version of the file format supported by this class.
 
Constructor Summary
TemplateFileIO()
           
 
Method Summary
protected  java.lang.String component2File(java.io.File parentFile, TemplateComponent component)
          Derive a name for the file where the model of a TemplateComponent will be saved, from the name of the model of the TemplateComponent.
protected  java.lang.String file2Component(java.io.File parentFile, java.io.File file)
          Derive a name for the model of a TemplateComponent, from the name of the file where the model of the TemplateComponent is saved.
 java.lang.String getIOTypeDescriptor()
           
 java.util.Set<java.lang.String> getMetaTags()
           
 java.lang.String getSaveDataVersion()
           
 java.lang.String getSaveMetaVersion(java.lang.String arg0)
           
 ides.api.plugin.model.DESModel loadData(java.lang.String arg0, java.io.InputStream arg1, java.lang.String file)
           
 void loadMeta(java.lang.String arg0, java.io.InputStream arg1, ides.api.plugin.model.DESModel model, java.lang.String arg3)
           
 void saveData(java.io.PrintStream stream, ides.api.plugin.model.DESModel model, java.lang.String file)
           
 void saveMeta(java.io.PrintStream stream, ides.api.plugin.model.DESModel arg1, java.lang.String arg2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE

protected static final java.lang.String TYPE
The string description of TemplateModels.

See Also:
Constant Field Values

META

protected static final java.lang.String META
The meta tag for the layout information of TemplateDiagrams.

See Also:
Constant Field Values

VERSION

protected static final java.lang.String VERSION
The version of the file format supported by this class.

See Also:
Constant Field Values

FILE

protected static final java.lang.String FILE
Key for the annotation of a FSAModel component of a TemplateModel with information about the location of the file where the component is saved.

See Also:
Constant Field Values

LAST_SAVE_FILE

protected static final java.lang.String LAST_SAVE_FILE
Key for the annotation of a TemplateModel with information about the location of the last file to which the model was saved.

See Also:
Constant Field Values

ELEMENT_DATA

protected static final java.lang.String ELEMENT_DATA
"DATA" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Denotes the element which contains the description of the TemplateModel.

See Also:
Constant Field Values

ELEMENT_COMPONENT

protected static final java.lang.String ELEMENT_COMPONENT
"COMPONENT" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Denotes the element which describes a TemplateComponent (module or channel) of a TemplateModel.

See Also:
Constant Field Values

ELEMENT_LINK

protected static final java.lang.String ELEMENT_LINK
"LINK" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Denotes the element which describes a TemplateLink between components of a TemplateModel.

See Also:
Constant Field Values

ELEMENT_ENTITY

protected static final java.lang.String ELEMENT_ENTITY
"ENTITY" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Denotes the element which describes an Entity in a TemplateDiagram.

See Also:
Constant Field Values

ELEMENT_CONNECTOR

protected static final java.lang.String ELEMENT_CONNECTOR
"CONNECTOR" element of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Denotes the element which describes a Connector in a TemplateDiagram.

See Also:
Constant Field Values

ATTRIBUTE_ID

protected static final java.lang.String ATTRIBUTE_ID
"ID" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the ID of an element in a TemplateModel.

See Also:
Constant Field Values

ATTRIBUTE_TYPE

protected static final java.lang.String ATTRIBUTE_TYPE
"TYPE" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the type (module or channel) of a TemplateComponent.

See Also:
Constant Field Values

ATTRIBUTE_FSA

protected static final java.lang.String ATTRIBUTE_FSA
"MODEL" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the name of the file where the FSAModel of TemplateComponent is saved.

See Also:
Constant Field Values

ATTRIBUTE_LEFT

protected static final java.lang.String ATTRIBUTE_LEFT
"COMPONENT1" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the ID of the "left" TemplateComponent in a TemplateLink.

See Also:
Constant Field Values

ATTRIBUTE_RIGHT

protected static final java.lang.String ATTRIBUTE_RIGHT
"COMPONENT2" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the ID of the "right" TemplateComponent in a TemplateLink.

See Also:
Constant Field Values

ATTRIBUTE_LEFTEVENT

protected static final java.lang.String ATTRIBUTE_LEFTEVENT
"EVENT1" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the name of the event from the "left" TemplateComponent linked by a TemplateLink.

See Also:
Constant Field Values

ATTRIBUTE_RIGHTEVENT

protected static final java.lang.String ATTRIBUTE_RIGHTEVENT
"EVENT2" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the name of the event from the "right" TemplateComponent linked by a TemplateLink.

See Also:
Constant Field Values

ATTRIBUTE_COMPONENT

protected static final java.lang.String ATTRIBUTE_COMPONENT
"COMPONENT" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the ID of the TemplateComponent whose layout information is maintained by the Entity.

See Also:
Constant Field Values

ATTRIBUTE_X

protected static final java.lang.String ATTRIBUTE_X
"X" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the x-axis location of an Entity.

See Also:
Constant Field Values

ATTRIBUTE_Y

protected static final java.lang.String ATTRIBUTE_Y
"Y" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the y-axis location of an Entity.

See Also:
Constant Field Values

ATTRIBUTE_LABEL

protected static final java.lang.String ATTRIBUTE_LABEL
"LABEL" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the label of an Entity.

See Also:
Constant Field Values

ATTRIBUTE_COLOR

protected static final java.lang.String ATTRIBUTE_COLOR
"COLOR" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the color of the icon representing an Entity.

See Also:
Constant Field Values

ATTRIBUTE_TAG

protected static final java.lang.String ATTRIBUTE_TAG
"TAG" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains the text inside the icon representing an Entity.

See Also:
Constant Field Values

ATTRIBUTE_FLAG

protected static final java.lang.String ATTRIBUTE_FLAG
"FLAG" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Contains information if the icon of an Entity is "flagged"

See Also:
Constant Field Values

ATTRIBUTE_ICON

protected static final java.lang.String ATTRIBUTE_ICON
"ICON" attribute of the XML structure used to save a TemplateModel and the associated TemplateDiagram. Reserved attribute.

See Also:
Constant Field Values
Constructor Detail

TemplateFileIO

public TemplateFileIO()
Method Detail

getIOTypeDescriptor

public java.lang.String getIOTypeDescriptor()
Specified by:
getIOTypeDescriptor in interface ides.api.plugin.io.FileIOPlugin

getMetaTags

public java.util.Set<java.lang.String> getMetaTags()
Specified by:
getMetaTags in interface ides.api.plugin.io.FileIOPlugin

component2File

protected java.lang.String component2File(java.io.File parentFile,
                                          TemplateComponent component)
Derive a name for the file where the model of a TemplateComponent will be saved, from the name of the model of the TemplateComponent.

Parameters:
parentFile - name of the file where the TemplateModel is saved
component - the TemplateComponent for which to derive a file name
Returns:
the file name to be used for saving the model of the TemplateComponent

file2Component

protected java.lang.String file2Component(java.io.File parentFile,
                                          java.io.File file)
Derive a name for the model of a TemplateComponent, from the name of the file where the model of the TemplateComponent is saved.

Parameters:
parentFile - name of the file where the TemplateModel is saved
file - the file where the model of the TemplateComponent is saved
Returns:
the name to be used for the model of the TemplateComponent

saveData

public void saveData(java.io.PrintStream stream,
                     ides.api.plugin.model.DESModel model,
                     java.lang.String file)
              throws ides.api.plugin.io.FileSaveException
Specified by:
saveData in interface ides.api.plugin.io.FileIOPlugin
Throws:
ides.api.plugin.io.FileSaveException

saveMeta

public void saveMeta(java.io.PrintStream stream,
                     ides.api.plugin.model.DESModel arg1,
                     java.lang.String arg2)
              throws ides.api.plugin.io.FileSaveException
Specified by:
saveMeta in interface ides.api.plugin.io.FileIOPlugin
Throws:
ides.api.plugin.io.FileSaveException

getSaveDataVersion

public java.lang.String getSaveDataVersion()
Specified by:
getSaveDataVersion in interface ides.api.plugin.io.FileIOPlugin

getSaveMetaVersion

public java.lang.String getSaveMetaVersion(java.lang.String arg0)
Specified by:
getSaveMetaVersion in interface ides.api.plugin.io.FileIOPlugin

loadData

public ides.api.plugin.model.DESModel loadData(java.lang.String arg0,
                                               java.io.InputStream arg1,
                                               java.lang.String file)
                                        throws ides.api.plugin.io.FileLoadException
Specified by:
loadData in interface ides.api.plugin.io.FileIOPlugin
Throws:
ides.api.plugin.io.FileLoadException

loadMeta

public void loadMeta(java.lang.String arg0,
                     java.io.InputStream arg1,
                     ides.api.plugin.model.DESModel model,
                     java.lang.String arg3)
              throws ides.api.plugin.io.FileLoadException
Specified by:
loadMeta in interface ides.api.plugin.io.FileIOPlugin
Throws:
ides.api.plugin.io.FileLoadException