001: /*
002: * RewriteContext.java
003: *
004: * Brazil project web application Framework,
005: * export version: 1.1
006: * Copyright (c) 1999-2000 Sun Microsystems, Inc.
007: *
008: * Sun Public License Notice
009: *
010: * The contents of this file are subject to the Sun Public License Version
011: * 1.0 (the "License"). You may not use this file except in compliance with
012: * the License. A copy of the License is included as the file "license.terms",
013: * and also available at http://www.sun.com/
014: *
015: * The Original Code is from:
016: * Brazil project web application Framework release 1.1.
017: * The Initial Developer of the Original Code is: cstevens.
018: * Portions created by cstevens are Copyright (C) Sun Microsystems, Inc.
019: * All Rights Reserved.
020: *
021: * Contributor(s): cstevens, suhler.
022: *
023: * Version: 1.8
024: * Created by cstevens on 99/09/29
025: * Last modified by suhler on 00/07/06 15:48:56
026: */
027:
028: package sunlabs.brazil.template;
029:
030: import sunlabs.brazil.server.Server;
031: import sunlabs.brazil.server.Request;
032: import sunlabs.brazil.handler.HtmlRewriter;
033: import java.util.Properties;
034: import java.util.Vector;
035:
036: /**
037: * A variant containing instance variables that may be referenced by
038: * rewriting filters. Every implementation of the template class
039: * may define methods of the form:
040: * <code>tag_<i>xxx</i></code>
041: * or
042: * <code>tag_slash_<i>xxx</i></code>
043: * which will get called when the corrosponding HTML entity
044: * <code><xxx ...></code>
045: * or
046: * <code></xxx ...></code>
047: * is found in the content being filtered.
048: * <p>
049: * An instance of this class is passed to each <code>tag</code>
050: * method, permitting introspection of the current filtering context.
051: *
052: * @version %V% RewriteContext.java
053: */
054:
055: public class RewriteContext extends HtmlRewriter {
056: /**
057: * The server object, as passed to a handler's init method.
058: */
059: public Server server; // The server, containing properties.
060: /**
061: * The prefix to use for locating keys in the server or request properties
062: * objects, as passed to a handler's init method.
063: */
064: public String prefix; // The prefix for this template.
065: /**
066: * The Request object, as passed to a handler's respond method.
067: */
068: public Request request; // The current request
069: /**
070: * A unique <b>session id</b>, if available.
071: */
072: public String sessionId; // The session ID (if any)
073: /**
074: * Application specific placeholder.
075: */
076: Object[] args; // app. specific extra stuff
077:
078: TemplateRunner runner;
079: Vector templates;
080:
081: public RewriteContext(Server server, String prefix,
082: Request request, String content, String sessionId,
083: TemplateRunner runner, Vector templates) {
084: super (content);
085:
086: this .server = server;
087: this .prefix = prefix;
088: this .request = request;
089: this .sessionId = sessionId;
090: this .runner = runner;
091: this .templates = templates;
092: this .args = new Object[] { this };
093: }
094:
095: /**
096: * Invoke a template on this token, if any template is interested in this
097: * token. The template may consume more than just this token, if it
098: * wants.
099: */
100: public void process() {
101: runner.process(this);
102: }
103: }
|