01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: * $Header:$
18: */
19: package org.apache.beehive.netui.tags.rendering;
20:
21: /**
22: * This class will render the constant HTML used by the tags
23: */
24: abstract public class ConstantRendering {
25: abstract public void BR(AbstractRenderAppender sb);
26:
27: public void TR_TD(AbstractRenderAppender sb) {
28: sb.append("<tr><td>");
29: }
30:
31: public void end_TD_TR(AbstractRenderAppender sb) {
32: sb.append("</td></tr>");
33: }
34:
35: public void TABLE(AbstractRenderAppender sb) {
36: sb.append("<table>");
37: }
38:
39: public void end_TABLE(AbstractRenderAppender sb) {
40: sb.append("</table>");
41: }
42:
43: public void NBSP(AbstractRenderAppender sb) {
44: sb.append(" ");
45: }
46:
47: private static class HtmlConstants extends ConstantRendering {
48: public void BR(AbstractRenderAppender sb) {
49: sb.append("<br>");
50: }
51: }
52:
53: private static class XhtmlConstants extends ConstantRendering {
54: public void BR(AbstractRenderAppender sb) {
55: sb.append("<br />");
56: }
57: }
58:
59: public static ConstantRendering getRendering(int type) {
60:
61: if (type == TagRenderingBase.HTML_RENDERING)
62: return new HtmlConstants();
63: if (type == TagRenderingBase.XHTML_RENDERING)
64: return new XhtmlConstants();
65: assert (false) : "Didn't find the requested contant renderer:"
66: + type;
67: return null;
68: }
69: }
|