KickJava   Java API By Example, From Geeks To Geeks.

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


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 import net.sf.saxon.om.Navigator;
6
7 /**
8   * TProcInstImpl is an implementation of ProcInstInfo
9   * @author Michael H. Kay
10   * @version 16 July 1999
11   */

12
13
14 final class TinyProcInstImpl extends TinyNodeImpl {
15
16     public TinyProcInstImpl(TinyTree tree, int nodeNr) {
17         this.tree = tree;
18         this.nodeNr = nodeNr;
19     }
20
21     public String JavaDoc getStringValue() {
22         int start = tree.alpha[nodeNr];
23         int len = tree.beta[nodeNr];
24         if (len==0) {
25             return ""; // need to special-case this for the Microsoft JVM
26
}
27         char[] dest = new char[len];
28         tree.commentBuffer.getChars(start, start+len, dest, 0);
29         return new String JavaDoc(dest, 0, len);
30     }
31
32     public final int getNodeKind() {
33         return Type.PROCESSING_INSTRUCTION;
34     }
35
36     /**
37     * Get the base URI of this element node. This will be the same as the System ID unless
38     * xml:base has been used.
39     */

40
41     public String JavaDoc getBaseURI() {
42         return Navigator.getBaseURI(this);
43     }
44
45     /**
46     * Copy this node to a given outputter
47     */

48
49     public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException {
50         out.processingInstruction(getDisplayName(), getStringValue(), 0, 0);
51     }
52
53     // DOM methods
54

55     /**
56      * The target of this processing instruction. XML defines this as being
57      * the first token following the markup that begins the processing
58      * instruction.
59      */

60
61     public String JavaDoc getTarget() {
62         return getDisplayName();
63     }
64
65     /**
66      * The content of this processing instruction. This is from the first non
67      * white space character after the target to the character immediately
68      * preceding the <code>?&gt;</code> .
69      */

70
71     public String JavaDoc getData() {
72         return getStringValue();
73     }
74
75 }
76
77
78 //
79
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
80
// you may not use this file except in compliance with the License. You may obtain a copy of the
81
// License at http://www.mozilla.org/MPL/
82
//
83
// Software distributed under the License is distributed on an "AS IS" basis,
84
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
85
// See the License for the specific language governing rights and limitations under the License.
86
//
87
// The Original Code is: all this file.
88
//
89
// The Initial Developer of the Original Code is Michael H. Kay.
90
//
91
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
92
//
93
// Contributor(s): none.
94
//
95
Popular Tags