001: /*
002: * Copyright (c) 1997-1999 The Java Apache Project. All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * 2. Redistributions in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * 3. All advertising materials mentioning features or use of this
017: * software must display the following acknowledgment:
018: * "This product includes software developed by the Java Apache
019: * Project for use in the Apache JServ servlet engine project
020: * (http://java.apache.org/)."
021: *
022: * 4. The names "Apache JServ", "Apache JServ Servlet Engine" and
023: * "Java Apache Project" must not be used to endorse or promote products
024: * derived from this software without prior written permission.
025: *
026: * 5. Products derived from this software may not be called "Apache JServ"
027: * nor may "Apache" nor "Apache JServ" appear in their names without
028: * prior written permission of the Java Apache Project.
029: *
030: * 6. Redistributions of any form whatsoever must retain the following
031: * acknowledgment:
032: * "This product includes software developed by the Java Apache
033: * Project for use in the Apache JServ servlet engine project
034: * (http://java.apache.org/)."
035: *
036: * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY
037: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
038: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
039: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
042: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
043: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
044: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
045: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
046: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
047: * OF THE POSSIBILITY OF SUCH DAMAGE.
048: *
049: * This software consists of voluntary contributions made by many
050: * individuals on behalf of the Java Apache Group. For more information
051: * on the Java Apache Project and the Apache JServ Servlet Engine project,
052: * please see <http://java.apache.org/>.
053: */
054:
055: /**
056: * <CODE>SpecialTagHandler</CODE> represents a tag which requires
057: * handling within server side parsed page. This could be a
058: * class handling <SERVLET>-Tags or any other tag. See
059: * PageParser, SSI and ParameterPropagatingSSI for examples.
060: *
061: * <p>A class to plug into PageParser <em>must</em> implement
062: * this interface and <em>must</em> have a simple constructor
063: * without parameters and can then be added with
064: * <code>addTagHandler()</code> to a PageParser servlet.
065: *
066: * @author <A href="mailto:zeller@think.de">Henner Zeller</A>
067: */package org.wings.template.parser;
068:
069: import java.io.IOException;
070: import java.io.InputStream;
071:
072: public interface SpecialTagHandler {
073: /**
074: * Parse tag.
075: * This method is invoked if a tag with a name
076: * this class is registered for is found.
077: * It gets the ServletConfiguration of the PageParser
078: * servet and a PositionReader, placed after name of
079: * the current tag.<p>
080: * The <CODE>parseTag()</CODE> method is called <em>before</em>
081: * any processing is done. Its purpose is to parse the area
082: * this tag spans and probably read in parameters used at
083: * execution time.<p>
084: * This method returns the last tag belonging to the
085: * area handled by this handler (for server side included
086: * servlets, this would be <CODE></SERVLET></CODE>).
087: * For simple one-tag Handlers this is simply the tag passed
088: * to this method. If the Handler decides not to handle this tag, this
089: * method should return <CODE>null</CODE>.
090: *
091: * @param context The context used while parsing; contains
092: * at least the HttpServletRequest and HttpServletResponse.
093: * @param input The PositionReader, located after the Name token
094: * of the Tag
095: * @param startPos The Position parsing of this token began
096: * @param startTag the SGMLTag found in the file.
097: */
098: SGMLTag parseTag(ParseContext context, PositionReader input,
099: long startPos, SGMLTag startTag) throws IOException;
100:
101: /**
102: * Get start position of the area in the sourcefile this
103: * handler processes.
104: * This is usually the position of the "<code><</code>"
105: * of the <code><SpecialTag></code> within the inputfile.
106: */
107: long getTagStart();
108:
109: /**
110: * Get the length of the area in the sourcefile.
111: * The area this handler processes is skipped in the inputfile.
112: * Usually this represents the length of the single
113: * <code><SpecialTag></code> or the
114: * area <code><SpecialTag>...</SpecialTag></code>
115: */
116: long getTagLength();
117:
118: /**
119: * actually perform the action associated with this tag.
120: *
121: * @throws Exception anything can happen .. and throw an Exception
122: * which is caught in PageParser
123: */
124: void executeTag(ParseContext context, InputStream input)
125: throws Exception;
126: }
127:
128: /*
129: * Local variables:
130: * c-basic-offset: 4
131: * compile-command: "ant -emacs -find build.xml"
132: * End:
133: */
|