Update of /cvsroot/webmacro/webmacro/src/org/webmacro/servlet In directory sc8-pr-cvs1:/tmp/cvs-serv6675/src/org/webmacro/servlet Modified Files: CGITool.java CGI_Impersonator.java ConfigException.java CookieJar.java CookieTool.java ErrorHandler.java Form.java FormList.java FormListTool.java FormTool.java Handler.java HandlerException.java ListTool.java ListUtil.java LocaleTool.java MathTool.java RequestTool.java ResponseTool.java Servlet20Broker.java Servlet22Broker.java ServletBroker.java ServletLog.java SessionTool.java TemplateTool.java TextTool.java TypeTool.java URLTool.java VariableTool.java WMServlet.java WebContext.java Log Message: If this doesn't drive our SF "activity" stats through the roof, I don't know what will. Mass re-formatting of all code, following (to the best of my interpertation) the Sun (w/ jakarta tweaks) coding style guidelines defined here: http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html and here: http://jakarta.apache.org/turbine/common/code-standards.html I did this reformatting with IDEA 3.0.5, and I am going to commit the style configuration for IDEA (if I can find it). Index: CGITool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CGITool.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** CGITool.java 11 Jun 2002 17:43:22 -0000 1.9 --- CGITool.java 12 Jun 2003 00:47:47 -0000 1.10 *************** *** 32,51 **** * script variable names. */ ! public class CGITool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! CGI_Impersonator cgi = new CGI_Impersonator(wc); ! return cgi; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "CGITool only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 32,56 ---- * script variable names. */ ! public class CGITool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! CGI_Impersonator cgi = new CGI_Impersonator(wc); ! return cgi; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "CGITool only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: CGI_Impersonator.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CGI_Impersonator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CGI_Impersonator.java 11 Jun 2002 17:43:22 -0000 1.5 --- CGI_Impersonator.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 24,29 **** package org.webmacro.servlet; ! import javax.servlet.*; ! import javax.servlet.http.*; --- 24,29 ---- package org.webmacro.servlet; ! import javax.servlet.ServletContext; ! import javax.servlet.http.HttpServletRequest; *************** *** 38,201 **** * familiar to CGI programmers. eg: REQUEST_METHOD, PATH_INFO, etc. */ ! final public class CGI_Impersonator { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest requst_; ! final ServletContext sc_; ! /** ! * Use the supplied HttpServletRequest to produce the results ! * below. Really this class just forwards methods to this sub ! * object in order to provide a familiar interface to CGI programmers. ! */ ! CGI_Impersonator(WebContext wc) { ! requst_ = wc.getRequest(); ! // this is not very nice, but I don't see any other ! // possibility to get the servlet context. We should ! // provide a method in WebContext to hide this from our users. ! sc_ = ((ServletBroker) wc.getBroker()).getServletContext(); ! } ! /** ! * Return the name of the server ! */ ! final public String getSERVER_NAME() { ! return requst_.getServerName(); ! } ! /** ! * Return the server info ! */ ! final public String getSERVER_SOFTWARE() { ! return sc_.getServerInfo(); ! } ! /** ! * Return the server protocol ! */ ! final public String getSERVER_PROTOCOL() { ! return requst_.getProtocol(); ! } ! /** ! * Return the server port ! */ ! final public Integer getSERVER_PORT() { ! return new Integer(requst_.getServerPort()); ! } ! /** ! * Return what type of REQUEST this was: GET, POST, etc. ! */ ! final public String getREQUEST_METHOD() { ! return requst_.getMethod(); ! } ! /** ! * What portion of the URL appeared as additional path beyond ! * the SCRIPT_NAME portion? Return that as a string. ! */ ! final public String getPATH_INFO() { ! return requst_.getPathInfo(); ! } ! /** ! * Same as PATH_INFO but translated to a real path ! */ ! final public String getPATH_TRANSLATED() { ! return requst_.getPathTranslated(); ! } ! /** ! * What portion of the URL represented the servlet being run? ! * Return that as a string. ! */ ! final public String getSCRIPT_NAME() { ! return requst_.getServletPath(); ! } ! /** ! * What is the root of documents served by this servlet ! * ! * WARNING: the method called (getRealPath) is deprecated in Servlet 2.2 ! * ! */ ! final public String getDOCUMENT_ROOT() { ! return sc_.getRealPath("/"); ! } ! /** ! * In a GET request, return the query string that was submitted, if any ! */ ! final public String getQUERY_STRING() { ! return requst_.getQueryString(); ! } ! /** ! * Return the remote host connected to this request ! */ ! final public String getREMOTE_HOST() { ! return requst_.getRemoteHost(); ! } ! /** ! * Return the remove address connected to this servlet ! */ ! final public String getREMOTE_ADDR() { ! return requst_.getRemoteAddr(); ! } ! /** ! * Type of authorization for this request ! */ ! final public String getAUTH_TYPE() { ! return requst_.getAuthType(); ! } ! /** ! * Name of the remote user if it was supplied with the HTTP request ! */ ! final public String getREMOTE_USER() { ! return requst_.getRemoteUser(); ! } ! /** ! * Get the content type submitted to this request ! */ ! final public String getCONTENT_TYPE() { ! return requst_.getContentType(); ! } ! /** ! * Get the content length submitted to this request ! */ ! final public Integer getCONTENT_LENGTH() { ! return new Integer(requst_.getContentLength()); ! } ! /** ! * What type of data is accepted by the client ! */ ! final public String getHTTP_ACCEPT() { ! return requst_.getHeader("Accept"); ! } ! /** ! * Get the user agent (browser) connected to this request ! */ ! final public String getHTTP_USER_AGENT() { ! return requst_.getHeader("User-Agent"); ! } ! /** ! * Get the URL that the request claims to have visited prior to this one ! */ ! final public String getHTTP_REFERER() { ! return requst_.getHeader("Referer"); ! } } --- 38,222 ---- * familiar to CGI programmers. eg: REQUEST_METHOD, PATH_INFO, etc. */ ! final public class CGI_Impersonator ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest requst_; ! final ServletContext sc_; ! /** ! * Use the supplied HttpServletRequest to produce the results ! * below. Really this class just forwards methods to this sub ! * object in order to provide a familiar interface to CGI programmers. ! */ ! CGI_Impersonator (WebContext wc) ! { ! requst_ = wc.getRequest(); ! // this is not very nice, but I don't see any other ! // possibility to get the servlet context. We should ! // provide a method in WebContext to hide this from our users. ! sc_ = ((ServletBroker) wc.getBroker()).getServletContext(); ! } ! /** ! * Return the name of the server ! */ ! final public String getSERVER_NAME () ! { ! return requst_.getServerName(); ! } ! /** ! * Return the server info ! */ ! final public String getSERVER_SOFTWARE () ! { ! return sc_.getServerInfo(); ! } ! /** ! * Return the server protocol ! */ ! final public String getSERVER_PROTOCOL () ! { ! return requst_.getProtocol(); ! } ! /** ! * Return the server port ! */ ! final public Integer getSERVER_PORT () ! { ! return new Integer(requst_.getServerPort()); ! } ! /** ! * Return what type of REQUEST this was: GET, POST, etc. ! */ ! final public String getREQUEST_METHOD () ! { ! return requst_.getMethod(); ! } ! /** ! * What portion of the URL appeared as additional path beyond ! * the SCRIPT_NAME portion? Return that as a string. ! */ ! final public String getPATH_INFO () ! { ! return requst_.getPathInfo(); ! } ! /** ! * Same as PATH_INFO but translated to a real path ! */ ! final public String getPATH_TRANSLATED () ! { ! return requst_.getPathTranslated(); ! } ! /** ! * What portion of the URL represented the servlet being run? ! * Return that as a string. ! */ ! final public String getSCRIPT_NAME () ! { ! return requst_.getServletPath(); ! } ! /** ! * What is the root of documents served by this servlet ! * ! * WARNING: the method called (getRealPath) is deprecated in Servlet 2.2 ! * ! */ ! final public String getDOCUMENT_ROOT () ! { ! return sc_.getRealPath("/"); ! } ! /** ! * In a GET request, return the query string that was submitted, if any ! */ ! final public String getQUERY_STRING () ! { ! return requst_.getQueryString(); ! } ! /** ! * Return the remote host connected to this request ! */ ! final public String getREMOTE_HOST () ! { ! return requst_.getRemoteHost(); ! } ! /** ! * Return the remove address connected to this servlet ! */ ! final public String getREMOTE_ADDR () ! { ! return requst_.getRemoteAddr(); ! } ! /** ! * Type of authorization for this request ! */ ! final public String getAUTH_TYPE () ! { ! return requst_.getAuthType(); ! } ! /** ! * Name of the remote user if it was supplied with the HTTP request ! */ ! final public String getREMOTE_USER () ! { ! return requst_.getRemoteUser(); ! } ! /** ! * Get the content type submitted to this request ! */ ! final public String getCONTENT_TYPE () ! { ! return requst_.getContentType(); ! } ! /** ! * Get the content length submitted to this request ! */ ! final public Integer getCONTENT_LENGTH () ! { ! return new Integer(requst_.getContentLength()); ! } ! /** ! * What type of data is accepted by the client ! */ ! final public String getHTTP_ACCEPT () ! { ! return requst_.getHeader("Accept"); ! } ! /** ! * Get the user agent (browser) connected to this request ! */ ! final public String getHTTP_USER_AGENT () ! { ! return requst_.getHeader("User-Agent"); ! } ! /** ! * Get the URL that the request claims to have visited prior to this one ! */ ! final public String getHTTP_REFERER () ! { ! return requst_.getHeader("Referer"); ! } } Index: ConfigException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ConfigException.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConfigException.java 11 Jun 2002 17:43:22 -0000 1.3 --- ConfigException.java 12 Jun 2003 00:47:47 -0000 1.4 *************** *** 31,44 **** * the config file eg default variables cannot be located */ ! public class ConfigException extends WebMacroException { ! /** ! * Constructor only requires a reason ! * <p> ! * @param reason explains what went wrong ! */ ! public ConfigException(String reason) { ! super(reason); ! } } --- 31,46 ---- * the config file eg default variables cannot be located */ ! public class ConfigException extends WebMacroException ! { ! /** ! * Constructor only requires a reason ! * <p> ! * @param reason explains what went wrong ! */ ! public ConfigException (String reason) ! { ! super(reason); ! } } Index: CookieJar.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CookieJar.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CookieJar.java 11 Jun 2002 17:43:22 -0000 1.6 --- CookieJar.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 24,85 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; /** * Provide access to form variables */ ! final public class CookieJar { ! private Cookie[] jar; ! private HttpServletResponse res; ! /** ! * Read the form data from the supplied Request object ! */ ! CookieJar(final HttpServletRequest rq, final HttpServletResponse rs) { ! jar = rq.getCookies(); ! res = rs; ! } ! /** ! * Get a form value ! */ ! final public Object get(String cookieName) { ! if (jar == null) { ! return null; ! } ! for (int i = 0; i < jar.length; i++) { ! if ((jar[i] != null) && (jar[i].getName().equals(cookieName))) { ! return jar[i]; ! } ! } ! return null; ! } ! /** ! * Create a new cookie with the supplied name and value and set it ! * in the response header. ! */ ! public final void put(final String name, final String value) { ! Cookie c = new Cookie(name, value); ! res.addCookie(c); ! } ! /** ! * Calls put ! */ ! public final void set(final String name, final Object value) ! throws UnsettableException { ! try { ! put(name, (String) value); ! } ! catch (ClassCastException ce) { ! throw new UnsettableException("Value must be a String"); ! } ! } } --- 24,96 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; + import javax.servlet.http.Cookie; + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + /** * Provide access to form variables */ ! final public class CookieJar ! { ! private Cookie[] jar; ! private HttpServletResponse res; ! /** ! * Read the form data from the supplied Request object ! */ ! CookieJar (final HttpServletRequest rq, final HttpServletResponse rs) ! { ! jar = rq.getCookies(); ! res = rs; ! } ! /** ! * Get a form value ! */ ! final public Object get (String cookieName) ! { ! if (jar == null) ! { ! return null; ! } ! for (int i = 0; i < jar.length; i++) ! { ! if ((jar[i] != null) && (jar[i].getName().equals(cookieName))) ! { ! return jar[i]; ! } ! } ! return null; ! } ! /** ! * Create a new cookie with the supplied name and value and set it ! * in the response header. ! */ ! public final void put (final String name, final String value) ! { ! Cookie c = new Cookie(name, value); ! res.addCookie(c); ! } ! /** ! * Calls put ! */ ! public final void set (final String name, final Object value) ! throws UnsettableException ! { ! try ! { ! put(name, (String) value); ! } ! catch (ClassCastException ce) ! { ! throw new UnsettableException("Value must be a String"); ! } ! } } Index: CookieTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/CookieTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** CookieTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- CookieTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,54 **** * Provide Template with access to form data. */ ! public class CookieTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! CookieJar fl = new CookieJar(wc.getRequest(), wc.getResponse()); ! return fl; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,56 ---- * Provide Template with access to form data. */ ! public class CookieTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! CookieJar fl = new CookieJar(wc.getRequest(), wc.getResponse()); ! return fl; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: ErrorHandler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ErrorHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ErrorHandler.java 11 Jun 2002 17:43:22 -0000 1.8 --- ErrorHandler.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 34,95 **** * explaining what went wrong. */ ! final class ErrorHandler implements Handler { ! private static final String DEFAULT_ERROR_TEXT = ! "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n" ! + "#set $Response.ContentType = \"text/html\"\n" ! + "<BODY><H1>Error</H1>" ! + "<HR>$error</BODY></HTML>"; ! private Template _errorTemplate = null; ! /** ! * The default error handler simply returns its template ! * @see TemplateStore ! * @exception HandlerException if you don't want to handle the connect ! * @return A Template which can be used to interpret the connection ! */ ! public Template accept(WebContext c) ! throws HandlerException { ! Broker broker = c.getBroker(); ! String templateName; ! try { ! templateName = (String) broker.get("config", WMServlet.ERROR_TEMPLATE); ! } ! catch (ResourceException e) { ! templateName = WMServlet.ERROR_TEMPLATE_DEFAULT; ! } ! try { ! _errorTemplate = (Template) broker.get("template", templateName); ! } ! catch (ResourceException e) { ! _errorTemplate = new StringTemplate(broker, DEFAULT_ERROR_TEXT, ! "WebMacro default error template"); ! } ! return _errorTemplate; ! } ! /** ! * Does nothing ! */ ! public void destroy() { ! } ! /** ! * Does nothing ! */ ! public void init() { ! } ! /** ! * Return the name of this handler ! */ ! final public String toString() { ! return "WebMacro ErrorHandler"; ! } } --- 34,104 ---- * explaining what went wrong. */ ! final class ErrorHandler implements Handler ! { ! private static final String DEFAULT_ERROR_TEXT = ! "<HTML><HEAD><TITLE>Error</TITLE></HEAD>\n" ! + "#set $Response.ContentType = \"text/html\"\n" ! + "<BODY><H1>Error</H1>" ! + "<HR>$error</BODY></HTML>"; ! private Template _errorTemplate = null; ! /** ! * The default error handler simply returns its template ! * @see TemplateStore ! * @exception HandlerException if you don't want to handle the connect ! * @return A Template which can be used to interpret the connection ! */ ! public Template accept (WebContext c) ! throws HandlerException ! { ! Broker broker = c.getBroker(); ! String templateName; ! try ! { ! templateName = (String) broker.get("config", WMServlet.ERROR_TEMPLATE); ! } ! catch (ResourceException e) ! { ! templateName = WMServlet.ERROR_TEMPLATE_DEFAULT; ! } ! try ! { ! _errorTemplate = (Template) broker.get("template", templateName); ! } ! catch (ResourceException e) ! { ! _errorTemplate = new StringTemplate(broker, DEFAULT_ERROR_TEXT, ! "WebMacro default error template"); ! } ! return _errorTemplate; ! } ! /** ! * Does nothing ! */ ! public void destroy () ! { ! } ! /** ! * Does nothing ! */ ! public void init () ! { ! } ! /** ! * Return the name of this handler ! */ ! final public String toString () ! { ! return "WebMacro ErrorHandler"; ! } } Index: Form.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/Form.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Form.java 10 Nov 2002 20:51:13 -0000 1.8 --- Form.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 29,38 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; import org.webmacro.util.Bag; import java.util.Enumeration; --- 29,36 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; import org.webmacro.util.Bag; + import javax.servlet.http.HttpServletRequest; import java.util.Enumeration; *************** *** 41,143 **** * Provide access to form variables */ ! final public class Form implements Bag { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! Form(final HttpServletRequest r) { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get(String field) { ! try { ! return _request.getParameterValues(field)[0]; ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Try to get a form value ! * ! * @param strKey = The form key that we're looking for. ! * ! * @return The value of that form key if found, else null ! * ! **/ ! final public Object getPossibleForm( String strKey ) { ! String strElement; ! Object obValue; ! Enumeration obEnumeration; ! //--- end of var's declaration ---// ! obValue = get( strKey ); ! if ( obValue == null ) { ! obEnumeration = _request.getParameterNames(); ! while ( obEnumeration.hasMoreElements() ) { ! strElement = obEnumeration.nextElement().toString(); ! if ( strElement.equalsIgnoreCase( strKey ) ) { ! obValue = get( strElement ); ! break; ! } ! } ! } ! return obValue; ! } ! /** ! * Get a form value as an array ! */ ! final public Object[] getList(String field) { ! try { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } /** * Return a String listing all the HTTP request parameter names and their values. */ ! final public String toString() { ! StringBuffer sb = new StringBuffer (); ! String eol = java.lang.System.getProperty ("line.separator"); ! for (Enumeration enum = _request.getParameterNames(); enum.hasMoreElements();) { String key = (String) enum.nextElement(); String[] value = _request.getParameterValues(key); ! for (int x=0; value != null && x<value.length; x++) { ! sb.append (key).append("=").append(value[x]).append (eol); } } --- 39,158 ---- * Provide access to form variables */ ! final public class Form implements Bag ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! Form (final HttpServletRequest r) ! { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get (String field) ! { ! try ! { ! return _request.getParameterValues(field)[0]; ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Try to get a form value ! * ! * @param strKey = The form key that we're looking for. ! * ! * @return The value of that form key if found, else null ! * ! **/ ! final public Object getPossibleForm (String strKey) ! { ! String strElement; ! Object obValue; ! Enumeration obEnumeration; ! //--- end of var's declaration ---// ! obValue = get(strKey); ! if (obValue == null) ! { ! obEnumeration = _request.getParameterNames(); ! while (obEnumeration.hasMoreElements()) ! { ! strElement = obEnumeration.nextElement().toString(); ! if (strElement.equalsIgnoreCase(strKey)) ! { ! obValue = get(strElement); ! break; ! } ! } ! } ! return obValue; ! } ! /** ! * Get a form value as an array ! */ ! final public Object[] getList (String field) ! { ! try ! { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } /** * Return a String listing all the HTTP request parameter names and their values. */ ! final public String toString () ! { ! StringBuffer sb = new StringBuffer(); ! String eol = java.lang.System.getProperty("line.separator"); ! for (Enumeration enum = _request.getParameterNames(); enum.hasMoreElements();) ! { String key = (String) enum.nextElement(); String[] value = _request.getParameterValues(key); ! for (int x = 0; value != null && x < value.length; x++) ! { ! sb.append(key).append("=").append(value[x]).append(eol); } } Index: FormList.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormList.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FormList.java 11 Jun 2002 17:43:22 -0000 1.5 --- FormList.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 24,78 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.UnsettableException; import org.webmacro.util.Bag; /** * Provide access to form variables */ ! final public class FormList implements Bag { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! FormList(final HttpServletRequest r) { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get(String field) { ! try { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } } --- 24,84 ---- package org.webmacro.servlet; import org.webmacro.UnsettableException; import org.webmacro.util.Bag; + import javax.servlet.http.HttpServletRequest; + /** * Provide access to form variables */ ! final public class FormList implements Bag ! { ! /** ! * This is the request object from the WebContext ! */ ! final HttpServletRequest _request; ! /** ! * Read the form data from the supplied Request object ! */ ! FormList (final HttpServletRequest r) ! { ! _request = r; ! } ! /** ! * Get a form value ! */ ! final public Object get (String field) ! { ! try ! { ! return _request.getParameterValues(field); ! } ! catch (NullPointerException ne) ! { ! return null; ! } ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } } Index: FormListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormListTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FormListTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- FormListTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,53 **** * Provide Template with access to form data. */ ! public class FormListTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! FormList fl = new FormList(wc.getRequest()); ! return fl; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,55 ---- * Provide Template with access to form data. */ ! public class FormListTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! FormList fl = new FormList(wc.getRequest()); ! return fl; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "This only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: FormTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/FormTool.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** FormTool.java 11 Jun 2002 17:43:22 -0000 1.8 --- FormTool.java 12 Jun 2003 00:47:47 -0000 1.9 *************** *** 24,30 **** package org.webmacro.servlet; - import javax.servlet.*; - import javax.servlet.http.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 34,53 **** * Provide Template with access to form data. */ ! public class FormTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! Form fr = new Form(wc.getRequest()); ! return fr; ! } ! catch (ClassCastException ce) { ! throw new PropertyException( ! "FormTool only works with WebContext", ce); ! } ! } ! public void destroy(Object o) { ! } } --- 31,55 ---- * Provide Template with access to form data. */ ! public class FormTool implements ContextTool ! { ! public Object init (Context context) ! throws PropertyException ! { ! try ! { ! WebContext wc = (WebContext) context; ! Form fr = new Form(wc.getRequest()); ! return fr; ! } ! catch (ClassCastException ce) ! { ! throw new PropertyException( ! "FormTool only works with WebContext", ce); ! } ! } ! public void destroy (Object o) ! { ! } } Index: Handler.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/Handler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Handler.java 12 Jun 2002 17:35:34 -0000 1.6 --- Handler.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 51,95 **** * <p> */ ! public interface Handler { ! /** ! * This is the primary method you override to create a new handler. ! * Incoming requests ultimately get passed to this method of your ! * handler, at which point it is up to you to decide what to do. ! * You must return a template--which will be used to format the ! * data you have inserted into the supplied WebContext. ! * <p> ! * If you throw an Exception it will be used to provide an explanation ! * to the user of why the failure occurred. The HandlerException class ! * provides you with numerous options for reporting errors. ! * <p> ! * @param contextData contains information about this connection ! * @return A Template which can be used to interpret the connection ! * @exception HandlerException if something went wrong with the handler ! */ ! public Template accept(WebContext contextData) ! throws HandlerException; ! /** ! * Use this method to run any startup initialization that you need ! * to perform. It will be called just before the first use of your ! * Handler. ! * @exception HandlerException if the handler failed to initialize ! */ ! public void init() throws HandlerException; ! /** ! * You SHOULD override this method and provide a short name by ! * which your handler is known. This will help you out in logging ! * and debugging messages if for some reason WebMacro needs to ! * identify the handler in a log message. ! */ ! public String toString(); ! /** ! * You may use this method to save persistent state on exit. ! * It will be called whenever the servlet is shut down. ! */ ! public void destroy(); } --- 51,96 ---- * <p> */ ! public interface Handler ! { ! /** ! * This is the primary method you override to create a new handler. ! * Incoming requests ultimately get passed to this method of your ! * handler, at which point it is up to you to decide what to do. ! * You must return a template--which will be used to format the ! * data you have inserted into the supplied WebContext. ! * <p> ! * If you throw an Exception it will be used to provide an explanation ! * to the user of why the failure occurred. The HandlerException class ! * provides you with numerous options for reporting errors. ! * <p> ! * @param contextData contains information about this connection ! * @return A Template which can be used to interpret the connection ! * @exception HandlerException if something went wrong with the handler ! */ ! public Template accept (WebContext contextData) ! throws HandlerException; ! /** ! * Use this method to run any startup initialization that you need ! * to perform. It will be called just before the first use of your ! * Handler. ! * @exception HandlerException if the handler failed to initialize ! */ ! public void init () throws HandlerException; ! /** ! * You SHOULD override this method and provide a short name by ! * which your handler is known. This will help you out in logging ! * and debugging messages if for some reason WebMacro needs to ! * identify the handler in a log message. ! */ ! public String toString (); ! /** ! * You may use this method to save persistent state on exit. ! * It will be called whenever the servlet is shut down. ! */ ! public void destroy (); } Index: HandlerException.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/HandlerException.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** HandlerException.java 11 Jun 2002 17:43:22 -0000 1.5 --- HandlerException.java 12 Jun 2003 00:47:47 -0000 1.6 *************** *** 30,46 **** * not want to process a connection request. */ ! public class HandlerException extends WebMacroException { ! /** ! * Declare a handler exception with a reason ! * @param reason why the handler failed ! */ ! public HandlerException(String reason) { ! super(reason); ! } ! public HandlerException(String reason, Exception e) { ! super(reason, e); ! } } --- 30,49 ---- * not want to process a connection request. */ ! public class HandlerException extends WebMacroException ! { ! /** ! * Declare a handler exception with a reason ! * @param reason why the handler failed ! */ ! public HandlerException (String reason) ! { ! super(reason); ! } ! public HandlerException (String reason, Exception e) ! { ! super(reason, e); ! } } Index: ListTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ListTool.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ListTool.java 11 Jun 2002 17:43:22 -0000 1.4 --- ListTool.java 12 Jun 2003 00:47:47 -0000 1.5 *************** *** 34,44 **** * @see ListUtil */ ! public class ListTool implements ContextTool { ! public Object init(Context context) { ! return ListUtil.getInstance(); ! } ! public void destroy(Object o) { ! } } --- 34,47 ---- * @see ListUtil */ ! public class ListTool implements ContextTool ! { ! public Object init (Context context) ! { ! return ListUtil.getInstance(); ! } ! public void destroy (Object o) ! { ! } } Index: ListUtil.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/ListUtil.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ListUtil.java 20 Dec 2002 02:25:25 -0000 1.9 --- ListUtil.java 12 Jun 2003 00:47:47 -0000 1.10 *************** *** 36,761 **** * @see ListTool */ ! public class ListUtil { ! /** ! * Private constructor for a singleton class ! */ ! private ListUtil() { ! } [...1521 lines suppressed...] ! out.print(splitArray3[i][j] + ", "); ! } ! out.println("*"); ! } ! // test primitive arrays ! int[] emptyInts = new int[0]; ! out.println("Empty array of int: isEmpty=" + isEmpty(emptyInts)); ! char[] chars = {'A', 'B', 'C'}; ! out.println("Array of char: isEmpty=" + isEmpty(chars) + ", size=" + size(chars)); ! out.println("contains 'C'=" + contains(chars, new Character('C'))); ! out.println("contains 'Z'=" + contains(chars, new Character('Z'))); ! out.println("toList=" + toList(chars)); ! float[] f = new float[]{1.1f, 2.2f, 3.3f}; ! out.println("getItem(floats, 0)=" + getItem(f, 0)); ! List appendList = append(f, chars); ! out.println("append(f, chars)=" + appendList); ! append(appendList, "another thing"); ! out.println("append(appendList, \"another thing\")=" + appendList); ! } } Index: LocaleTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/LocaleTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** LocaleTool.java 11 Nov 2002 19:22:38 -0000 1.7 --- LocaleTool.java 12 Jun 2003 00:47:47 -0000 1.8 *************** *** 24,30 **** package org.webmacro.servlet; - import java.lang.reflect.Field; - import java.util.*; - import org.webmacro.Context; import org.webmacro.ContextTool; --- 24,27 ---- *************** *** 33,150 **** import org.webmacro.util.Bag; /** * Provide Template with access to Locales. Also gives access to the static * fields e.g., Locale.US */ ! public class LocaleTool implements ContextTool, Bag { ! public static final String RCS = "$Id$"; ! private static HashMap cache = new HashMap(); ! public Object init(Context context) ! throws PropertyException { ! return this; ! } ! /** ! * return the default locale for this JVM ! */ ! final public Locale getDefault() { ! return Locale.getDefault(); ! } ! /** ! * wrappers around the 3 constructors for Locale ! */ ! final public Locale getLocale(String country) { ! return getLocale(country, "", ""); ! } ! final public Locale getLocale(String country, String language) { ! return getLocale(country, language, ""); ! } ! final public Locale getLocale(String country, String language, String variant) { ! String key = country + "_" + language + "_" + variant; // language.toUpperCase() ? ! Locale locale = (Locale) cache.get(key); ! if (locale == null) { ! locale = new Locale(country, language, ""); ! cache.put(key, locale); ! } ! return locale; ! } ! /** ! * access method used by $Locale.xxxxx => LocaleTool.get("xxxxx") ! */ ! final public Object get(String field) { ! return buildLocale(field); ! } ! /** ! * access to the static members such as Locale.US, etc ! * ! * If that field doesn't exist try to construct a locale ! * from a string so templates can have $Locale.en_GB. ! * ! * This may not be the right thing to do, though, in case of typos ! * ! * e.g., $Locale.ENGLISH => Locale.ENGLISH ! * but $Locale.ENGLSH => Locale("ENGLSH","","") ! * ! * Could argue that typos aren't caught in the latter anyway ! * (surprisingly?) ! */ ! final public static Locale buildLocale(String field) { ! Locale locale = (Locale) cache.get(field); ! if (locale == null) { ! try { ! Field f = Locale.class.getField(field); ! locale = (Locale) f.get(null); ! } ! catch (Exception ne) { ! StringTokenizer st = new StringTokenizer(field, "_"); ! String[] parts = new String[]{"", "", ""}; ! try { ! for (int i = 0; i < 3; i++) { ! parts[i] = st.nextToken(); ! } ! } ! catch (NoSuchElementException e) { } // System.out.println("Creating Locale: " // +parts[0]+"-"+parts[1]+"-"+parts[2]); ! locale = new Locale(parts[0], parts[1], parts[2]); ! } // System.out.println("Returning locale for "+field+" -> "+locale); ! cache.put(field, locale); ! } ! return locale; ! } ! /** ! * Unsupported ! */ ! final public void put(String key, Object value) ! throws UnsettableException { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove(String key) ! throws UnsettableException { ! throw new UnsettableException("Cannot unset a form property"); ! } ! public void destroy(Object o) { ! } } --- 30,171 ---- import org.webmacro.util.Bag; + import java.lang.reflect.Field; + import java.util.HashMap; + import java.util.Locale; + import java.util.NoSuchElementException; + import java.util.StringTokenizer; + /** * Provide Template with access to Locales. Also gives access to the static * fields e.g., Locale.US */ ! public class LocaleTool implements ContextTool, Bag ! { ! public static final String RCS = "$Id$"; ! private static HashMap cache = new HashMap(); ! public Object init (Context context) ! throws PropertyException ! { ! return this; ! } ! /** ! * return the default locale for this JVM ! */ ! final public Locale getDefault () ! { ! return Locale.getDefault(); ! } ! /** ! * wrappers around the 3 constructors for Locale ! */ ! final public Locale getLocale (String country) ! { ! return getLocale(country, "", ""); ! } ! final public Locale getLocale (String country, String language) ! { ! return getLocale(country, language, ""); ! } ! final public Locale getLocale (String country, String language, String variant) ! { ! String key = country + "_" + language + "_" + variant; // language.toUpperCase() ? ! Locale locale = (Locale) cache.get(key); ! if (locale == null) ! { ! locale = new Locale(country, language, ""); ! cache.put(key, locale); ! } ! return locale; ! } ! /** ! * access method used by $Locale.xxxxx => LocaleTool.get("xxxxx") ! */ ! final public Object get (String field) ! { ! return buildLocale(field); ! } ! /** ! * access to the static members such as Locale.US, etc ! * ! * If that field doesn't exist try to construct a locale ! * from a string so templates can have $Locale.en_GB. ! * ! * This may not be the right thing to do, though, in case of typos ! * ! * e.g., $Locale.ENGLISH => Locale.ENGLISH ! * but $Locale.ENGLSH => Locale("ENGLSH","","") ! * ! * Could argue that typos aren't caught in the latter anyway ! * (surprisingly?) ! */ ! final public static Locale buildLocale (String field) ! { ! Locale locale = (Locale) cache.get(field); ! if (locale == null) ! { ! try ! { ! Field f = Locale.class.getField(field); ! locale = (Locale) f.get(null); } + catch (Exception ne) + { + StringTokenizer st = new StringTokenizer(field, "_"); + String[] parts = new String[]{"", "", ""}; + try + { + for (int i = 0; i < 3; i++) + { + parts[i] = st.nextToken(); + } + } + catch (NoSuchElementException e) + { + } // System.out.println("Creating Locale: " // +parts[0]+"-"+parts[1]+"-"+parts[2]); ! locale = new Locale(parts[0], parts[1], parts[2]); ! } // System.out.println("Returning locale for "+field+" -> "+locale); ! cache.put(field, locale); ! } ! return locale; ! } ! /** ! * Unsupported ! */ ! final public void put (String key, Object value) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot set a form property"); ! } ! /** ! * Unsupported ! */ ! final public void remove (String key) ! throws UnsettableException ! { ! throw new UnsettableException("Cannot unset a form property"); ! } ! public void destroy (Object o) ! { ! } } Index: MathTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/MathTool.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MathTool.java 28 Mar 2003 02:46:00 -0000 1.6 --- MathTool.java 12 Jun 2003 00:47:47 -0000 1.7 *************** *** 34,198 **** */ ! public class MathTool implements ContextTool { ! /** our lonely singleton */ ! private static final MathTool _instance = new MathTool(); ! /** ! * @return the static instance of the MathTool ! */ ! public static final MathTool getInstance() { ! return _instance; ! } ! // ! // static MathTool methods and fields ! // ! /** the value of PI, as defined by <code>java.lang.Math.PI</code> */ ! public static final double PI = java.lang.Math.PI; ! /** ! * @return the smaller of the specified number ! */ ! public static final int min(int a, int b) { ! return (a < b)?a:b; ! } ! public static final long min(long a, long b) { ! return (a < b)?a:b; ! } ! public static final float min(float a, float b) { ! return (a < b)?a:b; ! } ! public static final double min(double a, double b) { ! return (a < b)?a:b; ! } ! /** ! * @return the larger of the specified number ! */ ! public static final int max(int a, int b) { ! return (a > b)?a:b; ! } ! public static final long max(long a, long b) { ! return (a > b)?a:b; ! } ! public static final float max(float a, float b) { ! return (a > b)?a:b; ! } ! public static final double max(double a, double b) { ! return (a > b)?a:b; ! } ! /** ! * Creates a pseudo-random Integer between <code>start</code> ! * and <code>end</code>, inclusive ! */ ! public static final int random(int start, int end) { ! return start + (int)((end - start + 1) * java.lang.Math.random()); ! } ! /** ! * @return <code>base</code> raised to the specified <code>power</code> ! */ ! public static final int pow(int base, int power) { ! return base ^ power; ! } ! public static final long pow(long base, long power) { ! return base ^ power; ! } ! /** ! * @return the absolute value of the specified number ! */ ! public static final int abs(int a) { ! return java.lang.Math.abs(a); ! } ! public static final long abs(long a) { ! return java.lang.Math.abs(a); ! } ! public static final float abs(float a) { ! return java.lang.Math.abs(a); ! } ! public static final double abs(double a) { ! return java.lang.Math.abs(a); ! } ! /** ! * @return <code>a</code> modulo <code>b</code> ! */ ! public static final int mod(int a, int b) { ! return a % b; ! } ! /** ! * Converts args to doubles and multiplies them together. ! * @return <code>a * b</code> ! */ ! public static final double multiply(Number a, Number b){ ! return a.doubleValue() * b.doubleValue(); ! } ! ! /** ! * Converts args to doubles and divides the first by the second. ! * @return <code>a / b</code> ! */ ! public static final double divide(Number a, Number b){ ! return a.doubleValue() / b.doubleValue(); ! } - // - // ContextTool implementation methods - // ! /** default contsructor. Does nothing */ ! public MathTool() { ! } ! /** ! * public constructor. Does nothing. The MathTool doesn't ! * interact with the Context, so it is ignored ! */ ! public MathTool(Context context) { ! } ! /** ! * Tool initialization method. The MathTool doesn't ! * interact with the context, so the <code>context</code> ! * parameter is ignored. ! */ ! public Object init(Context context) throws PropertyException { ! return MathTool.getInstance(); ! } ! /** ! * Perform necessary cleanup work ! */ ! public void destroy(Object o) { ! } ! ! public static void main(String[] args){ ! System.out.println("Generating 200 random ints between 10 and 99 inclusive:"); ! for (int i=0; i<200; i++){ ! System.out.print(MathTool.random(10, 99) + " "); ! if (((i + 1) % 20) == 0) System.out.println(); ! } ! System.out.println("\nDone."); ! } } --- 34,224 ---- */ ! public class MathTool implements ContextTool ! { ! /** our lonely singleton */ ! private static final MathTool _instance = new MathTool(); ! /** ! * @return the static instance of the MathTool ! */ ! public static final MathTool getInstance () ! { ! return _instance; ! } ! // ! // static MathTool methods and fields ! // ! /** the value of PI, as defined by <code>java.lang.Math.PI</code> */ ! public static final double PI = java.lang.Math.PI; ! /** ! * @return the smaller of the specified number ! */ ! public static final int min (int a, int b) ! { ! return (a < b) ? a : b; ! } ! public static final long min (long a, long b) ! { ! return (a < b) ? a : b; ! } ! public static final float min (float a, float b) ! { ! return (a < b) ? a : b; ! } ! public static final double min (double a, double b) ! { ! return (a < b) ? a : b; ! } ! /** ! * @return the larger of the specified number ! */ ! public static final int max (int a, int b) ! { ! return (a > b) ? a : b; ! } ! public static final long max (long a, long b) ! { ! return (a > b) ? a : b; ! } ! public static final float max (float a, float b) ! { ! return (a > b) ? a : b; ! } ! public static final double max (double a, double b) ! { ! return (a > b) ? a : b; ! } ! /** ! * Creates a pseudo-random Integer between <code>start</code> ! * and <code>end</code>, inclusive ! */ ! public static final int random (int start, int end) ! { ! return start + (int) ((end - start + 1) * java.lang.Math.random()); ! } ! /** ! * @return <code>base</code> raised to the specified <code>power</code> ! */ ! public static final int pow (int base, int power) ! { ! return base ^ power; ! } ! public static final long pow (long base, long power) ! { ! return base ^ power; ! } ! /** ! * @return the absolute value of the specified number ! */ ! public static final int abs (int a) ! { ! return java.lang.Math.abs(a); ! } ! public static final long abs (long a) ! { ! return java.lang.Math.abs(a); ! } ! public static final float abs (float a) ! { ! return java.lang.Math.abs(a); ! } ! public static final double abs (double a) ! { ! return java.lang.Math.abs(a); ! } ! /** ! * @return <code>a</code> modulo <code>b</code> ! */ ! public static final int mod (int a, int b) ! { ! return a % b; ! } ! /** ! * Converts args to doubles and multiplies them together. ! * @return <code>a * b</code> ! */ ! public static final double multiply (Number a, Number b) ! { ! return a.doubleValue() * b.doubleValue(); ! } + /** + * Converts args to doubles and divides the first by the second. + * @return <code>a / b</code> + */ + public static final double divide (Number a, Number b) + { + return a.doubleValue() / b.doubleValue(); + } ! // ! // ContextTool implementation methods ! // ! /** default contsructor. Does nothing */ ! public MathTool () ! { ! } ! /** ! * public constructor. Does nothing. The MathTool doesn't ! * interact with the Context, so it is ignored ! */ ! public MathTool (Context context) ! { ! } ! /** ! * Tool initialization method. The MathTool doesn't ! * interact with the context, so the <code>context</code> ! * parameter is ignored. ! */ ! public Object init (Context context) throws PropertyException ! { ! return MathTool.getInstance(); ! } ! ! /** ! * Perform necessary cleanup work ! */ ! public void destroy (Object o) ! { ! } ! ! public static void main (String[] args) ! { ! System.out.println("Generating 200 random ints between 10 and 99 inclusive:"); ! for (int i = 0; i < 200; i++) ! { ! System.out.print(MathTool.random(10, 99) + " "); ! if (((i + 1) % 20) == 0) System.out.println(); ! } ! System.out.println("\nDone."); ! } } Index: RequestTool.java =================================================================== RCS file: /cvsroot/webmacro/webmacro/src/org/webmacro/servlet/RequestTool.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** RequestTool.java 11 Nov 2002 19:22:38 -0000 1.7 --- RequestTool.java 12 Jun 2003 00:47:47 -0000 1.8 *************** *** 31,49 **** * Provide Template with access to form data. */ ! public class RequestTool implements ContextTool { ! public Object init(Context context) ! throws PropertyException { ! try { ! WebContext wc = (WebContext) context; ! return wc.getRequest(); ! } ! catch (ClassCastExceptio... [truncated message content] |