01: package net.homeip.donaldm.testng.templates;
02:
03: import java.io.File;
04: import java.io.InputStream;
05: import net.homeip.donaldm.httpdbase4j.Request;
06:
07: import org.antlr.stringtemplate.StringTemplate;
08: import net.homeip.donaldm.httpdbase4j.TemplatableAdapter;
09:
10: public class Pagetemplate extends TemplatableAdapter
11: //--------------------------------------------------
12: {
13: private SelItem[] selList;
14:
15: public Pagetemplate() {
16: selList = new SelItem[6];
17: for (int i = 0; i < 5; i++)
18: selList[i] = new SelItem("OPT" + i, "Option " + (i + 1));
19: selList[5] = new SelItem("OPT5", "Option 6", true);
20:
21: }
22:
23: private void setTemplateAttributes(StringTemplate template,
24: Request request)
25: // ---------------------------------------------------------
26: {
27: template.setAttribute("selList", selList);
28: if (System.getProperty("os.name").toLowerCase().contains(
29: "windows"))
30: template.setAttribute("welcome", "Welcome Dumbass");
31: else
32: template.setAttribute("welcome", "Welcome Master");
33: }
34:
35: public java.io.File templateFile(StringTemplate template,
36: Request request, StringBuffer mimeType, File dir)
37: // ---------------------------------------------------------------------
38: {
39: setTemplateAttributes(template, request);
40: return super .templateFile(template, request, mimeType, dir);
41: }
42:
43: public String templateString(StringTemplate template,
44: Request request, StringBuffer mimeType)
45: // -----------------------------------------------------------------------
46: {
47: setTemplateAttributes(template, request);
48: return super .templateString(template, request, mimeType);
49: }
50:
51: public InputStream templateStream(StringTemplate template,
52: Request request, StringBuffer mimeType)
53: // -------------------------------------------------------------------------
54: {
55: setTemplateAttributes(template, request);
56: return super.templateStream(template, request, mimeType);
57: }
58: }
|