01: /*
02: * Copyright (C) 2004 TiongHiang Lee
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: * Email: thlee@onemindsoft.org
19: */
20:
21: package org.onemind.swingweb.client.awt;
22:
23: import java.util.ArrayList;
24: import org.onemind.swingweb.client.dom.DomDocument;
25: import org.onemind.swingweb.client.dom.DomNode;
26: import org.w3c.dom.*;
27:
28: public class W3CDomNode implements DomNode {
29:
30: /** the element **/
31: private Node _node;
32:
33: /** the lazy loaded child nodes **/
34: private ArrayList _childNodes = null;
35:
36: /** the parent **/
37: private W3CDomNode _parent;
38:
39: /**
40: * Constructor
41: * @param e the element
42: */
43: public W3CDomNode(Node node, W3CDomNode parent) {
44: _node = node;
45: _parent = parent;
46: }
47:
48: public String getAttribute(String name) {
49: if (_node instanceof Element) {
50: return ((Element) _node).getAttribute(name);
51: } else {
52: return null;
53: }
54: }
55:
56: public ArrayList getChildNodes() {
57: if (_childNodes == null) {
58: _childNodes = new ArrayList();
59: NodeList list = _node.getChildNodes();
60: for (int i = 0; i < list.getLength(); i++) {
61: Node n = list.item(i);
62: _childNodes.add(new W3CDomNode(n, this ));
63: }
64: }
65: // TODO Auto-generated method stub
66: return _childNodes;
67: }
68:
69: public DomDocument getDocument() {
70: // TODO Auto-generated method stub
71: return null;
72: }
73:
74: public String getName() {
75: return _node.getNodeName();
76: }
77:
78: public DomNode getParent() {
79: return _parent;
80: }
81:
82: public String getType() {
83: return null;
84: }
85:
86: public String getValue() {
87: return null;
88: }
89:
90: public void appendChild(DomNode node) {
91: throw new UnsupportedOperationException();
92: }
93: }
|