KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > CommentImpl


1 package org.enhydra.xml;
2
3 import org.w3c.dom.Comment JavaDoc;
4 import org.w3c.dom.Node JavaDoc;
5
6 /**
7  * @author Tweety
8  *
9  * A class representing a node in a meta-data tree, which implements
10  * the <a HREF="../../../../api/org/w3c/dom/Comment.html">
11  *
12  * <p> Namespaces are ignored in this implementation. The terms "tag
13  * name" and "node name" are always considered to be synonymous.
14  *
15  * @version 1.0
16  */

17 public class CommentImpl extends CharacterDataImpl implements Comment JavaDoc {
18
19     /**
20      * Constructs a <code>CommentImpl</code> from the given node.
21      *
22      * @param node, as a <code>CommentImpl</code>.
23      */

24     public CommentImpl(CommentImpl node) {
25         super((NodeImpl)node);
26     }
27
28
29     /**
30      * Constructs a <code>CommentImpl</code> from the given node value.
31      *
32      * @param value, as a <code>String</code>.
33      */

34     public CommentImpl(String JavaDoc value) {
35         nodeValue = value;
36         type = Node.COMMENT_NODE;
37     }
38     
39     
40     /**
41      * Constructs a <code>CommentImpl</code> from a given node,
42      * as a <code>Node</code>
43      *
44      * @param node, as <code>Node</code>.
45      */

46     public CommentImpl(Node JavaDoc node) {
47         super(node);
48     }
49
50
51     /**
52      * Returns the node type.
53      *
54      * @return the <code>COMMENT_NODE</code> node type.
55      */

56     public short getNodeType() {
57         return Node.COMMENT_NODE;
58     }
59
60     /**
61      * Returns the name ("#comment") associated with this node.
62      *
63      * @return the name, as a <code>String</code>.
64      */

65     public String JavaDoc getNodeName() {
66         return "#comment";
67     }
68     
69     
70     /**
71      * Method beginToString for this class writes the xml
72      * comment prefix string and the comment string.
73      *
74      * @param sb string buffer to add resulting string.
75      * @param indent used in formating the output.
76      */

77     protected void beginToString(StringBuffer JavaDoc sb, Indent indent) {
78         sb.append("\n" + indent + "<!-- " + this.nodeValue.trim());
79     }
80     
81     
82     /**
83      * Method endToString writes the xml comment postfix string.
84      */

85     protected void endToString(StringBuffer JavaDoc sb, Indent indent) {
86         sb.append(" -->");
87     }
88     
89
90 }
91
Popular Tags