1 4 package org.ashkelon.pages; 5 6 import java.io.File ; 7 import java.io.IOException ; 8 import com.java2html.Java2HTML; 9 10 15 class J2HGenerator implements HtmlGenerator 16 { 17 private Java2HTML j2h = null; 18 19 public void initialize(File 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 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 sourceFile, String realHtmlFile) 39 { 40 try 43 { 44 j2h.setJavaDirectorySource(new String [] {dirof(sourceFile)} ); 45 j2h.buildJava2HTML(); 46 } 47 catch (Exception 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 dirof(String file) 56 { 57 return new File (file).getParent(); 58 } 59 } 60 61 | Popular Tags |