org.argouml.persistence
Class UmlFilePersister

java.lang.Object
  extended byjavax.swing.filechooser.FileFilter
      extended byorg.argouml.persistence.AbstractFilePersister
          extended byorg.argouml.persistence.UmlFilePersister
All Implemented Interfaces:
EventListener, ProgressListener, ProjectFilePersister
Direct Known Subclasses:
ZargoFilePersister

public class UmlFilePersister
extends AbstractFilePersister
implements ProgressListener

To persist to and from argo (xml file) storage.


Field Summary
private static String ARGO_TEE
           
private static Logger LOG
          Logger.
private  int percentPhasesComplete
          The percentage completeness of phases complete.
protected static int PERSISTENCE_VERSION
          The PERSISTENCE_VERSION is increased every time the persistence format changes.
private  int phasesCompleted
          The sections complete of a load or save.
private  int progressPhaseCount
          The number of equals phases the progress will measure.
 
Fields inherited from class org.argouml.persistence.AbstractFilePersister
 
Constructor Summary
UmlFilePersister()
          The constructor.
 
Method Summary
 Project doLoad(File file)
           
 Project doLoad(File originalFile, File file)
           
 void doSave(Project project, File file)
          It is being considered to save out individual xmi's from individuals diagrams to make it easier to modularize the output of Argo.
protected  String getDesc()
          (Just the description, not the extension between "()".)
 String getExtension()
          The extension valid for this type of file.
protected  MemberFilePersister getMemberFilePersister(ProjectMember pm)
          Get a MemberFilePersister based on a given ProjectMember
private  MemberFilePersister getMemberFilePersister(String tag)
          Get a MemberFilePersister based on a given ProjectMember
private  int getPersistenceVersionFromFile(File file)
          Reads an XML file of uml format and extracts the persistence version number from the root tag.
private  String getReleaseVersionFromFile(File file)
          Reads an XML file of uml format and extracts the persistence version number from the root tag.
protected  String getVersion(String rootLine)
          Get the version attribute value from a string of XML.
 void progress(ProgressEvent event)
          Called when a ProgressEvent is fired.
 File transform(File file, int version)
          Transform a string of XML data according to the service required.
private  File upgrade(File file, int fileVersion)
           
(package private)  void writeProject(Project project, OutputStream stream)
          Write the output for a project on the given stream.
 
Methods inherited from class org.argouml.persistence.AbstractFilePersister
accept, addProgressListener, copyFile, createTempFile, fireProgressEvent, getDescription, getEncoding, removeProgressListener, save
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERSISTENCE_VERSION

protected static final int PERSISTENCE_VERSION
The PERSISTENCE_VERSION is increased every time the persistence format changes. This controls conversion of old persistence version files to be converted to the current one, keeping ArgoUML backwards compatible.

See Also:
Constant Field Values

LOG

private static final Logger LOG
Logger.


percentPhasesComplete

private int percentPhasesComplete
The percentage completeness of phases complete. Does not include part-completed phases.


phasesCompleted

private int phasesCompleted
The sections complete of a load or save.


progressPhaseCount

private int progressPhaseCount
The number of equals phases the progress will measure. It is assumed each phase will be of equal time. There is one phase for each upgrade from a previous version and one pahse for the final load.


ARGO_TEE

private static final String ARGO_TEE
See Also:
Constant Field Values
Constructor Detail

UmlFilePersister

public UmlFilePersister()
The constructor.

Method Detail

getExtension

public String getExtension()
Description copied from class: AbstractFilePersister
The extension valid for this type of file. (Just the chars, not the dot: e.g. "zargo".)

Specified by:
getExtension in class AbstractFilePersister
Returns:
the extension valid for this type of file
See Also:
AbstractFilePersister.getExtension()

getDesc

protected String getDesc()
Description copied from class: AbstractFilePersister
(Just the description, not the extension between "()".)

Specified by:
getDesc in class AbstractFilePersister
Returns:
the description valid for this type of file
See Also:
AbstractFilePersister.getDesc()

doSave

public void doSave(Project project,
                   File file)
            throws SaveException
It is being considered to save out individual xmi's from individuals diagrams to make it easier to modularize the output of Argo.

Specified by:
doSave in class AbstractFilePersister
Parameters:
file - The file to write.
project - the project to save
Throws:
SaveException - when anything goes wrong
See Also:
ProjectFilePersister.save( org.argouml.kernel.Project, java.io.File)

writeProject

void writeProject(Project project,
                  OutputStream stream)
            throws SaveException
Write the output for a project on the given stream.

Parameters:
project - The project to output.
stream - The stream to write to.
Throws:
SaveException - If something goes wrong.

doLoad

public Project doLoad(File file)
               throws OpenException
Specified by:
doLoad in interface ProjectFilePersister
Specified by:
doLoad in class AbstractFilePersister
Throws:
OpenException
See Also:
org.argouml.persistence.ProjectFilePersister#doLoad(java.io.File, javax.swing.JProgressBar, org.argouml.persistence.ProgressListener)

doLoad

public Project doLoad(File originalFile,
                      File file)
               throws OpenException
Throws:
OpenException
See Also:
org.argouml.persistence.ProjectFilePersister#doLoad(java.io.File, javax.swing.JProgressBar, org.argouml.persistence.ProgressListener)

upgrade

private File upgrade(File file,
                     int fileVersion)
              throws OpenException
Throws:
OpenException

transform

public final File transform(File file,
                            int version)
                     throws OpenException
Transform a string of XML data according to the service required.

Parameters:
file - The XML file to be transformed
version - the version of the persistence format the XML is to be transformed to.
Returns:
the transformed XML file
Throws:
OpenException - on XSLT transformation error or file read

getPersistenceVersionFromFile

private int getPersistenceVersionFromFile(File file)
                                   throws OpenException
Reads an XML file of uml format and extracts the persistence version number from the root tag.

Parameters:
file - the XML file
Returns:
The version number
Throws:
OpenException - on any error

getReleaseVersionFromFile

private String getReleaseVersionFromFile(File file)
                                  throws OpenException
Reads an XML file of uml format and extracts the persistence version number from the root tag.

Parameters:
file - the XML file
Returns:
The ArgoUML release number
Throws:
OpenException - on any error

getVersion

protected String getVersion(String rootLine)
Get the version attribute value from a string of XML.

Parameters:
rootLine - the line
Returns:
the version

progress

public void progress(ProgressEvent event)
Description copied from interface: ProgressListener
Called when a ProgressEvent is fired.

Specified by:
progress in interface ProgressListener
Parameters:
event - the ProgressEvent
See Also:
ProgressListener.progress(org.argouml.persistence.ProgressEvent)

getMemberFilePersister

protected MemberFilePersister getMemberFilePersister(ProjectMember pm)
Get a MemberFilePersister based on a given ProjectMember

Parameters:
pm - the project member
Returns:
the persister

getMemberFilePersister

private MemberFilePersister getMemberFilePersister(String tag)
Get a MemberFilePersister based on a given ProjectMember

Returns:
the persister


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook