KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > layout > renderer > aspect > impl > RemovableAspect


1 /*
2  * Copyright 1999-2002,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.portal.layout.renderer.aspect.impl;
17
18 import org.apache.cocoon.portal.PortalService;
19 import org.apache.cocoon.portal.coplet.CopletInstanceData;
20 import org.apache.cocoon.portal.event.impl.LayoutRemoveEvent;
21 import org.apache.cocoon.portal.layout.Layout;
22 import org.apache.cocoon.portal.layout.impl.CopletLayout;
23 import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
24 import org.apache.cocoon.xml.XMLUtils;
25 import org.xml.sax.ContentHandler JavaDoc;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * Add a tag holding a URI used to remove a coplet from a layout to the
30  * output stream if the coplet is not set to mandatory.
31  *
32  * <h2>Example XML:</h2>
33  * <pre>
34  * &lt;remove-uri&gt;layout-remove-event&lt;/remove-uri&gt;
35  * &lt;!-- output from following renderers --&gt;
36  * </pre>
37  *
38  * <h2>Applicable to:</h2>
39  * <ul>
40  * <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
41  * </ul>
42  *
43  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
44  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
45  *
46  * @version CVS $Id: RemovableAspect.java 30932 2004-07-29 17:35:38Z vgritsenko $
47  */

48 public class RemovableAspect
49     extends AbstractAspect {
50
51     /* (non-Javadoc)
52      * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext, org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
53      */

54     public void toSAX(RendererAspectContext context,
55                         Layout layout,
56                         PortalService service,
57                         ContentHandler JavaDoc handler)
58     throws SAXException JavaDoc {
59         
60         CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
61
62         Boolean JavaDoc mandatory = (Boolean JavaDoc)cid.getCopletData().getAspectData("mandatory");
63         if ( !mandatory.booleanValue() ) {
64             LayoutRemoveEvent lre = new LayoutRemoveEvent(layout);
65             XMLUtils.createElement(handler, "remove-uri", service.getComponentManager().getLinkService().getLinkURI(lre));
66         }
67         context.invokeNext(layout, service, handler);
68     }
69
70 }
71
Popular Tags