KickJava   Java API By Example, From Geeks To Geeks.

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


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

4 package org.ashkelon.pages;
5
6 import java.io.File JavaDoc;
7 import java.io.IOException JavaDoc;
8 import com.java2html.Java2HTML;
9
10 /**
11  * implementation based on the tool "j2h" ; see http://www.java2html.com/
12  *
13  * @author Eitan Suez
14  */

15 class J2HGenerator implements HtmlGenerator
16 {
17    private Java2HTML j2h = null;
18
19    public void initialize(File JavaDoc srcHtmlDir)
20    {
21       j2h = new Java2HTML();
22       j2h.setMarginSize(4);
23       j2h.setTabSize(3);
24       j2h.setSimple(true);
25
26       try
27       {
28          j2h.setDestination(srcHtmlDir.getCanonicalPath());
29       }
30       catch (IOException JavaDoc ex)
31       {
32          System.err.println("Failed to obtain canonical path for "+srcHtmlDir.toString());
33          System.err.println("IO Exception: "+ex.getMessage());
34          ex.printStackTrace();
35       }
36    }
37    
38    public void produceHtml(String JavaDoc sourceFile, String JavaDoc realHtmlFile)
39    {
40       // problem with jar and obfuscation hiding method even though in javadocs:
41
//j2h.setJavaFileSource( new String[] {sourceFile} );
42
try
43       {
44          j2h.setJavaDirectorySource(new String JavaDoc[] {dirof(sourceFile)} );
45          j2h.buildJava2HTML();
46       }
47       catch (Exception JavaDoc ex)
48       {
49          System.err.println("Failed to build html from java source");
50          System.err.println(ex.getMessage());
51          ex.printStackTrace();
52       }
53    }
54
55    private String JavaDoc dirof(String JavaDoc file)
56    {
57       return new File JavaDoc(file).getParent();
58    }
59 }
60
61
Popular Tags