/* * GNTHTMLWriter.java * * Created on December 8, 2003, 11:13 PM */ package gnt; import java.io.*; import palm.conduit.Log; import java.sql.*; /** * * @author Owner */ public class GNTHTMLWriter { private File path = null; private PrintWriter out = null; /** Creates a new instance of GNTHTMLWriter */ public GNTHTMLWriter(String backupFile) { path = (new File(backupFile)).getParentFile(); } void print(GNTRecord record) { GNTFile[] files = record.files; for (int i = 0; i < files.length; i++) { String filename = path.getAbsolutePath() + path.separatorChar + files[i].getName() + ".html"; StringBuffer output = new StringBuffer(); try { out = new PrintWriter(new FileOutputStream(filename)); String[] lines = Util.split(files[i].getFileText(), "\n"); out.println("" + files[i].getName() + ""); out.println(""); if (lines.length > 1) output.append("

" + lines[0] + "

\n"); else output.append(lines[0] + "
\n"); for (int j = 1; j < lines.length; j++) output.append(lines[j] + "
\n"); output.append(""); String item, value; GNTConnection con = new GNTConnection(); ResultSet rs = null; StringBuffer rOutput = null; try { con.init("dummy", "gnotet"); rs = con.execQ("Select * from replacement"); while (rs.next()) { rOutput = new StringBuffer(); int beg = 0; int end = 0; while (end > -1) { item = rs.getString("item"); value = rs.getString("value"); end = Util.indexOf(output, item, beg); if (end > -1) { rOutput.append(output.substring(beg, end)).append(value); beg = end + item.length(); } } rOutput.append(output.substring(beg)); output = rOutput; } } catch (SQLException sqle) { } con.closeRS(rs); con.close(); out.println(output.toString()); out.flush(); out.close(); } catch (FileNotFoundException fnfe) { } } } }