| 1 |
//---PACKAGE DECLARATION--- |
| 2 |
|
| 3 |
//---IMPORTS--- |
| 4 |
import java.io.*; |
| 5 |
import java.util.*; |
| 6 |
|
| 7 |
|
| 8 |
/** |
| 9 |
* Produces an SHTML index. This class should be extended. |
| 10 |
* |
| 11 |
* @author $Author: $ |
| 12 |
* @version $Id: $ |
| 13 |
*/ |
| 14 |
public class IndexMaker { |
| 15 |
|
| 16 |
//---FINAL ATTRIBUTES--- |
| 17 |
|
| 18 |
/** |
| 19 |
* The current CVS revision of this class |
| 20 |
*/ |
| 21 |
public final String REVISION = "$Revision: $"; |
| 22 |
|
| 23 |
private final String _metaDescription = ""; |
| 24 |
private final String _metaKeywords = ""; |
| 25 |
|
| 26 |
//---STATIC METHODS--- |
| 27 |
|
| 28 |
//---CONSTRUCTORS--- |
| 29 |
|
| 30 |
public IndexMaker(LinkedList pages, String title){ |
| 31 |
|
| 32 |
_title = title; |
| 33 |
|
| 34 |
Iterator it = pages.iterator(); |
| 35 |
while (it.hasNext()){ |
| 36 |
ReportPage rp = (ReportPage)it.next(); |
| 37 |
_filtered.add(rp); |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
|
| 42 |
public void writePage(String filename) throws IOException{ |
| 43 |
|
| 44 |
BufferedWriter bw = null; |
| 45 |
try { |
| 46 |
bw = new BufferedWriter(new FileWriter(filename)); |
| 47 |
} |
| 48 |
catch (IOException e){ |
| 49 |
System.out.println("Could not write to the SHTML page: "+e); |
| 50 |
} |
| 51 |
|
| 52 |
// Use the layout functions in SHTMLLayout... |
| 53 |
|
| 54 |
IscreamLayout.printDocType(bw); |
| 55 |
|
| 56 |
IscreamLayout.printHeader(bw, _title, _metaDescription, _metaKeywords); |
| 57 |
|
| 58 |
IscreamLayout.printLeftMenu(bw); |
| 59 |
|
| 60 |
IscreamLayout.printTitle(bw, _title); |
| 61 |
|
| 62 |
IscreamLayout.printLinkedList(bw, _filtered); |
| 63 |
|
| 64 |
IscreamLayout.printBottom(bw); |
| 65 |
|
| 66 |
bw.flush(); |
| 67 |
bw.close(); |
| 68 |
|
| 69 |
System.out.println(" - Written SHTML Index page"); |
| 70 |
|
| 71 |
} |
| 72 |
|
| 73 |
//---PUBLIC METHODS--- |
| 74 |
|
| 75 |
|
| 76 |
/** |
| 77 |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 78 |
* method to provide clean logging (every class should have this). |
| 79 |
* |
| 80 |
* @return the name of this class and its CVS revision |
| 81 |
*/ |
| 82 |
public String toString() { |
| 83 |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
| 84 |
} |
| 85 |
|
| 86 |
//---PRIVATE METHODS--- |
| 87 |
|
| 88 |
//---ACCESSOR/MUTATOR METHODS--- |
| 89 |
|
| 90 |
//---ATTRIBUTES--- |
| 91 |
|
| 92 |
private LinkedList _filtered; |
| 93 |
private String _title; |
| 94 |
|
| 95 |
//---STATIC ATTRIBUTES--- |
| 96 |
|
| 97 |
} |