KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > template > parser > SpecialTagHandler


1 /*
2  * Copyright (c) 1997-1999 The Java Apache Project. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  *
16  * 3. All advertising materials mentioning features or use of this
17  * software must display the following acknowledgment:
18  * "This product includes software developed by the Java Apache
19  * Project for use in the Apache JServ servlet engine project
20  * (http://java.apache.org/)."
21  *
22  * 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
23  * "Java Apache Project" must not be used to endorse or promote products
24  * derived from this software without prior written permission.
25  *
26  * 5. Products derived from this software may not be called "Apache JServ"
27  * nor may "Apache" nor "Apache JServ" appear in their names without
28  * prior written permission of the Java Apache Project.
29  *
30  * 6. Redistributions of any form whatsoever must retain the following
31  * acknowledgment:
32  * "This product includes software developed by the Java Apache
33  * Project for use in the Apache JServ servlet engine project
34  * (http://java.apache.org/)."
35  *
36  * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
37  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47  * OF THE POSSIBILITY OF SUCH DAMAGE.
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Java Apache Group. For more information
51  * on the Java Apache Project and the Apache JServ Servlet Engine project,
52  * please see <http://java.apache.org/>.
53  */

54
55 /**
56  * <CODE>SpecialTagHandler</CODE> represents a tag which requires
57  * handling within server side parsed page. This could be a
58  * class handling &lt;SERVLET&gt;-Tags or any other tag. See
59  * PageParser, SSI and ParameterPropagatingSSI for examples.
60  *
61  * <p>A class to plug into PageParser <em>must</em> implement
62  * this interface and <em>must</em> have a simple constructor
63  * without parameters and can then be added with
64  * <code>addTagHandler()</code> to a PageParser servlet.
65  *
66  * @version $Revision: 1.5 $ $Date: 2004/12/01 07:54:28 $
67  * @author <A HREF="mailto:zeller@think.de">Henner Zeller</A>
68  */

69
70 /*
71  * $Id: SpecialTagHandler.java,v 1.5 2004/12/01 07:54:28 hengels Exp $
72  * Copyright 2000,2005 wingS development team.
73  *
74  * This file is part of wingS (http://www.j-wings.org).
75  *
76  * wingS is free software; you can redistribute it and/or modify
77  * it under the terms of the GNU Lesser General Public License
78  * as published by the Free Software Foundation; either version 2.1
79  * of the License, or (at your option) any later version.
80  *
81  * Please see COPYING for the complete licence.
82  */

83 package org.wings.template.parser;
84
85 import java.io.IOException JavaDoc;
86 import java.io.InputStream JavaDoc;
87
88 public interface SpecialTagHandler {
89     /**
90      * Parse tag.
91      * This method is invoked if a tag with a name
92      * this class is registered for is found.
93      * It gets the ServletConfiguration of the PageParser
94      * servet and a PositionReader, placed after name of
95      * the current tag.<p>
96      * The <CODE>parseTag()</CODE> method is called <em>before</em>
97      * any processing is done. Its purpose is to parse the area
98      * this tag spans and probably read in parameters used at
99      * execution time.<p>
100      * This method returns the last tag belonging to the
101      * area handled by this handler (for server side included
102      * servlets, this would be <CODE>&lt;/SERVLET&gt;</CODE>).
103      * For simple one-tag Handlers this is simply the tag passed
104      * to this method. If the Handler decides not to handle this tag, this
105      * method should return <CODE>null</CODE>.
106      *
107      * @param context The context used while parsing; contains
108      * at least the HttpServletRequest and HttpServletResponse.
109      * @param input The PositionReader, located after the Name token
110      * of the Tag
111      * @param startPos The Position parsing of this token began
112      * @param startTag the SGMLTag found in the file.
113      */

114     SGMLTag parseTag(ParseContext context,
115                      PositionReader input,
116                      long startPos,
117                      SGMLTag startTag)
118             throws IOException JavaDoc;
119
120     /**
121      * Get start position of the area in the sourcefile this
122      * handler processes.
123      * This is usually the position of the &quot;<code>&lt;</code>&quot;
124      * of the <code>&lt;SpecialTag&gt;</code> within the inputfile.
125      */

126     long getTagStart();
127
128     /**
129      * Get the length of the area in the sourcefile.
130      * The area this handler processes is skipped in the inputfile.
131      * Usually this represents the length of the single
132      * <code>&lt;SpecialTag&gt;</code> or the
133      * area <code>&lt;SpecialTag&gt;...&lt;/SpecialTag&gt;</code>
134      */

135     long getTagLength();
136
137     /**
138      * actually perform the action associated with this tag.
139      *
140      * @throws Exception anything can happen .. and throw an Exception
141      * which is caught in PageParser
142      */

143     void executeTag(ParseContext context, InputStream JavaDoc input)
144             throws Exception JavaDoc;
145 }
146
147 /*
148  * Local variables:
149  * c-basic-offset: 4
150  * compile-command: "ant -emacs -find build.xml"
151  * End:
152  */

153
154
155
Popular Tags