KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > markup > xsp > XSPGenerator


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.language.markup.xsp;
17
18 import org.apache.avalon.excalibur.pool.Recyclable;
19 import org.apache.avalon.framework.component.ComponentException;
20 import org.apache.avalon.framework.component.ComponentManager;
21 import org.apache.avalon.framework.context.Context;
22 import org.apache.avalon.framework.context.ContextException;
23 import org.apache.avalon.framework.context.Contextualizable;
24 import org.apache.cocoon.components.language.generator.CompiledComponent;
25 import org.apache.cocoon.generation.AbstractServerPage;
26 import org.xml.sax.SAXException JavaDoc;
27
28 /**
29  * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
30  *
31  * @author <a HREF="mailto:ricardo@apache.org">Ricardo Rocha</a>
32  * @version CVS $Id: XSPGenerator.java 30932 2004-07-29 17:35:38Z vgritsenko $
33  */

34 public abstract class XSPGenerator extends AbstractServerPage implements CompiledComponent, Contextualizable, Recyclable {
35     protected Context avalonContext = null;
36
37     /** Contextualize this class */
38     public void contextualize(Context context) throws ContextException {
39         this.avalonContext = context;
40     }
41
42     /**
43      * Set the current <code>ComponentManager</code> instance used by this
44      * <code>Generator</code> and initialize relevant instance variables.
45      *
46      * @param manager The global component manager
47      */

48     public void compose(ComponentManager manager) throws ComponentException {
49         super.compose(manager);
50     }
51
52     // XSP Helper methods accessible from the page
53

54     /**
55      * Add character data
56      *
57      * @param data The character data
58      */

59     public void xspCharacters(String JavaDoc data) throws SAXException JavaDoc {
60         this.contentHandler.characters(data.toCharArray(), 0, data.length());
61     }
62
63     /**
64      * Add a comment
65      *
66      * @param comment The comment data
67      */

68     public void xspComment(String JavaDoc comment) throws SAXException JavaDoc {
69         this.lexicalHandler.comment(comment.toCharArray(), 0, comment.length());
70     }
71
72     /**
73      * Implementation of &lt;xsp:expr&gt; for String, Collection,
74      * XMLizable, Node, and Object.
75      *
76      * @param v the value
77      */

78     public void xspExpr(Object JavaDoc v) throws SAXException JavaDoc {
79         XSPObjectHelper.xspExpr(this.contentHandler, v);
80     }
81 }
82
Popular Tags