Title: [789] trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java: Made print method public in StoryToDirectoryPrinter.
Revision
789
Author
mauro
Date
2007-09-05 09:37:49 -0500 (Wed, 05 Sep 2007)

Log Message

Made print method public in StoryToDirectoryPrinter.
Removed redundant exceptions.  Minor variable renames.

Modified Paths

Diff

Modified: trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java (788 => 789)

--- trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java	2007-09-05 14:28:57 UTC (rev 788)
+++ trunk/core/src/java/org/jbehave/core/story/StoryToDirectoryPrinter.java	2007-09-05 14:37:49 UTC (rev 789)
@@ -6,52 +6,51 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 
-import org.jbehave.core.story.codegen.parser.TextStoryParser;
 import org.jbehave.core.story.domain.Story;
 import org.jbehave.core.story.renderer.PlainTextRenderer;
 
 public class StoryToDirectoryPrinter {
-    
-    private final StoryLoader loader;
+
+    private final StoryLoader storyLoader;
     private final File directory;
 
-    public StoryToDirectoryPrinter(StoryLoader loader, File directory) {
+    public StoryToDirectoryPrinter(StoryLoader storyLoader, File directory) {
         if (!directory.exists()) {
             throw new IllegalArgumentException("Directory " + directory + " does not exist.");
         }
         if (!directory.isDirectory()) {
             throw new IllegalArgumentException("Directory " + directory + " is not a directory.");
         }
-        
-        this.loader = loader;
+
+        this.storyLoader = storyLoader;
         this.directory = directory;
     }
 
+    public void print(String storyClassName) throws IOException {
+        Story story = storyLoader.loadStoryClass(storyClassName);
+        String simpleStoryName = simpleStoryName(story);
 
-    private void print(String storyClass) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
-        Story story = loader.loadStoryClass(storyClass);
-        String[] storyNameParts = story.getClass().getName().split("\\.");
-        String simpleStoryName = storyNameParts[storyNameParts.length - 1];
-        
         File file = new File(directory, simpleStoryName + ".story");
         if (!file.exists()) {
             file.createNewFile();
         }
         OutputStream outputStream = new FileOutputStream(file);
-        new StoryPrinter(loader, new PlainTextRenderer(new PrintStream(outputStream))).print(storyClass);
-        
+        new StoryPrinter(storyLoader, new PlainTextRenderer(new PrintStream(outputStream))).print(storyClassName);
+
         outputStream.close();
     }
 
-    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
-        File directory = new File(args[0]);                      
-    
-        StoryToDirectoryPrinter printer = new StoryToDirectoryPrinter(
-                new StoryLoader(new TextStoryParser(), Thread.currentThread().getContextClassLoader()),
-                directory);
-                
+    private String simpleStoryName(Story story) {
+        String[] storyNameParts = story.getClass().getName().split("\\.");
+        return storyNameParts[storyNameParts.length - 1];
+    }
+
+    public static void main(String[] args) throws IOException {
+        File directory = new File(args[0]);
+        StoryToDirectoryPrinter printer = new StoryToDirectoryPrinter(new StoryLoader(), directory);
+
         for (int i = 1; i < args.length; i++) {
-            printer.print(args[i]); 
-        }           
+            printer.print(args[i]);
+        }
     }
 }


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to