Cytoscape 3.0.0-alpha8-SNAPSHOT API

org.cytoscape.io.write
Class AbstractCyWriter<T extends CyWriterManager>

java.lang.Object
  extended by org.cytoscape.work.AbstractTask
      extended by org.cytoscape.io.write.AbstractCyWriter<T>
Type Parameters:
T - Generic type that extends CyWriterManager.
All Implemented Interfaces:
CyWriter, Task

public abstract class AbstractCyWriter<T extends CyWriterManager>
extends AbstractTask
implements CyWriter

An abstract utility implementation of a Task that writes a user defined file to a file type determined by a provided writer manager. This class is meant to be extended for specific file types such that the appropriate CyWriter can be identified.


Cytoscape Backwards Compatibility (Abstract Class): This class is abstract and meant to be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Field Summary
protected  Map<String,CyFileFilter> descriptionFilterMap
          A Map that maps description strings to CyFileFilters
protected  File outputFile
          The file to be written.
protected  T writerManager
          The CyWriterManager specified in the constructor.
 
Fields inherited from class org.cytoscape.work.AbstractTask
cancelled
 
Constructor Summary
AbstractCyWriter(T writerManager)
          Constructor.
 
Method Summary
protected abstract  String getExportFileFormat()
          An implementation of this method should return a file format description from CyFileFilter, such that the string can be found in the descriptionFilterMap.
 File getOutputFile()
          This method gets the file to be written.
protected abstract  CyWriter getWriter(CyFileFilter filter, File out)
          Should return a CyWriter object for writing the specified file of the specified type.
 void run(TaskMonitor tm)
          This method processes the chosen input file and output type and attempts to write the file.
 void setOutputFile(File f)
          The method sets the file to be written.
 
Methods inherited from class org.cytoscape.work.AbstractTask
cancel, insertTasksAfterCurrentTask, insertTasksAfterCurrentTask, setTaskIterator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cytoscape.work.Task
cancel
 

Field Detail

outputFile

protected File outputFile
The file to be written.


descriptionFilterMap

protected final Map<String,CyFileFilter> descriptionFilterMap
A Map that maps description strings to CyFileFilters


writerManager

protected final T extends CyWriterManager writerManager
The CyWriterManager specified in the constructor.

Constructor Detail

AbstractCyWriter

public AbstractCyWriter(T writerManager)
Constructor.

Parameters:
writerManager - The CyWriterManager to be used to determine which CyWriter to be used to write the file chosen by the user.
Method Detail

setOutputFile

public final void setOutputFile(File f)
The method sets the file to be written. This field should not be called directly, but rather handled by the Tunable processing. This method is the "setter" portion of a getter/setter tunable method pair.

Parameters:
f - The file to be written.

getOutputFile

public File getOutputFile()
This method gets the file to be written. This method should not be called directly, but rather handled by the Tunable processing. This method is the "getter" portion of a getter/setter tunable method pair.

Returns:
The file to be written.

getExportFileFormat

protected abstract String getExportFileFormat()
An implementation of this method should return a file format description from CyFileFilter, such that the string can be found in the descriptionFilterMap.

Returns:
a file format description from CyFileFilter.

run

public final void run(TaskMonitor tm)
               throws Exception
This method processes the chosen input file and output type and attempts to write the file.

Specified by:
run in interface Task
Specified by:
run in class AbstractTask
Parameters:
tm - The TaskMonitor provided by the TaskManager execution environment.
Throws:
Exception - The Task is at liberty to throw an exception in run. The exception is caught by TaskManager and is displayed in the interface. If a Task does not throw an exception, the Task implementation does not need to specify the throws Exception clause for the run method. Moreover, exceptions should be the way the Task communicates the occurrence of a fatal error, like a low-level exception or an invalid parameter, to the TaskManager.

getWriter

protected abstract CyWriter getWriter(CyFileFilter filter,
                                      File out)
                               throws Exception
Should return a CyWriter object for writing the specified file of the specified type.

Parameters:
filter - The specific type of file to be written.
out - The file that will be written.
Returns:
a CyWriter object for writing the specified file of the specified type.
Throws:
Exception

Cytoscape 3.0.0-alpha8-SNAPSHOT API

Copyright 2011 Cytoscape Consortium. All rights reserved.