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: import net.sf.saxon.om.Navigator;
07:
08: /**
09: * TProcInstImpl is an implementation of ProcInstInfo
10: * @author Michael H. Kay
11: * @version 16 July 1999
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 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(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 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,
50: boolean copyAnnotations, int locationId)
51: throws XPathException {
52: out.processingInstruction(getDisplayName(), getStringValue(),
53: 0, 0);
54: }
55:
56: // DOM methods
57:
58: /**
59: * The target of this processing instruction. XML defines this as being
60: * the first token following the markup that begins the processing
61: * instruction.
62: */
63:
64: public String getTarget() {
65: return getDisplayName();
66: }
67:
68: /**
69: * The content of this processing instruction. This is from the first non
70: * white space character after the target to the character immediately
71: * preceding the <code>?></code> .
72: */
73:
74: public String getData() {
75: return getStringValue();
76: }
77:
78: }
79:
80: //
81: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
82: // you may not use this file except in compliance with the License. You may obtain a copy of the
83: // License at http://www.mozilla.org/MPL/
84: //
85: // Software distributed under the License is distributed on an "AS IS" basis,
86: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
87: // See the License for the specific language governing rights and limitations under the License.
88: //
89: // The Original Code is: all this file.
90: //
91: // The Initial Developer of the Original Code is Michael H. Kay.
92: //
93: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
94: //
95: // Contributor(s): none.
96: //
|