KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > tinytree > TinyCommentImpl


1 package com.icl.saxon.tinytree;
2 import com.icl.saxon.om.*;
3 import com.icl.saxon.output.Outputter;
4 import com.icl.saxon.Context;
5 import com.icl.saxon.tree.DOMExceptionImpl;
6
7 import javax.xml.transform.TransformerException JavaDoc;
8 import org.w3c.dom.Comment JavaDoc;
9 import org.w3c.dom.DOMException JavaDoc;
10
11
12 /**
13   * TinyCommentImpl is an implementation of CommentInfo
14   * @author Michael H. Kay (mhkay@iclway.co.uk)
15   */

16   
17
18 final class TinyCommentImpl extends TinyNodeImpl implements Comment JavaDoc {
19     
20     public TinyCommentImpl(TinyDocumentImpl doc, int nodeNr) {
21         this.document = doc;
22         this.nodeNr = nodeNr;
23     }
24
25     /**
26     * Get the XPath string value of the comment
27     */

28
29     public final String JavaDoc getStringValue() {
30         int start = document.offset[nodeNr];
31         int len = document.length[nodeNr];
32         if (len==0) return ""; // fix bug 6.0.2/005
33
char[] dest = new char[len];
34         document.commentBuffer.getChars(start, start+len, dest, 0);
35         return new String JavaDoc(dest, 0, len);
36     }
37
38     /**
39     * Get the node type
40     * @return NodeInfo.COMMENT
41     */

42
43     public final short getNodeType() {
44         return NodeInfo.COMMENT;
45     }
46
47     /**
48     * Copy this node to a given outputter
49     */

50
51     public void copy(Outputter out) throws TransformerException JavaDoc {
52         out.writeComment(getStringValue());
53     }
54     
55 }
56
57
58 //
59
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
60
// you may not use this file except in compliance with the License. You may obtain a copy of the
61
// License at http://www.mozilla.org/MPL/
62
//
63
// Software distributed under the License is distributed on an "AS IS" basis,
64
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
65
// See the License for the specific language governing rights and limitations under the License.
66
//
67
// The Original Code is: all this file.
68
//
69
// The Initial Developer of the Original Code is
70
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
71
//
72
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
73
//
74
// Contributor(s): none.
75
//
76
Popular Tags