KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ashkelon > pages > Java2HtmlGenerator


1 /*
2  * Created on Jul 29, 2004
3  */

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 /**
12  * implementation based on the tool "Java2Html" ; see http://www.java2html.de/
13  *
14  * @author Eitan Suez
15  */

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 JavaDoc sourceFile, String JavaDoc 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