KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > mlw > vlh > web > tag > support > AbstractHTMLDisplayProvider


1 /*
2  * Created on 21.2.2005
3  * azachar
4  */

5 package net.mlw.vlh.web.tag.support;
6
7 import net.mlw.vlh.ValueListInfo;
8
9 /**
10  * AbstractHTMLDisplayProvider implement common parts for display providers.
11  * @author Andrej Zachar
12  * @version $Revision: 1.2 $ $Date: 2005/11/23 14:37:14 $
13  */

14 public abstract class AbstractHTMLDisplayProvider implements DisplayProvider
15 {
16
17    public boolean doesIncludeBodyContent()
18    {
19       return true;
20    }
21
22    /**
23     * @param String text
24     * @param String emphasisPattern
25     * @return Emphase text with emphasesis prefix and postfix. example: <a
26     * class='emphase'> emphasisPattern </a>
27     */

28    public String JavaDoc emphase(String JavaDoc text, String JavaDoc emphasisPattern, String JavaDoc style)
29    {
30       if (emphasisPattern == null)
31          return text;
32
33       StringBuffer JavaDoc replacement = new StringBuffer JavaDoc("<span class='" + style + "Emphase'>");
34       replacement.append(emphasisPattern);
35       replacement.append("</span>");
36       return text.replaceAll(emphasisPattern, replacement.toString());
37    }
38
39    /**
40     * Get the HTML that comes before the column text.
41     *
42     * @return The HTML that comes before the column text.
43     */

44    public String JavaDoc getHeaderRowPostProcess()
45    {
46       return "</tr>";
47    }
48
49    /**
50     * Get the HTML that comes before the column text.
51     *
52     * @return The HTML that comes before the column text.
53     */

54    public String JavaDoc getHeaderRowPreProcess()
55    {
56       return "\n<tr>";
57    }
58
59    public String JavaDoc getMimeType()
60    {
61       return null;
62    }
63
64    public String JavaDoc getRowPostProcess()
65    {
66       return "</tr>";
67    }
68
69    public String JavaDoc getRowPreProcess(Attributes attributes)
70    {
71       return (attributes == null) ? "\n<tr>" : "\n<tr " + attributes.getCellAttributesAsString() + ">";
72    }
73
74    public String JavaDoc getNestedHeaderPreProcess(ColumnInfo columnInfo, ValueListInfo info)
75    {
76       return (columnInfo.getAttributes() == null) ? "<table width=\"100%\">" : "<table width=\"100%\" " + columnInfo.getAttributes() + ">";
77    }
78
79    public String JavaDoc getNestedHeaderPostProcess()
80    {
81       return "</table>";
82    }
83 }
84
Popular Tags