1 package org.enhydra.xml;
2
3 import org.w3c.dom.Comment;
4 import org.w3c.dom.DOMException;
5 import org.w3c.dom.Node;
6
7 /***
8 * @author Tweety
9 *
10 * A class representing a node in a meta-data tree, which implements
11 * the <a href="../../../../api/org/w3c/dom/Comment.html">
12 *
13 * <p> Namespaces are ignored in this implementation. The terms "tag
14 * name" and "node name" are always considered to be synonymous.
15 *
16 * @version 1.0
17 */
18 public class CommentImpl extends CharacterDataImpl implements Comment {
19
20 /***
21 * Constructs a <code>CommentImpl</code> from the given node.
22 *
23 * @param node, as a <code>CommentImpl</code>.
24 */
25 public CommentImpl(CommentImpl node) {
26 super((NodeImpl)node);
27 }
28
29
30 /***
31 * Constructs a <code>CommentImpl</code> from the given node value.
32 *
33 * @param value, as a <code>String</code>.
34 */
35 public CommentImpl(String value) {
36 nodeValue = value;
37 type = Node.COMMENT_NODE;
38 }
39
40
41 /***
42 * Constructs a <code>CommentImpl</code> from a given node,
43 * as a <code>Node</code>
44 *
45 * @param node, as <code>Node</code>.
46 */
47 public CommentImpl(Node node) {
48 super(node);
49 }
50
51
52 /***
53 * Returns the node type.
54 *
55 * @return the <code>COMMENT_NODE</code> node type.
56 */
57 public short getNodeType() {
58 return Node.COMMENT_NODE;
59 }
60
61 /***
62 * Returns the name ("#comment") associated with this node.
63 *
64 * @return the name, as a <code>String</code>.
65 */
66 public String getNodeName() {
67 return "#comment";
68 }
69
70
71 /***
72 * Method beginToString for this class writes the xml
73 * comment prefix string and the comment string.
74 *
75 * @param sb string buffer to add resulting string.
76 * @param indent used in formating the output.
77 */
78 protected void beginToString(StringBuffer sb, Indent indent) {
79 sb.append("\n" + indent + "<!-- " + this.nodeValue.trim());
80 }
81
82
83 /***
84 * Method endToString writes the xml comment postfix string.
85 */
86 protected void endToString(StringBuffer sb, Indent indent) {
87 sb.append(" -->");
88 }
89
90
91 }
This page automatically generated by Maven