com.swfm.mica.view
Class MiModelIOFormatManager

java.lang.Object
  extended bycom.swfm.mica.model.MiModelEntity
      extended bycom.swfm.mica.view.MiModelIOFormatManager
All Implemented Interfaces:
MiiActionHandler, MiiActionTypes, MiiModelEntity, MiiModelIOFormatManager, MiiModelTypes, MiiNames, MiiPropertyTypes, MiiTypes

public class MiModelIOFormatManager
extends MiModelEntity
implements MiiModelIOFormatManager, MiiModelTypes, MiiNames

This class implements the MiiModelIOFormatManager interface. It reads and writes MiiModelDocuments to and from Streams. The format of the stream is lines of ASCII text, each line a seperate entity. If the first character of a line is a '#' or a '!' it is considered a comment. Entities are assumed to be sequences of name/value pairs. For example: "name = entity1, color = red, type = node"

Version:
%I% %G%
Author:
Michael L. Davis

Field Summary
             
Constructor Summary
MiModelIOFormatManager()
          Constructs a new MiModelIOFormatManager.
 
Method Summary
 MiiModelDocument load(java.io.InputStream inputStream, java.lang.String streamName)
          Creates, loads contents (the entities of type MiModelEntity) of, and returns a new MiiModelDocument from the given Stream.
static MiModelEntity makeModelEntityFromString(java.lang.String str, java.lang.String streamName, int lineNumber)
          Creates a MiModelEntity from the given line of text.
static java.lang.String makeStringFromModelEntity(MiiModelEntity entity)
          Creates a String describing the given MiiModelEntity.
static void postProcessesContainersAndConnections(MiiModelEntity document, boolean createNodesAtEndsOfDanglingReferences)
           
 void save(MiiModelEntity document, java.io.OutputStream outputStream, java.lang.String header)
          Saves the contents (the entities of type MiModelEntity) of the given document to the given Stream.
 
Methods inherited from class com.swfm.mica.model.MiModelEntity
appendModelChangeHandler, appendModelEntity, appendModelRelation, appendPropertyChangeHandler, copy, copy, createModelEntity, createModelRelation, deepCopy, deepCopy, deleteSelf, dispatchModelChangeEvent, dispatchPropertyChange, dispatchPropertyChangeEvent, dump, dump, equals, equalsProperties, getChild, getChildren, getDefaultPropertyValue, getEditingPermissions, getIgnoreCase, getIndexOfModelEntity, getLocation, getModelChangeHandler, getModelEntities, getModelEntity, getModelEntity, getModelRelations, getName, getNumberOfModelChangeHandlers, getNumberOfModelEntities, getNumberOfPropertyChangeHandlers, getParent, getPropertiesAreOrdered, getPropertyChangeHandler, getPropertyDescriptions, getPropertyNames, getPropertyValue, getTitle, getType, getUserData, hasUserData, insertModelEntity, insertModelRelation, isObservedProperty, isToCopyEntitysRelationsWhenDeepCopyEntity, processAction, removeAllModelEntities, removeAllModelRelations, removeAllProperties, removeModelChangeHandler, removeModelEntity, removeModelRelation, removeProperty, removePropertyChangeHandler, removeSelf, replaceSelf, setIgnoreCase, setLocation, setModelChangeEventDispatchingEnabled, setName, setParent, setPropertiesAreOrdered, setPropertiesToDefaultValues, setPropertyChangeEventDispatchingEnabled, setPropertyDescriptions, setPropertyValue, setTitle, setToCopyEntitysRelationsWhenDeepCopyEntity, setType, toString, toString, validateModelEntity, validateModelRelation, validatePropertyValue
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.swfm.mica.model.MiiModelEntity
appendModelChangeHandler, appendModelEntity, appendModelRelation, appendPropertyChangeHandler, copy, copy, createModelEntity, createModelRelation, deepCopy, deepCopy, deleteSelf, equals, equalsProperties, getChild, getChildren, getEditingPermissions, getIgnoreCase, getIndexOfModelEntity, getLocation, getModelChangeHandler, getModelEntities, getModelEntity, getModelEntity, getModelRelations, getName, getNumberOfModelChangeHandlers, getNumberOfModelEntities, getNumberOfPropertyChangeHandlers, getParent, getPropertiesAreOrdered, getPropertyChangeHandler, getPropertyDescriptions, getPropertyNames, getPropertyValue, getTitle, getType, getUserData, hasUserData, insertModelEntity, insertModelRelation, removeAllModelEntities, removeAllModelRelations, removeAllProperties, removeModelChangeHandler, removeModelEntity, removeModelRelation, removeProperty, removePropertyChangeHandler, removeSelf, replaceSelf, setIgnoreCase, setLocation, setModelChangeEventDispatchingEnabled, setName, setParent, setPropertiesAreOrdered, setPropertyChangeEventDispatchingEnabled, setPropertyDescriptions, setPropertyValue, setTitle, setType, validateModelEntity, validateModelRelation, validatePropertyValue
 

Constructor Detail

MiModelIOFormatManager

public MiModelIOFormatManager()
Constructs a new MiModelIOFormatManager.

Method Detail

load

public MiiModelDocument load(java.io.InputStream inputStream,
                             java.lang.String streamName)
                      throws java.io.IOException
Creates, loads contents (the entities of type MiModelEntity) of, and returns a new MiiModelDocument from the given Stream.

Specified by:
load in interface MiiModelIOFormatManager
Parameters:
inputStream - the source of the data from which the document contents will be built.
streamName - The name of the stream to be used for error messages
Returns:
the document
Throws:
java.io.IOException

save

public void save(MiiModelEntity document,
                 java.io.OutputStream outputStream,
                 java.lang.String header)
Saves the contents (the entities of type MiModelEntity) of the given document to the given Stream.

Specified by:
save in interface MiiModelIOFormatManager
Parameters:
document - The document to save
outputStream - the destination of the data built from the document contents.
header - The first line output that identifies the format of the data

makeModelEntityFromString

public static MiModelEntity makeModelEntityFromString(java.lang.String str,
                                                      java.lang.String streamName,
                                                      int lineNumber)
Creates a MiModelEntity from the given line of text. The entity is assigned the given line number. This method is static and publically available so that it may be used to parse any line of form: " = , = , ..."

Parameters:
str - the text describing the entity
streamName - the name of the source of the text to be used for error messages
lineNumber - the line number of the entity
Returns:
the entity

makeStringFromModelEntity

public static java.lang.String makeStringFromModelEntity(MiiModelEntity entity)
Creates a String describing the given MiiModelEntity.

Parameters:
entity - the entity to convert to text.
Returns:
the line of text

postProcessesContainersAndConnections

public static void postProcessesContainersAndConnections(MiiModelEntity document,
                                                         boolean createNodesAtEndsOfDanglingReferences)