01: /* TextNode.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Sat Sep 17 14:11:45 2005, Created by tomyeh
10: }}IS_NOTE
11:
12: Copyright (C) 2004 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.web.servlet.dsp.impl;
20:
21: import java.io.Writer;
22: import java.io.IOException;
23:
24: /**
25: * Represents a node holding a plain text.
26: *
27: * @author tomyeh
28: */
29: class TextNode extends Node {
30: private final String _text;
31:
32: TextNode(String text) {
33: _text = text;
34: }
35:
36: /** Returns the text.
37: * @since 3.0.0
38: */
39: public String getText() {
40: return _text;
41: }
42:
43: //-- super --//
44: void interpret(InterpretContext ic)
45: throws javax.servlet.ServletException, IOException {
46: ic.dc.getOut().write(_text);
47: }
48:
49: void addChild(Node node) {
50: throw new IllegalStateException("No child allowed");
51: }
52:
53: public String toString() {
54: return "TextNode["
55: + (_text.length() > 20 ? _text.substring(0, 20) : _text)
56: + ']';
57: }
58: }
|