KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > tree > ProcInstImpl


1 package com.icl.saxon.tree;
2 import com.icl.saxon.output.Outputter;
3
4 import org.w3c.dom.ProcessingInstruction JavaDoc;
5 import org.w3c.dom.DOMException JavaDoc;
6 import javax.xml.transform.TransformerException JavaDoc;
7
8 /**
9   * ProcInstImpl is an implementation of ProcInstInfo used by the Propagator to construct
10   * its trees.
11   * @author Michael H. Kay (mhkay@iclway.co.uk)
12   */

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

30     
31     public int getNameCode() {
32         return nameCode;
33     }
34
35     public String JavaDoc getStringValue() {
36         return content;
37     }
38
39     public final short getNodeType() {
40         return PI;
41     }
42
43     /**
44     * Set the system ID and line number
45     */

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

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

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

71
72     public void copy(Outputter out) throws TransformerException JavaDoc {
73         out.writePI(getLocalName(), content);
74     }
75
76     // DOM methods
77

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

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

93      
94     public String JavaDoc getData() {
95         return content;
96     }
97
98     /**
99      * Set the content of this PI. Always fails.
100      * @exception DOMException
101      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
102      */

103     
104     public void setData(String JavaDoc data) throws DOMException JavaDoc {
105         disallowUpdate();
106     }
107                                       
108 }
109
110
111 //
112
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
113
// you may not use this file except in compliance with the License. You may obtain a copy of the
114
// License at http://www.mozilla.org/MPL/
115
//
116
// Software distributed under the License is distributed on an "AS IS" basis,
117
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
118
// See the License for the specific language governing rights and limitations under the License.
119
//
120
// The Original Code is: all this file.
121
//
122
// The Initial Developer of the Original Code is
123
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
124
//
125
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
126
//
127
// Contributor(s): none.
128
//
129
Popular Tags