001: /*
002: * The Apache Software License, Version 1.1
003: *
004: * Copyright (c) 1999 The Apache Software Foundation. All rights
005: * reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The end-user documentation included with the redistribution, if
020: * any, must include the following acknowlegement:
021: * "This product includes software developed by the
022: * Apache Software Foundation (http://www.apache.org/)."
023: * Alternately, this acknowlegement may appear in the software itself,
024: * if and wherever such third-party acknowlegements normally appear.
025: *
026: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
027: * Foundation" must not be used to endorse or promote products derived
028: * from this software without prior written permission. For written
029: * permission, please contact apache@apache.org.
030: *
031: * 5. Products derived from this software may not be called "Apache"
032: * nor may "Apache" appear in their names without prior written
033: * permission of the Apache Group.
034: *
035: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: *
049: * This software consists of voluntary contributions made by many
050: * individuals on behalf of the Apache Software Foundation. For more
051: * information on the Apache Software Foundation, please see
052: * <http://www.apache.org/>.
053: *
054: */
055:
056: package com.sun.portal.providers.jsp.jasper3.jasper.compiler;
057:
058: import java.util.Hashtable;
059: import java.util.Vector;
060:
061: import javax.servlet.jsp.tagext.TagInfo;
062: import javax.servlet.jsp.tagext.TagLibraryInfo;
063:
064: import com.sun.portal.providers.jsp.jasper3.jasper.JasperException;
065: import com.sun.portal.providers.jsp.jasper3.jasper.Constants;
066:
067: /**
068: * Simple util class.... see usage in Parser.Parser(). Not intended for anything
069: * other than that purpose....
070: *
071: * @author Anil K. Vijendran
072: */
073: final class DelegatingListener implements ParseEventListener {
074: ParseEventListener delegate;
075: Parser.Action action;
076: Mark tmplStart, tmplStop;
077:
078: DelegatingListener(ParseEventListener delegate, Parser.Action action) {
079: this .delegate = delegate;
080: this .action = action;
081: }
082:
083: void doAction(Mark start, Mark stop) throws JasperException {
084: action.execute(start, stop);
085: }
086:
087: public void setTemplateInfo(Mark start, Mark stop) {
088: this .tmplStart = start;
089: this .tmplStop = stop;
090: }
091:
092: public void beginPageProcessing() throws JasperException {
093: delegate.beginPageProcessing();
094: }
095:
096: public void endPageProcessing() throws JasperException {
097: delegate.endPageProcessing();
098: }
099:
100: public void handleComment(Mark start, Mark stop)
101: throws JasperException {
102: doAction(this .tmplStart, this .tmplStop);
103: delegate.handleComment(start, stop);
104: }
105:
106: public void handleDirective(String directive, Mark start,
107: Mark stop, Hashtable attrs) throws JasperException {
108: doAction(this .tmplStart, this .tmplStop);
109: delegate.handleDirective(directive, start, stop, attrs);
110: }
111:
112: public void handleDeclaration(Mark start, Mark stop, Hashtable attrs)
113: throws JasperException {
114: doAction(this .tmplStart, this .tmplStop);
115: delegate.handleDeclaration(start, stop, attrs);
116: }
117:
118: public void handleScriptlet(Mark start, Mark stop, Hashtable attrs)
119: throws JasperException {
120: doAction(this .tmplStart, this .tmplStop);
121: delegate.handleScriptlet(start, stop, attrs);
122: }
123:
124: public void handleExpression(Mark start, Mark stop, Hashtable attrs)
125: throws JasperException {
126: doAction(this .tmplStart, this .tmplStop);
127: delegate.handleExpression(start, stop, attrs);
128: }
129:
130: public void handleBean(Mark start, Mark stop, Hashtable attrs,
131: boolean isBodyEmpty) throws JasperException {
132: doAction(this .tmplStart, this .tmplStop);
133: delegate.handleBean(start, stop, attrs, isBodyEmpty);
134: }
135:
136: public void handleBeanEnd(Mark start, Mark stop, Hashtable attrs,
137: boolean isBodyEmpty) throws JasperException {
138: doAction(this .tmplStart, this .tmplStop);
139: delegate.handleBeanEnd(start, stop, attrs, isBodyEmpty);
140: }
141:
142: public void handleGetProperty(Mark start, Mark stop, Hashtable attrs)
143: throws JasperException {
144: doAction(this .tmplStart, this .tmplStop);
145: delegate.handleGetProperty(start, stop, attrs);
146: }
147:
148: public void handleSetProperty(Mark start, Mark stop, Hashtable attrs)
149: throws JasperException {
150: doAction(this .tmplStart, this .tmplStop);
151: delegate.handleSetProperty(start, stop, attrs);
152: }
153:
154: public void handlePlugin(Mark start, Mark stop, Hashtable attrs,
155: Hashtable param, String fallback) throws JasperException {
156: doAction(this .tmplStart, this .tmplStop);
157: delegate.handlePlugin(start, stop, attrs, param, fallback);
158: }
159:
160: public void handleCharData(Mark start, Mark stop, char[] chars)
161: throws JasperException {
162: delegate.handleCharData(start, stop, chars);
163: }
164:
165: public void handleForward(Mark start, Mark stop, Hashtable attrs,
166: Hashtable param) throws JasperException {
167: doAction(this .tmplStart, this .tmplStop);
168: delegate.handleForward(start, stop, attrs, param);
169: }
170:
171: public void handleInclude(Mark start, Mark stop, Hashtable attrs,
172: Hashtable param) throws JasperException {
173: doAction(this .tmplStart, this .tmplStop);
174: delegate.handleInclude(start, stop, attrs, param);
175: }
176:
177: public void handleTagBegin(Mark start, Mark stop, Hashtable attrs,
178: String prefix, String shortTagName, TagLibraryInfo tli,
179: TagInfo ti) throws JasperException {
180: doAction(this .tmplStart, this .tmplStop);
181: delegate.handleTagBegin(start, stop, attrs, prefix,
182: shortTagName, tli, ti);
183: }
184:
185: public void handleTagEnd(Mark start, Mark stop, String prefix,
186: String shortTagName, Hashtable attrs, TagLibraryInfo tli,
187: TagInfo ti) throws JasperException {
188: doAction(this .tmplStart, this .tmplStop);
189: delegate.handleTagEnd(start, stop, prefix, shortTagName, attrs,
190: tli, ti);
191: }
192:
193: public TagLibraries getTagLibraries() {
194: return delegate.getTagLibraries();
195: }
196: }
|