01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.language.markup.xsp;
18:
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.generation.AbstractServerPage;
25: import org.xml.sax.SAXException;
26:
27: /**
28: * Base class for XSP-generated <code>ServerPagesGenerator</code> classes
29: *
30: * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
31: * @version $Id: XSPGenerator.java 433543 2006-08-22 06:22:54Z crossley $
32: */
33: public abstract class XSPGenerator extends AbstractServerPage implements
34: Contextualizable {
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)
49: throws ComponentException {
50: super .compose(manager);
51: }
52:
53: // XSP Helper methods accessible from the page
54:
55: /**
56: * Add character data
57: *
58: * @param data The character data
59: */
60: public void xspCharacters(String data) throws SAXException {
61: this .contentHandler.characters(data.toCharArray(), 0, data
62: .length());
63: }
64:
65: /**
66: * Add a comment
67: *
68: * @param comment The comment data
69: */
70: public void xspComment(String comment) throws SAXException {
71: this .lexicalHandler.comment(comment.toCharArray(), 0, comment
72: .length());
73: }
74:
75: /**
76: * Implementation of <xsp:expr> for String, Collection,
77: * XMLizable, Node, and Object.
78: *
79: * @param v the value
80: */
81: public void xspExpr(Object v) throws SAXException {
82: XSPObjectHelper.xspExpr(this.contentHandler, v);
83: }
84: }
|