1 17 18 19 20 21 27 28 package org.apache.fop.render.rtf.rtflib.testdocs; 29 30 import java.io.File ; 31 import java.io.IOException ; 32 34 38 39 public class CreateTestDocuments { 40 41 44 public static final String TESTDOCS_PACKAGE = "org.apache.fop.render.rtf.rtflib.testdocs"; 45 46 47 private static final String [] CLASS_NAMES = { 48 "SimpleDocument", 49 "TextAttributes", 50 "SimpleTable", 51 "SimpleLists", 52 "ListInTable", 53 "Whitespace", 54 "MergedTableCells", 55 "NestedTable", 56 "ExternalGraphic", 57 "BasicLink", 58 "ParagraphAlignment" 59 }; 60 61 CreateTestDocuments(File outDir) 62 throws Exception { 63 if (!outDir.isDirectory() || !outDir.canWrite()) { 64 throw new IOException ("output directory (" + outDir + ") must exist and be writable"); 65 } 66 67 for (int i = 0; i < CLASS_NAMES.length; i++) { 68 createOneTestDocument(CLASS_NAMES[i], outDir); 69 } 70 } 71 72 73 void createOneTestDocument(String className, File outDir) 74 throws Exception { 75 className = TESTDOCS_PACKAGE + "." + className; 76 TestDocument td = null; 77 try { 78 td = (TestDocument)Class.forName(className).newInstance(); 79 } catch (Exception e) { 80 throw new Exception ("unable to instantiate '" + className 81 + " as a TestDocument object: " + e); 82 } 83 td.setOutputDir(outDir); 84 try { 85 td.generateOutput(); 86 } catch (Exception e) { 87 System.err.println("Error while generating test RTF document:"); 88 e.printStackTrace(); 89 } 90 } 91 92 96 public static void main(String [] args) 97 throws Exception { 98 if (args.length < 1) { 99 System.err.println("usage: CreateTestDocuments <output directory>"); 100 System.exit(1); 101 } 102 103 System.err.println("Generates documents to test the RTF library."); 105 final File outDir = new File (args[0]); 106 new CreateTestDocuments(outDir); 107 System.err.println("CreateTestDocuments - all done."); 108 System.exit(0); 109 } 110 } 111 | Popular Tags |