1 /*
2 Copyright (C) 2003 Together
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 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
19 package org.enhydra.xml;
20
21 import org.w3c.dom.Comment;
22 import org.w3c.dom.DOMException;
23 import org.w3c.dom.Node;
24
25 /***
26 * @author Tweety
27 *
28 * A class representing a node in a meta-data tree, which implements
29 * the <a href="../../../../api/org/w3c/dom/Comment.html">
30 *
31 * <p> Namespaces are ignored in this implementation. The terms "tag
32 * name" and "node name" are always considered to be synonymous.
33 *
34 * @version 1.0
35 */
36 public class CommentImpl extends CharacterDataImpl implements Comment {
37
38 /***
39 * Constructs a <code>CommentImpl</code> from the given node.
40 *
41 * @param node , as a <code>CommentImpl</code>.
42 */
43 public CommentImpl(CommentImpl node) {
44 super((NodeImpl)node);
45 }
46
47
48 /***
49 * Constructs a <code>CommentImpl</code> from the given node value.
50 *
51 * @param value , as a <code>String</code>.
52 */
53 public CommentImpl(String value) {
54 nodeValue = value;
55 type = Node.COMMENT_NODE;
56 }
57
58
59 /***
60 * Constructs a <code>CommentImpl</code> from a given node,
61 * as a <code>Node</code>
62 *
63 * @param node , as <code>Node</code>.
64 */
65 public CommentImpl(Node node) {
66 super(node);
67 }
68
69
70 /***
71 * Returns the node type.
72 *
73 * @return the <code>COMMENT_NODE</code> node type.
74 */
75 public short getNodeType() {
76 return Node.COMMENT_NODE;
77 }
78
79 /***
80 * Returns the name ("#comment") associated with this node.
81 *
82 * @return the name, as a <code>String</code>.
83 */
84 public String getNodeName() {
85 return "#comment";
86 }
87
88
89 /***
90 * Method beginToString for this class writes the xml
91 * comment prefix string and the comment string.
92 *
93 * @param sb string buffer to add resulting string.
94 * @param indent used in formating the output.
95 */
96 protected void beginToString(StringBuffer sb, Indent indent) {
97 sb.append("\n" + indent + "<!-- " + this.nodeValue.trim());
98 }
99
100
101 /***
102 * Method endToString writes the xml comment postfix string.
103 * @param sb represents StringBuffer
104 * @param indent is indent
105 */
106 protected void endToString(StringBuffer sb, Indent indent) {
107 sb.append(" -->");
108 }
109
110
111 }
This page was automatically generated by Maven