KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > sax > XMLTeePipe


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.sax;
17
18 import org.apache.cocoon.xml.XMLConsumer;
19 import org.apache.cocoon.xml.XMLPipe;
20 import org.apache.cocoon.xml.XMLProducer;
21 import org.xml.sax.Attributes JavaDoc;
22 import org.xml.sax.Locator JavaDoc;
23 import org.xml.sax.SAXException JavaDoc;
24
25
26 /**
27  * This is a simple Tee Component.
28  * The incoming events are forwarded to two other components.
29  *
30  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
31  * @version CVS $Id: XMLTeePipe.java 30932 2004-07-29 17:35:38Z vgritsenko $
32  */

33
34 public final class XMLTeePipe
35 implements XMLPipe {
36
37     /**
38      * Set the <code>XMLConsumer</code> that will receive XML data.
39      */

40     public void setConsumer(XMLConsumer consumer) {
41         ((XMLProducer)this.firstConsumer).setConsumer(consumer);
42     }
43
44     private XMLConsumer firstConsumer;
45     private XMLConsumer secondConsumer;
46
47     /**
48      * Create a new XMLTeePipe with two consumers
49      */

50     public XMLTeePipe(XMLConsumer firstPipe,
51                       XMLConsumer secondConsumer) {
52         this.firstConsumer = firstPipe;
53         this.secondConsumer = secondConsumer;
54     }
55
56     public void recycle() {
57         this.firstConsumer = null;
58         this.secondConsumer = null;
59     }
60
61     public void startDocument() throws SAXException JavaDoc {
62         this.firstConsumer.startDocument();
63         this.secondConsumer.startDocument();
64     }
65
66     public void endDocument() throws SAXException JavaDoc {
67         this.firstConsumer.endDocument();
68         this.secondConsumer.endDocument();
69     }
70
71     public void startPrefixMapping(String JavaDoc prefix, String JavaDoc uri) throws SAXException JavaDoc {
72         this.firstConsumer.startPrefixMapping(prefix, uri);
73         this.secondConsumer.startPrefixMapping(prefix, uri);
74     }
75
76     public void endPrefixMapping(String JavaDoc prefix) throws SAXException JavaDoc {
77         this.firstConsumer.endPrefixMapping(prefix);
78         this.secondConsumer.endPrefixMapping(prefix);
79     }
80
81     public void startElement(String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc qName, Attributes JavaDoc atts)
82     throws SAXException JavaDoc {
83         this.firstConsumer.startElement(namespaceURI, localName, qName, atts);
84         this.secondConsumer.startElement(namespaceURI, localName, qName, atts);
85     }
86
87     public void endElement(String JavaDoc namespaceURI, String JavaDoc localName, String JavaDoc qName)
88     throws SAXException JavaDoc {
89         this.firstConsumer.endElement(namespaceURI, localName, qName);
90         this.secondConsumer.endElement(namespaceURI, localName, qName);
91     }
92
93     public void characters(char[] ch, int start, int length) throws SAXException JavaDoc {
94         this.firstConsumer.characters(ch, start, length);
95         this.secondConsumer.characters(ch, start, length);
96     }
97
98     public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException JavaDoc {
99         this.firstConsumer.ignorableWhitespace(ch, start, length);
100         this.secondConsumer.ignorableWhitespace(ch, start, length);
101     }
102
103     public void processingInstruction(String JavaDoc target, String JavaDoc data) throws SAXException JavaDoc {
104         this.firstConsumer.processingInstruction(target, data);
105         this.secondConsumer.processingInstruction(target, data);
106     }
107
108     public void setDocumentLocator(Locator JavaDoc locator) {
109         this.firstConsumer.setDocumentLocator(locator);
110         this.secondConsumer.setDocumentLocator(locator);
111     }
112
113     public void skippedEntity(String JavaDoc name) throws SAXException JavaDoc {
114         this.firstConsumer.skippedEntity(name);
115         this.secondConsumer.skippedEntity(name);
116     }
117
118     public void startDTD(String JavaDoc name, String JavaDoc public_id, String JavaDoc system_id)
119     throws SAXException JavaDoc {
120         this.firstConsumer.startDTD(name, public_id, system_id);
121         this.secondConsumer.startDTD(name, public_id, system_id);
122     }
123
124     public void endDTD() throws SAXException JavaDoc {
125         this.firstConsumer.endDTD();
126         this.secondConsumer.endDTD();
127     }
128
129     public void startEntity(String JavaDoc name) throws SAXException JavaDoc {
130         this.firstConsumer.startEntity(name);
131         this.secondConsumer.startEntity(name);
132     }
133
134     public void endEntity(String JavaDoc name) throws SAXException JavaDoc {
135         this.firstConsumer.endEntity(name);
136         this.secondConsumer.endEntity(name);
137     }
138
139     public void startCDATA() throws SAXException JavaDoc {
140         this.firstConsumer.startCDATA();
141         this.secondConsumer.startCDATA();
142     }
143
144     public void endCDATA() throws SAXException JavaDoc {
145         this.firstConsumer.endCDATA();
146         this.secondConsumer.endCDATA();
147     }
148
149     public void comment(char ary[], int start, int length)
150     throws SAXException JavaDoc {
151         this.firstConsumer.comment(ary, start, length);
152         this.secondConsumer.comment(ary, start, length);
153     }
154
155 }
156
Popular Tags