1 4 package org.ashkelon.pages; 5 6 import java.io.*; 7 import de.java2html.converter.*; 8 import de.java2html.javasource.*; 9 import de.java2html.options.*; 10 11 16 class Java2HtmlGenerator implements HtmlGenerator 17 { 18 private Java2HtmlConversionOptions _options = null; 19 20 public void initialize(File srcHtmlDir) 21 { 22 _options = Java2HtmlConversionOptions.getDefault(); 23 _options.setTabSize(3); 24 _options.setShowLineNumbers(true); 25 _options.setShowJava2HtmlLink(false); 26 _options.setShowFileName(true); 27 } 28 29 public void produceHtml(String sourceFile, String realHtmlFile) 30 { 31 try 32 { 33 java2HtmlConvert(new File(sourceFile), new File(realHtmlFile)); 34 } 35 catch (IOException ex) 36 { 37 System.err.println("Failed to build html from java source"); 38 System.err.println("IO Exception: " + ex.getMessage()); 39 ex.printStackTrace(); 40 } 41 } 42 43 private void java2HtmlConvert(File sourceFile, File htmlFile) throws IOException 44 { 45 htmlFile.getParentFile().mkdirs(); 46 47 JavaSourceConverter converter = new JavaSource2HTMLConverter(); 48 converter.setConversionOptions(_options); 49 JavaSourceParser parser = new JavaSourceParser(_options); 50 JavaSource jsource = parser.parse(sourceFile); 51 converter.convert(jsource, new FileWriter(htmlFile)); 52 } 53 54 } 55 | Popular Tags |