Author: mes
Date: 2012-04-12 13:52:03 -0700 (Thu, 12 Apr 2012)
New Revision: 28807
Added:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/AbstractCyWriter.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/AbstractCyWriterTest.java
Removed:
core3/api/trunk/io-api/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
core3/api/trunk/io-api/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
Modified:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/TunableAbstractCyWriter.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/network/CyNetworkViewWriterTest.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/io/ViewWriterTest.java
Log:
Moved confusing object to the only place it's used.
Deleted:
core3/api/trunk/io-api/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
===================================================================
---
core3/api/trunk/io-api/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
2012-04-12 20:36:48 UTC (rev 28806)
+++
core3/api/trunk/io-api/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -1,117 +0,0 @@
-package org.cytoscape.io.write;
-
-
-import org.cytoscape.work.AbstractTask;
-import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.Tunable;
-import org.cytoscape.work.util.ListSingleSelection;
-import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.CyWriter;
-import org.cytoscape.io.write.CyWriterManager;
-
-import java.io.File;
-
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.ArrayList;
-
-
-/**
- * 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
- * {@link org.cytoscape.io.write.CyWriter} can be identified.
- * @param <T> Generic type that extends CyWriterManager.
- * @CyAPI.Abstract.Class
- */
-public abstract class AbstractCyWriter<S extends CyWriterFactory,T extends
CyWriterManager<S>> extends AbstractTask
- implements CyWriter
-{
- /** The file to be written. */
- protected File outputFile;
-
- /**
- * The method sets the file to be written. This field should not
- * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
- * processing. This method is the "setter" portion of a
- * getter/setter tunable method pair.
- * @param f The file to be written.
- */
- public final void setOutputFile(File f) {
- if ( f != null )
- outputFile = f;
- }
-
- /**
- * This method gets the file to be written. This method should not
- * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
- * processing. This method is the "getter" portion of a
- * getter/setter tunable method pair.
- * @return The file to be written.
- */
- public File getOutputFile() {
- return outputFile;
- }
-
- /** An implementation of this method should return a file format
description
- * from {@link CyFileFilter}, such that the string can be found in the
descriptionFilterMap.
- * @return a file format description from {@link CyFileFilter}.
- */
- abstract protected String getExportFileFormat();
- /** A Map that maps description strings to {@link CyFileFilter}s*/
- protected final Map<String,CyFileFilter> descriptionFilterMap;
-
- /**
- * The CyWriterManager specified in the constructor.
- */
- protected final T writerManager;
-
- /**
- * Constructor.
- * @param writerManager The CyWriterManager to be used to determine
which
- * {@link org.cytoscape.io.write.CyWriter} to be used to write the file
chosen by the user.
- */
- public AbstractCyWriter(T writerManager) {
- if (writerManager == null)
- throw new NullPointerException("CyWriterManager is
null");
- this.writerManager = writerManager;
-
- descriptionFilterMap = new TreeMap<String,CyFileFilter>();
- for (CyFileFilter f : writerManager.getAvailableWriterFilters())
- descriptionFilterMap.put(f.getDescription(), f);
- }
-
- /**
- * This method processes the chosen input file and output type and
attempts
- * to write the file.
- * @param tm The {@link org.cytoscape.work.TaskMonitor} provided by the
TaskManager execution environment.
- */
- public final void run(final TaskMonitor tm) throws Exception {
- if (outputFile == null)
- throw new NullPointerException("Output file has not ben
specified!");
-
- final String desc = getExportFileFormat();
- if (desc == null)
- throw new NullPointerException("No file type has been
specified!");
-
- final CyFileFilter filter = descriptionFilterMap.get(desc);
- if (filter == null)
- throw new NullPointerException("No file filter found
for specified file type!");
-
- final CyWriter writer = getWriter(filter, outputFile);
- if (writer == null)
- throw new NullPointerException("No CyWriter found for
specified file type!");
-
- insertTasksAfterCurrentTask(writer);
- }
-
- /**
- * Should return a {@link org.cytoscape.io.write.CyWriter} object for
writing the specified file of the specified type.
- * @param filter The specific type of file to be written.
- * @param out The file that will be written.
- * @return a {@link org.cytoscape.io.write.CyWriter} object for writing
the specified file of the specified type.
- * @throws Exception
- */
- protected abstract CyWriter getWriter(CyFileFilter filter, File out)
throws Exception;
-
-}
Deleted:
core3/api/trunk/io-api/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
===================================================================
---
core3/api/trunk/io-api/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
2012-04-12 20:36:48 UTC (rev 28806)
+++
core3/api/trunk/io-api/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -1,28 +0,0 @@
-package org.cytoscape.io.write;
-
-
-import java.io.File;
-
-import org.cytoscape.io.CyFileFilter;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-
-public abstract class AbstractCyWriterTest {
- protected AbstractCyWriter cyWriter;
- protected CyFileFilter fileFilter;
-
- @Test
- public void testOutputFile() {
- final File outputFile = new File("dummy");
- cyWriter.setOutputFile(outputFile);
- assertEquals(outputFile, cyWriter.getOutputFile());
- }
-
- @Test
- public void testGetWriter() throws Exception {
- final File outputFile = new File("dummy");
- assertNotNull(cyWriter.getWriter(fileFilter, outputFile));
- }
-}
Copied:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/AbstractCyWriter.java
(from rev 28806,
core3/api/trunk/io-api/src/main/java/org/cytoscape/io/write/AbstractCyWriter.java)
===================================================================
---
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/AbstractCyWriter.java
(rev 0)
+++
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/AbstractCyWriter.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -0,0 +1,118 @@
+package org.cytoscape.task.internal.export;
+
+
+import org.cytoscape.work.AbstractTask;
+import org.cytoscape.work.TaskMonitor;
+import org.cytoscape.work.Tunable;
+import org.cytoscape.work.util.ListSingleSelection;
+import org.cytoscape.io.CyFileFilter;
+import org.cytoscape.io.write.CyWriter;
+import org.cytoscape.io.write.CyWriterFactory;
+import org.cytoscape.io.write.CyWriterManager;
+
+import java.io.File;
+
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.ArrayList;
+
+
+/**
+ * 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
+ * {@link org.cytoscape.io.write.CyWriter} can be identified.
+ * @param <T> Generic type that extends CyWriterManager.
+ * @CyAPI.Abstract.Class
+ */
+public abstract class AbstractCyWriter<S extends CyWriterFactory,T extends
CyWriterManager<S>> extends AbstractTask
+ implements CyWriter
+{
+ /** The file to be written. */
+ protected File outputFile;
+
+ /**
+ * The method sets the file to be written. This field should not
+ * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing. This method is the "setter" portion of a
+ * getter/setter tunable method pair.
+ * @param f The file to be written.
+ */
+ public final void setOutputFile(File f) {
+ if ( f != null )
+ outputFile = f;
+ }
+
+ /**
+ * This method gets the file to be written. This method should not
+ * be called directly, but rather handled by the {@link
org.cytoscape.work.Tunable}
+ * processing. This method is the "getter" portion of a
+ * getter/setter tunable method pair.
+ * @return The file to be written.
+ */
+ public File getOutputFile() {
+ return outputFile;
+ }
+
+ /** An implementation of this method should return a file format
description
+ * from {@link CyFileFilter}, such that the string can be found in the
descriptionFilterMap.
+ * @return a file format description from {@link CyFileFilter}.
+ */
+ abstract protected String getExportFileFormat();
+ /** A Map that maps description strings to {@link CyFileFilter}s*/
+ protected final Map<String,CyFileFilter> descriptionFilterMap;
+
+ /**
+ * The CyWriterManager specified in the constructor.
+ */
+ protected final T writerManager;
+
+ /**
+ * Constructor.
+ * @param writerManager The CyWriterManager to be used to determine
which
+ * {@link org.cytoscape.io.write.CyWriter} to be used to write the file
chosen by the user.
+ */
+ public AbstractCyWriter(T writerManager) {
+ if (writerManager == null)
+ throw new NullPointerException("CyWriterManager is
null");
+ this.writerManager = writerManager;
+
+ descriptionFilterMap = new TreeMap<String,CyFileFilter>();
+ for (CyFileFilter f : writerManager.getAvailableWriterFilters())
+ descriptionFilterMap.put(f.getDescription(), f);
+ }
+
+ /**
+ * This method processes the chosen input file and output type and
attempts
+ * to write the file.
+ * @param tm The {@link org.cytoscape.work.TaskMonitor} provided by the
TaskManager execution environment.
+ */
+ public final void run(final TaskMonitor tm) throws Exception {
+ if (outputFile == null)
+ throw new NullPointerException("Output file has not ben
specified!");
+
+ final String desc = getExportFileFormat();
+ if (desc == null)
+ throw new NullPointerException("No file type has been
specified!");
+
+ final CyFileFilter filter = descriptionFilterMap.get(desc);
+ if (filter == null)
+ throw new NullPointerException("No file filter found
for specified file type!");
+
+ final CyWriter writer = getWriter(filter, outputFile);
+ if (writer == null)
+ throw new NullPointerException("No CyWriter found for
specified file type!");
+
+ insertTasksAfterCurrentTask(writer);
+ }
+
+ /**
+ * Should return a {@link org.cytoscape.io.write.CyWriter} object for
writing the specified file of the specified type.
+ * @param filter The specific type of file to be written.
+ * @param out The file that will be written.
+ * @return a {@link org.cytoscape.io.write.CyWriter} object for writing
the specified file of the specified type.
+ * @throws Exception
+ */
+ protected abstract CyWriter getWriter(CyFileFilter filter, File out)
throws Exception;
+
+}
Modified:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/TunableAbstractCyWriter.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/TunableAbstractCyWriter.java
2012-04-12 20:36:48 UTC (rev 28806)
+++
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/export/TunableAbstractCyWriter.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -7,7 +7,6 @@
import java.util.Iterator;
import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.AbstractCyWriter;
import org.cytoscape.io.write.CyWriterManager;
import org.cytoscape.io.write.CyWriterFactory;
import org.cytoscape.work.Tunable;
Copied:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/AbstractCyWriterTest.java
(from rev 28806,
core3/api/trunk/io-api/src/test/java/org/cytoscape/io/write/AbstractCyWriterTest.java)
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/AbstractCyWriterTest.java
(rev 0)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/AbstractCyWriterTest.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -0,0 +1,29 @@
+package org.cytoscape.task.internal.export;
+
+
+import java.io.File;
+
+import org.cytoscape.io.CyFileFilter;
+import org.cytoscape.task.internal.export.AbstractCyWriter;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+
+public abstract class AbstractCyWriterTest {
+ protected AbstractCyWriter cyWriter;
+ protected CyFileFilter fileFilter;
+
+ @Test
+ public void testOutputFile() {
+ final File outputFile = new File("dummy");
+ cyWriter.setOutputFile(outputFile);
+ assertEquals(outputFile, cyWriter.getOutputFile());
+ }
+
+ @Test
+ public void testGetWriter() throws Exception {
+ final File outputFile = new File("dummy");
+ assertNotNull(cyWriter.getWriter(fileFilter, outputFile));
+ }
+}
Modified:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/network/CyNetworkViewWriterTest.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/network/CyNetworkViewWriterTest.java
2012-04-12 20:36:48 UTC (rev 28806)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/export/network/CyNetworkViewWriterTest.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -12,8 +12,8 @@
import org.cytoscape.ding.NetworkViewTestSupport;
import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.AbstractCyWriterTest;
import org.cytoscape.io.write.CyNetworkViewWriterManager;
+import org.cytoscape.task.internal.export.AbstractCyWriterTest;
import org.cytoscape.view.model.CyNetworkView;
import org.junit.Before;
import org.junit.Test;
Modified:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/io/ViewWriterTest.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/io/ViewWriterTest.java
2012-04-12 20:36:48 UTC (rev 28806)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/io/ViewWriterTest.java
2012-04-12 20:52:03 UTC (rev 28807)
@@ -11,9 +11,9 @@
import java.util.List;
import org.cytoscape.io.CyFileFilter;
-import org.cytoscape.io.write.AbstractCyWriterTest;
import org.cytoscape.io.write.CyWriter;
import org.cytoscape.io.write.PresentationWriterManager;
+import org.cytoscape.task.internal.export.AbstractCyWriterTest;
import org.cytoscape.task.internal.export.ViewWriter;
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.RenderingEngine;
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.