import java.util.Hashtable; import java.io.*; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Vector; import java.util.Enumeration; public class BuildPageIndex implements FormDataBehavior, Serializable { private Hashtable tags; private String company; private String date; private transient BufferedWriter output; private String filename; private Vector index; private String indexEntryLabel; class IndexEntry implements Serializable { String label; String url; public IndexEntry(String label, String url) { this.label = label; this.url = url; } } public BuildPageIndex(Hashtable tags, String label) { this.tags = tags; // list of tag translations (if any) indexEntryLabel = label; try { FileInputStream fIn = new FileInputStream("index.objects"); ObjectInputStream in = new ObjectInputStream(fIn); try { index = (Vector)in.readObject(); } catch (IOException io) { System.err.println(io); } } catch (Exception io) { // first time program is run, no persistence file index = new Vector(50); } } public void enter() { try { Calendar c = new GregorianCalendar(); int day = c.get(Calendar.DAY_OF_MONTH); int month = c.get(Calendar.MONTH); int year = c.get(Calendar.YEAR); int d = c.get(Calendar.MILLISECOND); filename = "t"+month+"-"+day+"-"+year+"-"+d+".html"; output = new BufferedWriter(new FileWriter(filename)); output.write(""); output.newLine(); output.write("
"); output.newLine(); output.write(""); output.write(""); output.newLine(); String t=tag; if ( tags!=null ) { // translate tags if table exists t = (String)tags.get(tag); if ( t==null ) { return; // don't print entries for tags with no translation } } output.write(""+t+""); output.newLine(); output.write(" | "); output.newLine(); output.write(""); output.newLine(); printAsHTML(value); output.write(" | "); output.newLine(); output.write("