KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > tree > ProcInstImpl


1 package net.sf.saxon.tree;
2 import net.sf.saxon.event.Receiver;
3 import net.sf.saxon.trans.XPathException;
4 import net.sf.saxon.type.Type;
5
6 /**
7   * ProcInstImpl is an implementation of ProcInstInfo used by the Propagator to construct
8   * its trees.
9   * @author Michael H. Kay
10   */

11
12
13 class ProcInstImpl extends NodeImpl {
14
15     String JavaDoc content;
16     int nameCode;
17     String JavaDoc systemId;
18     int lineNumber = -1;
19
20     public ProcInstImpl(int nameCode, String JavaDoc content) {
21         this.nameCode = nameCode;
22         this.content = content;
23     }
24
25     /**
26     * Get the nameCode of the node. This is used to locate the name in the NamePool
27     */

28
29     public int getNameCode() {
30         return nameCode;
31     }
32
33     public String JavaDoc getStringValue() {
34         return content;
35     }
36
37     public final int getNodeKind() {
38         return Type.PROCESSING_INSTRUCTION;
39     }
40
41     /**
42     * Set the system ID and line number
43     */

44
45     public void setLocation(String JavaDoc uri, int lineNumber) {
46         this.systemId = uri;
47         this.lineNumber = lineNumber;
48     }
49
50     /**
51     * Get the system ID for the entity containing this node.
52     */

53
54     public String JavaDoc getSystemId() {
55         return systemId;
56     }
57
58     /**
59     * Get the line number of the node within its source entity
60     */

61
62     public int getLineNumber() {
63         return lineNumber;
64     }
65
66     /**
67     * Copy this node to a given outputter
68     */

69
70     public void copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId) throws XPathException {
71         out.processingInstruction(getLocalPart(), content, locationId, 0);
72     }
73
74     // DOM methods
75

76     /**
77      * The target of this processing instruction. XML defines this as being
78      * the first token following the markup that begins the processing
79      * instruction.
80      */

81
82     public String JavaDoc getTarget() {
83         return getLocalPart();
84     }
85
86     /**
87      * The content of this processing instruction. This is from the first non
88      * white space character after the target to the character immediately
89      * preceding the <code>?&gt;</code> .
90      */

91
92     public String JavaDoc getData() {
93         return content;
94     }
95
96
97 }
98
99
100 //
101
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
102
// you may not use this file except in compliance with the License. You may obtain a copy of the
103
// License at http://www.mozilla.org/MPL/
104
//
105
// Software distributed under the License is distributed on an "AS IS" basis,
106
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
107
// See the License for the specific language governing rights and limitations under the License.
108
//
109
// The Original Code is: all this file.
110
//
111
// The Initial Developer of the Original Code is Michael H. Kay.
112
//
113
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
114
//
115
// Contributor(s): none.
116
//
117
Popular Tags