KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > output > ProxyEmitter


1 package com.icl.saxon.output;
2 import com.icl.saxon.*;
3 import com.icl.saxon.om.NamePool;
4 import org.xml.sax.Attributes JavaDoc;
5 import org.xml.sax.Locator JavaDoc;
6 import java.io.*;
7 import java.util.*;
8 import javax.xml.transform.Result JavaDoc;
9 import javax.xml.transform.TransformerException JavaDoc;
10
11     /**
12     * A ProxyEmitter is an Emitter that filters data before passing it to another
13     * underlying Emitter.
14     */

15   
16 public abstract class ProxyEmitter extends Emitter
17 {
18     protected Emitter baseEmitter;
19     protected Properties outputProperties;
20     
21     /**
22     * Set the underlying emitter. This call is mandatory before using the Emitter.
23     */

24
25     public void setUnderlyingEmitter(Emitter emitter) {
26         baseEmitter = emitter;
27         if (namePool!=null) {
28             baseEmitter.setNamePool(namePool);
29         }
30     }
31
32     /**
33     * Set the name pool to be used for all name codes
34     */

35     
36     public void setNamePool(NamePool pool) {
37         super.setNamePool(pool);
38         if (baseEmitter!=null) {
39             baseEmitter.setNamePool(pool);
40         }
41     }
42
43     /**
44     * Set the result destination
45     */

46
47     public void setWriter (Writer writer) {
48         this.writer = writer;
49         if (baseEmitter!=null)
50             baseEmitter.setWriter(writer);
51     }
52
53     /**
54     * Start of document
55     */

56
57     public void startDocument() throws TransformerException JavaDoc {
58         if (baseEmitter==null) {
59             throw new TransformerException JavaDoc("ProxyEmitter.startDocument(): no underlying emitter provided");
60         }
61         baseEmitter.startDocument();
62     }
63
64     /**
65     * End of document
66     */

67
68     public void endDocument() throws TransformerException JavaDoc {
69         if (baseEmitter!=null) {
70             baseEmitter.endDocument();
71         }
72     }
73
74     /**
75     * Start of element
76     */

77
78     public void startElement(int nameCode, Attributes JavaDoc attributes,
79                              int[] namespaces, int nscount) throws TransformerException JavaDoc {
80         if (baseEmitter!=null) {
81             baseEmitter.startElement(nameCode, attributes, namespaces, nscount);
82         }
83     }
84
85     /**
86     * End of element
87     */

88
89     public void endElement(int nameCode) throws TransformerException JavaDoc {
90         if (baseEmitter!=null) {
91             baseEmitter.endElement(nameCode);
92         }
93     }
94
95     /**
96     * Character data
97     */

98
99     public void characters(char[] chars, int start, int len) throws TransformerException JavaDoc {
100         if (baseEmitter!=null) {
101             baseEmitter.characters(chars, start, len);
102         }
103     }
104
105
106     /**
107     * Processing Instruction
108     */

109
110     public void processingInstruction(String JavaDoc target, String JavaDoc data) throws TransformerException JavaDoc {
111         if (baseEmitter!=null) {
112             baseEmitter.processingInstruction(target, data);
113         }
114     }
115
116     /**
117     * Output a comment
118     */

119
120     public void comment (char ch[], int start, int length) throws TransformerException JavaDoc {
121         if (baseEmitter!=null) {
122             baseEmitter.comment(ch, start, length);
123         }
124     }
125
126
127     /**
128     * Switch escaping on or off. This is called when the XSLT disable-output-escaping attribute
129     * is used to switch escaping on or off. It is not called for other sections of output (e.g.
130     * element names) where escaping is inappropriate.
131     */

132
133     public void setEscaping(boolean escaping) throws TransformerException JavaDoc {
134         if (baseEmitter!=null) {
135             baseEmitter.setEscaping(escaping);
136         }
137     }
138     
139     /**
140     * Set the output details.
141     */

142     
143     public void setOutputProperties (Properties details) {
144         outputProperties = details;
145         if (baseEmitter!=null) {
146             baseEmitter.setOutputProperties(details);
147         }
148     }
149
150     /**
151     * Set the URI for an unparsed entity in the document.
152     */

153
154     public void setUnparsedEntity(String JavaDoc name, String JavaDoc uri) throws TransformerException JavaDoc {
155         if (baseEmitter!=null) {
156             baseEmitter.setUnparsedEntity(name, uri);
157         }
158     }
159     
160     /**
161     * Set the Document Locator
162     */

163     
164     public void setDocumentLocator(Locator JavaDoc locator) {
165         // System.err.println("ProxyEmitter.setDocumentLocator " + locator.getSystemId());
166
if (baseEmitter!=null) {
167             baseEmitter.setDocumentLocator(locator);
168         }
169     }
170 }
171
172 //
173
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
174
// you may not use this file except in compliance with the License. You may obtain a copy of the
175
// License at http://www.mozilla.org/MPL/
176
//
177
// Software distributed under the License is distributed on an "AS IS" basis,
178
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
179
// See the License for the specific language governing rights and limitations under the License.
180
//
181
// The Original Code is: all this file.
182
//
183
// The Initial Developer of the Original Code is
184
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
185
//
186
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
187
//
188
// Contributor(s): none.
189
//
190
Popular Tags