KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.icl.saxon.tinytree;
2 //import com.icl.saxon.om.*;
3
import com.icl.saxon.output.Outputter;
4
5 import javax.xml.transform.TransformerException JavaDoc;
6 import org.w3c.dom.ProcessingInstruction JavaDoc;
7 import org.w3c.dom.DOMException JavaDoc;
8
9 /**
10   * TProcInstImpl is an implementation of ProcInstInfo
11   * @author Michael H. Kay (mhkay@iclway.co.uk)
12   * @version 16 July 1999
13   */

14   
15
16 final class TinyProcInstImpl extends TinyNodeImpl implements ProcessingInstruction JavaDoc {
17     
18     public TinyProcInstImpl(TinyDocumentImpl doc, int nodeNr) {
19         this.document = doc;
20         this.nodeNr = nodeNr;
21     }
22
23     public String JavaDoc getStringValue() {
24         int start = document.offset[nodeNr];
25         int len = document.length[nodeNr];
26         if (len==0) {
27             return ""; // need to special-case this for the Microsoft JVM
28
}
29         char[] dest = new char[len];
30         document.commentBuffer.getChars(start, start+len, dest, 0);
31         return new String JavaDoc(dest, 0, len);
32     }
33
34     public final short getNodeType() {
35         return PI;
36     }
37
38     /**
39     * Copy this node to a given outputter
40     */

41
42     public void copy(Outputter out) throws TransformerException JavaDoc {
43         out.writePI(getDisplayName(), getStringValue());
44     }
45
46     // DOM methods
47

48     /**
49      * The target of this processing instruction. XML defines this as being
50      * the first token following the markup that begins the processing
51      * instruction.
52      */

53      
54     public String JavaDoc getTarget() {
55         return getDisplayName();
56     }
57
58     /**
59      * The content of this processing instruction. This is from the first non
60      * white space character after the target to the character immediately
61      * preceding the <code>?&gt;</code> .
62      */

63      
64     public String JavaDoc getData() {
65         return getStringValue();
66     }
67
68     /**
69      * Set the content of this PI. Always fails.
70      * @exception DOMException
71      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
72      */

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