KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.tinytree;
2 import com.icl.saxon.output.Outputter;
3 import com.icl.saxon.Version;
4 import com.icl.saxon.tree.DOMExceptionImpl;
5 import javax.xml.transform.TransformerException JavaDoc;
6
7 import org.w3c.dom.*;
8
9 /**
10   * A node in the XML parse tree representing character content<P>
11   * @author <A HREF="mailto:mhkay@iclway.co.uk>Michael H. Kay</A>
12   */

13
14 final class TinyTextImpl extends TinyNodeImpl implements Text {
15
16     public TinyTextImpl(TinyDocumentImpl doc, int nodeNr) {
17         this.document = doc;
18         this.nodeNr = nodeNr;
19     }
20
21     /**
22     * Return the character value of the node.
23     * @return the string value of the node
24     */

25
26     public String JavaDoc getStringValue() {
27         int start = document.offset[nodeNr];
28         int len = document.length[nodeNr];
29         return new String JavaDoc(document.charBuffer, start, len);
30     }
31
32     /**
33     * Return the type of node.
34     * @return Node.TEXT
35     */

36
37     public final short getNodeType() {
38         return TEXT;
39     }
40     
41     /**
42     * Copy this node to a given outputter
43     */

44
45     public void copy(Outputter out) throws TransformerException JavaDoc {
46         int start = document.offset[nodeNr];
47         int len = document.length[nodeNr];
48         out.writeContent(document.charBuffer, start, len);
49     }
50
51     /**
52     * Copy the string-value of this node to a given outputter
53     */

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