| 1 |
< |
//---PACKAGE DECLARATION--- |
| 2 |
< |
|
| 3 |
< |
//---IMPORTS--- |
| 4 |
< |
import java.io.*; |
| 5 |
< |
|
| 6 |
< |
|
| 7 |
< |
/** |
| 8 |
< |
* Connects to the database to produce reports. |
| 9 |
< |
* |
| 10 |
< |
* @author $Author$ |
| 11 |
< |
* @version $Id$ |
| 12 |
< |
*/ |
| 13 |
< |
public class SHTMLMaker { |
| 14 |
< |
|
| 15 |
< |
//---FINAL ATTRIBUTES--- |
| 16 |
< |
|
| 17 |
< |
/** |
| 18 |
< |
* The current CVS revision of this class |
| 19 |
< |
*/ |
| 20 |
< |
public final String REVISION = "$Revision$"; |
| 21 |
< |
|
| 22 |
< |
//---STATIC METHODS--- |
| 23 |
< |
|
| 24 |
< |
//---CONSTRUCTORS--- |
| 25 |
< |
|
| 26 |
< |
public SHTMLMaker(String metaDescription, String metaKeywords, String title, String graphFile, int width, int height, PlotData pd){ |
| 27 |
< |
|
| 28 |
< |
_metaDescription = metaDescription; |
| 29 |
< |
_metaKeywords = metaKeywords; |
| 30 |
< |
_title = title; |
| 31 |
< |
_graphFile = graphFile; |
| 32 |
< |
_width = width; |
| 33 |
< |
_height = height; |
| 34 |
< |
_pd = pd; |
| 35 |
< |
|
| 36 |
< |
} |
| 37 |
< |
|
| 38 |
< |
public void writePage(String filename) throws IOException{ |
| 39 |
< |
|
| 40 |
< |
BufferedWriter bw = null; |
| 41 |
< |
try { |
| 42 |
< |
bw = new BufferedWriter(new FileWriter(filename)); |
| 43 |
< |
} |
| 44 |
< |
catch (IOException e){ |
| 45 |
< |
System.out.println("Could not write to the SHTML page: "+e); |
| 46 |
< |
} |
| 47 |
< |
|
| 48 |
< |
// Use the layout functions in SHTMLLayout... |
| 49 |
< |
|
| 50 |
< |
IscreamLayout.printDocType(bw); |
| 51 |
< |
|
| 52 |
< |
IscreamLayout.printHeader(bw, _title, _metaDescription, _metaKeywords); |
| 53 |
< |
|
| 54 |
< |
IscreamLayout.printLeftMenu(bw); |
| 55 |
< |
|
| 56 |
< |
IscreamLayout.printTitle(bw, _title); |
| 57 |
< |
|
| 58 |
< |
IscreamLayout.printGraph(bw, _graphFile, _width, _height); |
| 59 |
< |
|
| 60 |
< |
IscreamLayout.printTable(bw, _pd); |
| 61 |
< |
|
| 62 |
< |
IscreamLayout.printBottom(bw); |
| 63 |
< |
|
| 64 |
< |
bw.flush(); |
| 65 |
< |
bw.close(); |
| 66 |
< |
|
| 67 |
< |
System.out.println(" - Written SHTML page"); |
| 68 |
< |
|
| 69 |
< |
} |
| 70 |
< |
|
| 71 |
< |
//---PUBLIC METHODS--- |
| 72 |
< |
|
| 73 |
< |
|
| 74 |
< |
/** |
| 75 |
< |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 76 |
< |
* method to provide clean logging (every class should have this). |
| 77 |
< |
* |
| 78 |
< |
* @return the name of this class and its CVS revision |
| 79 |
< |
*/ |
| 80 |
< |
public String toString() { |
| 81 |
< |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
| 82 |
< |
} |
| 83 |
< |
|
| 84 |
< |
//---PRIVATE METHODS--- |
| 85 |
< |
|
| 86 |
< |
//---ACCESSOR/MUTATOR METHODS--- |
| 87 |
< |
|
| 88 |
< |
//---ATTRIBUTES--- |
| 89 |
< |
|
| 90 |
< |
private String _metaDescription; |
| 91 |
< |
private String _metaKeywords; |
| 92 |
< |
private String _title; |
| 93 |
< |
private String _graphFile; |
| 94 |
< |
private int _width; |
| 95 |
< |
private int _height; |
| 96 |
< |
private PlotData _pd; |
| 97 |
< |
|
| 98 |
< |
//---STATIC ATTRIBUTES--- |
| 99 |
< |
|
| 100 |
< |
} |
| 1 |
> |
//---PACKAGE DECLARATION--- |
| 2 |
|
|
| 3 |
+ |
|
| 4 |
|
|
| 5 |
+ |
//---IMPORTS--- |
| 6 |
|
|
| 7 |
+ |
import java.io.*; |
| 8 |
|
|
| 9 |
+ |
|
| 10 |
|
|
| 11 |
+ |
|
| 12 |
|
|
| 13 |
+ |
/** |
| 14 |
|
|
| 15 |
+ |
* Produces an SHTML document. |
| 16 |
|
|
| 17 |
+ |
* |
| 18 |
|
|
| 19 |
+ |
* @author $Author$ |
| 20 |
|
|
| 21 |
+ |
* @version $Id$ |
| 22 |
|
|
| 23 |
+ |
*/ |
| 24 |
|
|
| 25 |
+ |
public class SHTMLMaker { |
| 26 |
|
|
| 27 |
+ |
|
| 28 |
|
|
| 29 |
+ |
//---FINAL ATTRIBUTES--- |
| 30 |
|
|
| 31 |
+ |
|
| 32 |
|
|
| 33 |
+ |
/** |
| 34 |
|
|
| 35 |
+ |
* The current CVS revision of this class |
| 36 |
|
|
| 37 |
+ |
*/ |
| 38 |
|
|
| 39 |
+ |
public final String REVISION = "$Revision$"; |
| 40 |
|
|
| 41 |
+ |
|
| 42 |
|
|
| 43 |
+ |
//---STATIC METHODS--- |
| 44 |
|
|
| 45 |
+ |
|
| 46 |
|
|
| 47 |
+ |
//---CONSTRUCTORS--- |
| 48 |
|
|
| 49 |
+ |
|
| 50 |
|
|
| 51 |
+ |
public SHTMLMaker(String metaDescription, String metaKeywords, String title, String friendlyName, String graphFile, int width, int height, PlotData pd, int type, long startDate, long endDate){ |
| 52 |
|
|
| 53 |
+ |
|
| 54 |
|
|
| 55 |
+ |
_metaDescription = metaDescription; |
| 56 |
|
|
| 57 |
+ |
_metaKeywords = metaKeywords; |
| 58 |
|
|
| 59 |
+ |
_title = title; |
| 60 |
|
|
| 61 |
+ |
_friendlyName = friendlyName; |
| 62 |
|
|
| 63 |
+ |
_graphFile = graphFile; |
| 64 |
|
|
| 65 |
+ |
_width = width; |
| 66 |
|
|
| 67 |
+ |
_height = height; |
| 68 |
|
|
| 69 |
+ |
_pd = pd; |
| 70 |
|
|
| 71 |
+ |
_type = type; |
| 72 |
|
|
| 73 |
+ |
_startDate = startDate; |
| 74 |
|
|
| 75 |
+ |
_endDate = endDate; |
| 76 |
|
|
| 77 |
+ |
|
| 78 |
|
|
| 79 |
+ |
} |
| 80 |
|
|
| 81 |
+ |
|
| 82 |
|
|
| 83 |
+ |
public void writePage(String filename) throws IOException{ |
| 84 |
|
|
| 85 |
+ |
|
| 86 |
|
|
| 87 |
+ |
BufferedWriter bw = null; |
| 88 |
|
|
| 89 |
+ |
try { |
| 90 |
|
|
| 91 |
+ |
bw = new BufferedWriter(new FileWriter(filename)); |
| 92 |
|
|
| 93 |
+ |
} |
| 94 |
|
|
| 95 |
+ |
catch (IOException e){ |
| 96 |
|
|
| 97 |
+ |
System.out.println("Could not write to the SHTML page: "+e); |
| 98 |
|
|
| 99 |
+ |
} |
| 100 |
|
|
| 101 |
+ |
|
| 102 |
|
|
| 103 |
+ |
// Use the layout functions in SHTMLLayout... |
| 104 |
|
|
| 105 |
+ |
|
| 106 |
|
|
| 107 |
+ |
IscreamLayout.printDocType(bw); |
| 108 |
|
|
| 109 |
+ |
|
| 110 |
|
|
| 111 |
+ |
IscreamLayout.printHeader(bw, _title, _metaDescription, _metaKeywords); |
| 112 |
|
|
| 113 |
+ |
|
| 114 |
|
|
| 115 |
+ |
IscreamLayout.printLeftMenu(bw); |
| 116 |
|
|
| 117 |
+ |
|
| 118 |
|
|
| 119 |
+ |
IscreamLayout.printTitle(bw, _title+"<br>"+"("+_friendlyName+")"); |
| 120 |
|
|
| 121 |
+ |
|
| 122 |
|
|
| 123 |
+ |
IscreamLayout.printGraph(bw, _graphFile, _width, _height, _type, _startDate, _endDate); |
| 124 |
|
|
| 125 |
+ |
|
| 126 |
|
|
| 127 |
+ |
// Let's leave this bit out for now... |
| 128 |
|
|
| 129 |
+ |
//IscreamLayout.printTable(bw, _pd); |
| 130 |
|
|
| 131 |
+ |
|
| 132 |
|
|
| 133 |
+ |
IscreamLayout.printBottom(bw); |
| 134 |
|
|
| 135 |
+ |
|
| 136 |
|
|
| 137 |
+ |
bw.flush(); |
| 138 |
|
|
| 139 |
+ |
bw.close(); |
| 140 |
|
|
| 141 |
+ |
|
| 142 |
|
|
| 143 |
+ |
System.out.println(" - Written SHTML page"); |
| 144 |
|
|
| 145 |
+ |
|
| 146 |
|
|
| 147 |
+ |
} |
| 148 |
|
|
| 149 |
+ |
|
| 150 |
|
|
| 151 |
+ |
//---PUBLIC METHODS--- |
| 152 |
|
|
| 153 |
+ |
|
| 154 |
|
|
| 155 |
+ |
|
| 156 |
|
|
| 157 |
+ |
/** |
| 158 |
|
|
| 159 |
+ |
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 160 |
|
|
| 161 |
+ |
* method to provide clean logging (every class should have this). |
| 162 |
|
|
| 163 |
+ |
* |
| 164 |
|
|
| 165 |
+ |
* @return the name of this class and its CVS revision |
| 166 |
|
|
| 167 |
+ |
*/ |
| 168 |
|
|
| 169 |
+ |
public String toString() { |
| 170 |
|
|
| 171 |
+ |
return this.getClass().getName() + "(" + REVISION.substring(11, REVISION.length() - 2) + ")"; |
| 172 |
|
|
| 173 |
+ |
} |
| 174 |
|
|
| 175 |
+ |
|
| 176 |
|
|
| 177 |
+ |
//---PRIVATE METHODS--- |
| 178 |
|
|
| 179 |
+ |
|
| 180 |
|
|
| 181 |
+ |
//---ACCESSOR/MUTATOR METHODS--- |
| 182 |
|
|
| 183 |
+ |
|
| 184 |
|
|
| 185 |
+ |
//---ATTRIBUTES--- |
| 186 |
|
|
| 187 |
+ |
|
| 188 |
|
|
| 189 |
+ |
private String _metaDescription; |
| 190 |
|
|
| 191 |
+ |
private String _metaKeywords; |
| 192 |
|
|
| 193 |
+ |
private String _title; |
| 194 |
|
|
| 195 |
+ |
private String _friendlyName; |
| 196 |
|
|
| 197 |
+ |
private String _graphFile; |
| 198 |
|
|
| 199 |
+ |
private int _width; |
| 200 |
|
|
| 201 |
+ |
private int _height; |
| 202 |
|
|
| 203 |
+ |
private PlotData _pd; |
| 204 |
|
|
| 205 |
+ |
private int _type; |
| 206 |
|
|
| 207 |
+ |
private long _startDate; |
| 208 |
|
|
| 209 |
+ |
private long _endDate; |
| 210 |
|
|
| 211 |
+ |
|
| 212 |
|
|
| 213 |
+ |
//---STATIC ATTRIBUTES--- |
| 214 |
|
|
| 215 |
+ |
|
| 216 |
|
|
| 217 |
+ |
} |
| 218 |
|
|