01: /* Node.java
02:
03: {{IS_NOTE
04: Purpose:
05:
06: Description:
07:
08: History:
09: Sat Sep 17 13:53:14 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.util.Collections;
22: import java.util.List;
23: import java.util.LinkedList;
24: import java.io.Writer;
25: import java.io.IOException;
26:
27: /**
28: * Represents a node in an {@link org.zkoss.web.servlet.dsp.Interpretation}.
29: *
30: * @author tomyeh
31: */
32: abstract class Node {
33: protected List _children;
34:
35: /** Interprets the node to generate the result to the output
36: * specified in the interpret context.
37: */
38: abstract void interpret(InterpretContext ic)
39: throws javax.servlet.ServletException, IOException;
40:
41: /** Adds a child. */
42: void addChild(Node node) {
43: if (node == null)
44: throw new IllegalArgumentException("null");
45: if (_children == null)
46: _children = new LinkedList();
47: _children.add(node);
48: }
49:
50: /** Adds a child to the specified position. */
51: void addChild(int pos, Node node) {
52: if (node == null)
53: throw new IllegalArgumentException("null");
54: if (_children == null)
55: _children = new LinkedList();
56: _children.add(pos, node);
57: }
58:
59: /** Returns the list of child nodes ({@link Node}).
60: * @since 3.0.0
61: */
62: public List getChildren() {
63: return _children != null ? _children : Collections.EMPTY_LIST;
64: }
65: }
|