KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > tinytree > TinyCommentImpl


1 package net.sf.saxon.tinytree;
2 import net.sf.saxon.event.Receiver;
3 import net.sf.saxon.trans.XPathException;
4 import net.sf.saxon.type.Type;
5
6
7 /**
8   * TinyCommentImpl is an implementation of CommentInfo
9   * @author Michael H. Kay
10   */

11
12
13 final class TinyCommentImpl extends TinyNodeImpl {
14
15     public TinyCommentImpl(TinyTree tree, int nodeNr) {
16         this.tree = tree;
17         this.nodeNr = nodeNr;
18     }
19
20     /**
21     * Get the XPath string value of the comment
22     */

23
24     public final String JavaDoc getStringValue() {
25         int start = tree.alpha[nodeNr];
26         int len = tree.beta[nodeNr];
27         if (len==0) return "";
28         char[] dest = new char[len];
29         tree.commentBuffer.getChars(start, start+len, dest, 0);
30         return new String JavaDoc(dest, 0, len);
31     }
32
33     /**
34     * Get the node type
35     * @return Type.COMMENT
36     */

37
38     public final int getNodeKind() {
39         return Type.COMMENT;
40     }
41
42     /**
43     * Copy this node to a given outputter
44     */

45
46     public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException {
47         out.comment(getStringValue(), 0, 0);
48     }
49
50 }
51
52
53 //
54
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
55
// you may not use this file except in compliance with the License. You may obtain a copy of the
56
// License at http://www.mozilla.org/MPL/
57
//
58
// Software distributed under the License is distributed on an "AS IS" basis,
59
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
60
// See the License for the specific language governing rights and limitations under the License.
61
//
62
// The Original Code is: all this file.
63
//
64
// The Initial Developer of the Original Code is Michael H. Kay.
65
//
66
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
67
//
68
// Contributor(s): none.
69
//
70
Popular Tags