KickJava   Java API By Example, From Geeks To Geeks.

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


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.transformation.CIncludeTransformer;
19 import org.apache.cocoon.xml.AttributesImpl;
20 import org.xml.sax.ContentHandler JavaDoc;
21 import org.xml.sax.SAXException JavaDoc;
22
23 /**
24  * Base class for aspect renderers that generate cinclude statements. Provides a single
25  * method for creating the cinclude tag.
26  *
27  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
28  * @author <a HREF="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
29  *
30  * @version CVS $Id: AbstractCIncludeAspect.java 158825 2005-03-23 20:00:56Z cziegeler $
31  */

32 public abstract class AbstractCIncludeAspect
33     extends AbstractAspect {
34
35     protected static final String JavaDoc PREFIX = "cinclude";
36     protected static final String JavaDoc NAMESPACE = CIncludeTransformer.CINCLUDE_NAMESPACE_URI;
37     protected static final String JavaDoc ELEMENT = CIncludeTransformer.CINCLUDE_INCLUDE_ELEMENT;
38     protected static final String JavaDoc QELEMENT= PREFIX + ":" + ELEMENT;
39     protected static final String JavaDoc ATTRIBUTE = CIncludeTransformer.CINCLUDE_INCLUDE_ELEMENT_SRC_ATTRIBUTE;
40
41     /**
42      * Create the cinclude statement.
43      *
44      * @param source attribute value for the cinclude tag
45      * @param handler SAX event handler
46      */

47     protected void createCInclude(String JavaDoc source, ContentHandler JavaDoc handler)
48     throws SAXException JavaDoc {
49         handler.startPrefixMapping(PREFIX, NAMESPACE);
50         AttributesImpl attributes = new AttributesImpl();
51         attributes.addCDATAAttribute(ATTRIBUTE, source);
52         handler.startElement(NAMESPACE, ELEMENT, QELEMENT, attributes);
53         handler.endElement(NAMESPACE, ELEMENT, QELEMENT);
54         handler.endPrefixMapping(PREFIX);
55     }
56
57 }
58
Popular Tags