01: package net.sf.saxon.tinytree;
02:
03: import net.sf.saxon.event.Receiver;
04: import net.sf.saxon.trans.XPathException;
05: import net.sf.saxon.type.Type;
06:
07: /**
08: * TinyCommentImpl is an implementation of CommentInfo
09: * @author Michael H. Kay
10: */
11:
12: final class TinyCommentImpl extends TinyNodeImpl {
13:
14: public TinyCommentImpl(TinyTree tree, int nodeNr) {
15: this .tree = tree;
16: this .nodeNr = nodeNr;
17: }
18:
19: /**
20: * Get the XPath string value of the comment
21: */
22:
23: public final String getStringValue() {
24: int start = tree.alpha[nodeNr];
25: int len = tree.beta[nodeNr];
26: if (len == 0)
27: return "";
28: char[] dest = new char[len];
29: tree.commentBuffer.getChars(start, start + len, dest, 0);
30: return new String(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,
47: boolean copyAnnotations, int locationId)
48: throws XPathException {
49: out.comment(getStringValue(), 0, 0);
50: }
51:
52: }
53:
54: //
55: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
56: // you may not use this file except in compliance with the License. You may obtain a copy of the
57: // License at http://www.mozilla.org/MPL/
58: //
59: // Software distributed under the License is distributed on an "AS IS" basis,
60: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
61: // See the License for the specific language governing rights and limitations under the License.
62: //
63: // The Original Code is: all this file.
64: //
65: // The Initial Developer of the Original Code is Michael H. Kay.
66: //
67: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
68: //
69: // Contributor(s): none.
70: //
|