KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > tags > rendering > ConstantRendering


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.tags.rendering;
19
20 /**
21  * This class will render the constant HTML used by the tags
22  */

23 abstract public class ConstantRendering
24 {
25     abstract public void BR(AbstractRenderAppender sb);
26
27     public void TR_TD(AbstractRenderAppender sb)
28     {
29         sb.append("<tr><td>");
30     }
31
32     public void end_TD_TR(AbstractRenderAppender sb)
33     {
34         sb.append("</td></tr>");
35     }
36
37     public void TABLE(AbstractRenderAppender sb)
38     {
39         sb.append("<table>");
40     }
41
42     public void end_TABLE(AbstractRenderAppender sb)
43     {
44         sb.append("</table>");
45     }
46
47     public void NBSP(AbstractRenderAppender sb)
48     {
49         sb.append("&nbsp;");
50     }
51
52     private static class HtmlConstants extends ConstantRendering
53     {
54         public void BR(AbstractRenderAppender sb)
55         {
56             sb.append("<br>");
57         }
58     }
59
60     private static class XhtmlConstants extends ConstantRendering
61     {
62         public void BR(AbstractRenderAppender sb)
63         {
64             sb.append("<br />");
65         }
66     }
67
68     public static ConstantRendering getRendering(int type)
69     {
70
71         if (type == TagRenderingBase.HTML_RENDERING)
72             return new HtmlConstants();
73         if (type == TagRenderingBase.XHTML_RENDERING)
74             return new XhtmlConstants();
75         assert (false) : "Didn't find the requested contant renderer:" + type;
76         return null;
77     }
78 }
79
Popular Tags