KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > sitemap > NotifyingGenerator


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.sitemap;
17
18 import java.util.Map JavaDoc;
19 import java.io.IOException JavaDoc;
20
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.cocoon.components.notification.Notifying;
23 import org.apache.cocoon.components.notification.Notifier;
24 import org.apache.cocoon.generation.AbstractGenerator;
25 import org.apache.cocoon.environment.SourceResolver;
26 import org.apache.cocoon.ProcessingException;
27 import org.apache.cocoon.Constants;
28
29 import org.xml.sax.SAXException JavaDoc;
30
31 /**
32  * Generates an XML representation of the current notification.
33  *
34  * @author <a HREF="mailto:barozzi@nicolaken.com">Nicola Ken Barozzi</a>
35  * @author <a HREF="mailto:stefano@apache.org">Stefano Mazzocchi</a>
36  * @author <a HREF="mailto:proyal@managingpartners.com">Peter Royal</a>
37  * @version CVS $Id: NotifyingGenerator.java 30932 2004-07-29 17:35:38Z vgritsenko $
38  */

39 public class NotifyingGenerator extends AbstractGenerator {
40     
41     /**
42      * The <code>Notification</code> to report.
43      */

44     private Notifying notification;
45
46     public void setup(SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc src,
47                       Parameters par) throws ProcessingException, SAXException JavaDoc, IOException JavaDoc {
48         super.setup(resolver, objectModel, src, par);
49
50         this.notification = (Notifying)objectModel.get(Constants.NOTIFYING_OBJECT);
51
52         if ( this.notification == null) {
53             throw new ProcessingException("Expected Constants.NOTIFYING_OBJECT not found in object model");
54         }
55     }
56
57     /**
58      * Generate the notification information in XML format.
59      *
60      * @throws SAXException when there is a problem creating the
61      * output SAX events.
62      */

63     public void generate() throws SAXException JavaDoc {
64         Notifier.notify(notification, this.contentHandler, "text/xml");
65     }
66
67     /**
68      * Recycle
69      */

70     public void recycle() {
71         super.recycle();
72         this.notification = null;
73     }
74 }
75
76
Popular Tags