01: /* XmlNativeComponent.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Thu Aug 23 17:29:06 2007, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2007 Potix Corporation. All Rights Reserved.
13:
14: {{IS_RIGHT
15: This program is distributed under GPL Version 2.0 in the hope that
16: it will be useful, but WITHOUT ANY WARRANTY.
17: }}IS_RIGHT
18: */
19: package org.zkoss.zml;
20:
21: import java.util.Collection;
22: import java.util.Map;
23:
24: import org.zkoss.xml.XMLs;
25:
26: import org.zkoss.zk.ui.Component;
27: import org.zkoss.zk.ui.HtmlNativeComponent;
28: import org.zkoss.zk.ui.ext.DynamicTag;
29: import org.zkoss.zk.ui.ext.Native;
30: import org.zkoss.zk.ui.impl.NativeHelpers;
31:
32: /**
33: * A comonent used to represent XML elements that are associated
34: * with the inline namespace (http://www.zkoss.org/2005/zk/inline).
35: *
36: * <p>It contains the content that shall be sent directly to client.
37: * It has three parts: prolog, children and epilog.
38: * The prolog ({@link #getPrologContent}) and epilog ({@link #getEpilogContent})
39: * are both {@link String}.
40: *
41: * <p>When this component is renderred ({@link #redraw}), it generates
42: * the prolog first, the children and then the epilog.
43: *
44: * @author tomyeh
45: * @since 3.0.0
46: */
47: public class XmlNativeComponent extends HtmlNativeComponent {
48: private static final Helper _helper = new XmlHelper();
49:
50: //super//
51: public Helper getHelper() {
52: return _helper;
53: }
54:
55: /** The HTML helper.
56: */
57: public static class XmlHelper implements Helper {
58: public Component newNative(String text) {
59: final XmlNativeComponent nc = new XmlNativeComponent();
60: if (text != null)
61: nc.setPrologContent(text);
62: return nc;
63: }
64:
65: public void getFirstHalf(StringBuffer sb, String tag,
66: Map props, Collection namespaces) {
67: if (tag != null)
68: sb.append('<').append(tag);
69:
70: NativeHelpers.getAttributes(sb, props, namespaces);
71:
72: if (tag != null)
73: sb.append(">");
74: }
75:
76: public void getSecondHalf(StringBuffer sb, String tag) {
77: if (tag != null)
78: sb.append("</").append(tag).append(">\n");
79: }
80:
81: public void appendText(StringBuffer sb, String text) {
82: XMLs.encodeText(sb, text);
83: }
84: }
85: }
|