KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > event > ProxyReceiver


1 package net.sf.saxon.event;
2
3 import net.sf.saxon.Configuration;
4 import net.sf.saxon.om.NamePool;
5 import net.sf.saxon.trans.XPathException;
6
7 /**
8  * A ProxyReceiver is an Receiver that filters data before passing it to another
9  * underlying Receiver.
10  */

11
12 public abstract class ProxyReceiver extends SequenceReceiver {
13     protected Receiver nextReceiver;
14     protected String JavaDoc systemId;
15
16     public void setSystemId(String JavaDoc systemId) {
17         if (systemId != this.systemId) {
18             this.systemId = systemId;
19             if (nextReceiver != null) {
20                 nextReceiver.setSystemId(systemId);
21             }
22         }
23     }
24
25     public String JavaDoc getSystemId() {
26         return systemId;
27     }
28
29     /**
30      * Set the underlying receiver. This call is mandatory before using the Receiver.
31      */

32
33     public void setUnderlyingReceiver(Receiver receiver) {
34         if (receiver != nextReceiver) {
35             nextReceiver = receiver;
36             if (pipelineConfiguration != null) {
37                 nextReceiver.setPipelineConfiguration(pipelineConfiguration);
38             }
39         }
40     }
41
42     /**
43      * Get the underlying Receiver (that is, the next one in the pipeline)
44      */

45
46     public Receiver getUnderlyingReceiver() {
47         return nextReceiver;
48     }
49
50
51     public void setPipelineConfiguration(PipelineConfiguration config) {
52         if (this.pipelineConfiguration != config) {
53             this.pipelineConfiguration = config;
54             if (nextReceiver != null) {
55                 nextReceiver.setPipelineConfiguration(config);
56             }
57         }
58     }
59
60     public Configuration getConfiguration() {
61         return pipelineConfiguration.getConfiguration();
62     }
63
64     /**
65      * Get the namepool for this configuration
66      */

67
68     public NamePool getNamePool() {
69         return getConfiguration().getNamePool();
70     }
71
72     /**
73      * Start of event stream
74      */

75
76     public void open() throws XPathException {
77         if (nextReceiver == null) {
78             throw new IllegalStateException JavaDoc("ProxyReceiver.open(): no underlying emitter provided");
79         }
80         nextReceiver.open();
81     }
82
83     /**
84      * End of document
85      */

86
87     public void close() throws XPathException {
88         nextReceiver.close();
89     }
90
91     /**
92      * Start of a document node.
93      */

94
95     public void startDocument(int properties) throws XPathException {
96         nextReceiver.startDocument(properties);
97     }
98
99     /**
100      * Notify the end of a document node
101      */

102
103     public void endDocument() throws XPathException {
104         nextReceiver.endDocument();
105     }
106
107     /**
108      * Notify the start of an element
109      *
110      * @param nameCode integer code identifying the name of the element within the name pool.
111      * @param typeCode integer code identifying the element's type within the name pool.
112      * @param properties properties of the element node
113      */

114
115     public void startElement(int nameCode, int typeCode, int locationId, int properties) throws XPathException {
116         nextReceiver.startElement(nameCode, typeCode, locationId, properties);
117     }
118
119     /**
120      * Notify a namespace. Namespaces are notified <b>after</b> the startElement event, and before
121      * any children for the element. The namespaces that are reported are only required
122      * to include those that are different from the parent element; however, duplicates may be reported.
123      * A namespace must not conflict with any namespaces already used for element or attribute names.
124      *
125      * @param namespaceCode an integer: the top half is a prefix code, the bottom half a URI code.
126      * These may be translated into an actual prefix and URI using the name pool. A prefix code of
127      * zero represents the empty prefix (that is, the default namespace). A URI code of zero represents
128      * a URI of "", that is, a namespace undeclaration.
129      * @throws IllegalStateException: attempt to output a namespace when there is no open element
130      * start tag
131      */

132
133     public void namespace(int namespaceCode, int properties) throws XPathException {
134         nextReceiver.namespace(namespaceCode, properties);
135     }
136
137     /**
138      * Notify an attribute. Attributes are notified after the startElement event, and before any
139      * children. Namespaces and attributes may be intermingled.
140      *
141      * @param nameCode The name of the attribute, as held in the name pool
142      * @param typeCode The type of the attribute, as held in the name pool
143      * @param properties Bit significant value. The following bits are defined:
144      * <dd>DISABLE_ESCAPING</dd> <dt>Disable escaping for this attribute</dt>
145      * <dd>NO_SPECIAL_CHARACTERS</dd> <dt>Attribute value contains no special characters</dt>
146      * @throws IllegalStateException: attempt to output an attribute when there is no open element
147      * start tag
148      */

149
150     public void attribute(int nameCode, int typeCode, CharSequence JavaDoc value, int locationId, int properties)
151             throws XPathException {
152         nextReceiver.attribute(nameCode, typeCode, value, locationId, properties);
153     }
154
155     /**
156      * Notify the start of the content, that is, the completion of all attributes and namespaces.
157      * Note that the initial receiver of output from XSLT instructions will not receive this event,
158      * it has to detect it itself. Note that this event is reported for every element even if it has
159      * no attributes, no namespaces, and no content.
160      */

161
162
163     public void startContent() throws XPathException {
164         nextReceiver.startContent();
165     }
166
167     /**
168      * End of element
169      */

170
171     public void endElement() throws XPathException {
172         nextReceiver.endElement();
173     }
174
175     /**
176      * Character data
177      */

178
179     public void characters(CharSequence JavaDoc chars, int locationId, int properties) throws XPathException {
180         nextReceiver.characters(chars, locationId, properties);
181     }
182
183
184     /**
185      * Processing Instruction
186      */

187
188     public void processingInstruction(String JavaDoc target, CharSequence JavaDoc data, int locationId, int properties) throws XPathException {
189         nextReceiver.processingInstruction(target, data, locationId, properties);
190     }
191
192     /**
193      * Output a comment
194      */

195
196     public void comment(CharSequence JavaDoc chars, int locationId, int properties) throws XPathException {
197         nextReceiver.comment(chars, locationId, properties);
198     }
199
200
201     /**
202      * Set the URI for an unparsed entity in the document.
203      */

204
205     public void setUnparsedEntity(String JavaDoc name, String JavaDoc uri, String JavaDoc publicId) throws XPathException {
206         nextReceiver.setUnparsedEntity(name, uri, publicId);
207     }
208
209     /**
210      * Get the Document Locator
211      */

212
213     public LocationProvider getDocumentLocator() {
214         return pipelineConfiguration.getLocationProvider();
215     }
216 }
217
218 //
219
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
220
// you may not use this file except in compliance with the License. You may obtain a copy of the
221
// License at http://www.mozilla.org/MPL/
222
//
223
// Software distributed under the License is distributed on an "AS IS" basis,
224
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
225
// See the License for the specific language governing rights and limitations under the License.
226
//
227
// The Original Code is: all this file.
228
//
229
// The Initial Developer of the Original Code is Michael H. Kay
230
//
231
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
232
//
233
// Contributor(s): none.
234
//
235
Popular Tags