You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2001/11/10 12:53:13 UTC

cvs commit: jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/util FunctionBean.java LabelValueBean.java

husted      01/11/10 03:53:13

  Modified:    contrib/scaffold/WEB-INF build.xml
  Added:       contrib/scaffold/WEB-INF/classes Resources.properties
               contrib/scaffold/WEB-INF/conf struts-config.xml
               contrib/scaffold/WEB-INF/lib index.html
               contrib/scaffold/WEB-INF/src/conf Resources.properties
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http
                        ContinueAction.java HelperAction.java
                        HttpClient.java MasterDetailHelper.java
                        ModelHelper.java RelayAction.java
                        Resources.properties SocketUtil.java TaskForm.java
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang
                        ChainedException.java ConfigureException.java
                        Exceptions.java.save Exceptions.text.txt
                        NestingException.java Tokens.java
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model
                        ModelAbstractException.java ModelBean.java
                        ModelBeanBase.java ModelException.java
                        ModelParameterException.java
                        ModelPopulateException.java
                        ModelResourceException.java ModelResult.java
                        ModelResultBase.java ModelUtils.java
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/search
                        LuceneUtils.java
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/sql
                        ConnectionPool.java ResultSetUtils.java
                        StatementUtils.java
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/text
                        ConvertUtils.java Merge.java Shortcut to Java 2
                        Platform SE v1.4.0 java.text.URL
                        Validator.java.text
               contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/util
                        FunctionBean.java LabelValueBean.java
  Log:
  Add "scaffold" package to contrib folder. Scaffold is a collection of
  utility classes designed to be useful in more than one application.
  
  Revision  Changes    Path
  1.2       +2 -2      jakarta-struts/contrib/scaffold/WEB-INF/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/build.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.xml	2001/11/10 11:38:23	1.1
  +++ build.xml	2001/11/10 11:53:11	1.2
  @@ -1,6 +1,6 @@
   <!-- 
   @author Ted Husted
  -@version $Revision: 1.1 $ $Date: 2001/11/10 11:38:23 $
  +@version $Revision: 1.2 $ $Date: 2001/11/10 11:53:11 $
   -->
   <project name="scaffold" basedir="." default="project.deploy">
   <property name="dist.name" value="scaffold"/>
  @@ -13,7 +13,7 @@
           <pathelement path ="lib/commons-digester.jar"/>
           <pathelement path ="lib/lucene.jar"/>
           <pathelement path ="lib/poolman.jar"/>
  -        <pathelement path ="lib/struts-101.jar"/>
  +        <pathelement path ="lib/struts.jar"/>
           <pathelement path ="classes"/>
           <pathelement path ="${classpath}"/>
       </path>
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/classes/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  index.title=Struts Starter Application
  index.heading=Hello World!
  index.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, reload Struts or restart your container, and you are on your way! You can find the Resources file with this message in the src/conf classes folder. 
  DO NOT EDIT THE Resources.properties FILE UNDER classes. Edit the one under src/conf instead! The build file automatically copies the files from under src/conf to classes in order to simplify a clean build. 
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/conf/struts-config.xml
  
  Index: struts-config.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1" ?>
  
  <!DOCTYPE struts-config PUBLIC
            "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
            "http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
  
  <!--
       This is a blank Struts configuration file based on the example application,
       with commented examples of some items.
  
       NOTE: If you have a generator tool to create the corresponding Java classes 
       for you, you could include the details in the "form-bean" declarations.  
       Otherwise, you would only define the "form-bean" element itself, with the 
       corresponding "name" and "type" attributes, as shown here.
  -->
  
  
  <struts-config>
  
  
    <!-- ========== Data Source Configuration =============================== -->
  <!--
    <data-sources>
      <data-source
         autoCommit="false"
        description="Example Data Source Configuration"
        driverClass="org.postgresql.Driver"
           maxCount="4"
           minCount="2"
           password="mypassword"
                url="jdbc:postgresql://localhost/mydatabase"
               user="myusername"
      />
    </data-sources>
  -->
  
    <!-- ========== Form Bean Definitions =================================== -->
    <form-beans>
  
      <!-- Example logon form bean 
      <form-bean      name="logonForm"
                      type="org.apache.struts.example.LogonForm"/>
       -->
  
    </form-beans>
  
  
    <!-- ========== Global Forward Definitions ============================== -->
    <global-forwards>
  
      <!-- Example logon forward 
       <forward   name="logon"                path="/logon.jsp"/>
       -->
  
    </global-forwards>
  
  
    <!-- ========== Action Mapping Definitions ============================== -->
    <action-mappings>
  
      <!-- Example logon action 
      <action    path="/logon"
                 type="org.apache.struts.example.LogonAction"
                 name="logonForm"
                scope="request"
                input="/logon.jsp">
      </action>
      -->
  
      <!-- Example logoff action 
      <action    path="/logoff"
                 type="org.apache.struts.example.LogoffAction">
        <forward name="success"              path="/index.jsp"/>
      </action>
      -->
  
  
      <!-- The standard administrative actions available with Struts -->
      <!-- These would be either omitted or protected by security -->
      <!-- in a real application deployment -->
      <action    path="/admin/addFormBean"
                 type="org.apache.struts.actions.AddFormBeanAction"/>
      <action    path="/admin/addForward"
                 type="org.apache.struts.actions.AddForwardAction"/>
      <action    path="/admin/addMapping"
                 type="org.apache.struts.actions.AddMappingAction"/>
      <action    path="/admin/reload"
                 type="org.apache.struts.actions.ReloadAction"/>
      <action    path="/admin/removeFormBean"
                 type="org.apache.struts.actions.RemoveFormBeanAction"/>
      <action    path="/admin/removeForward"
                 type="org.apache.struts.actions.RemoveForwardAction"/>
      <action    path="/admin/removeMapping"
                 type="org.apache.struts.actions.RemoveMappingAction"/>
  
  
    </action-mappings>
  
  </struts-config>
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/lib/index.html
  
  Index: index.html
  ===================================================================
  <html>
  <body>
  
  <p>See the build.xml for JARs expected to be available here.</p>
  <ul>
  <li>commons-digester.jar - jakarta.apache.org/commons
  <li>lucene.jar - jakarta.apache.org/lucene
  <li>struts.jar - jararta.apache.org/struts
  <li>poolman.jar - codestudio.com
  </ul>
  
  <p>Also these tld's </p>
  
  <ul>
  <li>struts-bean.tld
  <li>struts-html.tld
  <li>struts-logic.tld
  </ul>
  
  </body>
  </html>
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/conf/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  index.title=Struts Starter Application
  index.heading=Hello World!
  index.message=To get started on your own application, copy the struts-blank.war to a new WAR file using the name for your application. Place it in your container's "webapp" folder (or equivalent), and let your container auto-deploy the application. Edit the skeleton configuration files as needed, reload Struts or restart your container, and you are on your way! You can find the Resources file with this message in the src/conf classes folder. 
  DO NOT EDIT THE Resources.properties FILE UNDER classes. Edit the one under src/conf instead! The build file automatically copies the files from under src/conf to classes in order to simplify a clean build. 
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/ContinueAction.java
  
  Index: ContinueAction.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Standard Action to forward control to continue.
   * Useful for prototyping flow during development,
   * and for creating blank forms for new input.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public final class ContinueAction extends Action {
  
      /**
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
          return mapping.findForward(Tokens.CONTINUE);
  
      }
  
  } // end RelayAction
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/ContinueAction.java,v 1.1 2001/11/10 11:53:11 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/HelperAction.java
  
  Index: HelperAction.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.List;
  import java.util.Locale;
  import java.util.StringTokenizer;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpSession;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  
  import org.apache.struts.util.MessageResources;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Base class to instantiate helper objects from
   * parameter mapping. Subclasses should
   * override the alternate perform to provide
   * functionality. The standard perform will
   * instantiate the object, and call the
   * other perform method.
   * <p>
   * Multiple helper classes may be specified in a
   * comma delimited list, which will be instantiated
   * in the helpers array in the order given.
   * <p>
   * Will also look for cancel and token mappings,
   * and automatically redirect if those are present
   * and an error condition is detected.
   * <p>
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public class HelperAction extends Action {
  
  
  // --------------------------------------------------------- Public Methods
  
      /**
       * Return the locale for the given request. If no session is set,
       * or if the session has no locale set, the default locale
       * is returned.
       * @author  Fran�ois Rey (FREY - francois.rey@capco.com)
       * @author  Eric Bariaux (EBRX - eric.bariaux@capco.com)
       */
      public Locale getLocale(HttpServletRequest request) {
          Locale result = null;
          HttpSession session = request.getSession();
          if (session!=null) {
              result = (Locale) session.getAttribute(Action.LOCALE_KEY);
              if (result == null) result = Locale.getDefault();
          } else {
              result = Locale.getDefault();
          }
          return result;
      }
  
  
      /**
       * Return the application resources for this web application, if any.
       */
      public MessageResources getMessageResources() {
          return servlet.getResources();
      }
  
  
      /**
       * Number of replacement parameters permitted in Struts 1.0.
       * See also saveConfirm.
       */
      public static int CONFIRM_MAX = 5; // (Message Key, plus 1..4)
  
  
      /**
       * Retrieves a base messages and up to four replaceable
       * parameters from a List, and adds them as an ActionError.
       */
      public boolean saveMessage(ActionErrors errors, List messages) {
          if ((messages==null) || (messages.size()==0)) {
              return false;
          }
          int size = messages.size();
              // Struts 1.0 allows up to 4 parameters, 1..4
          if (size > CONFIRM_MAX) size = CONFIRM_MAX;
          String[] confirm = new String[size];
          for (int i=0; i<size; i++) {
              confirm[i] = (String) messages.get(i);
          }
          switch (size) {
             case 5:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2],confirm[3],confirm[4]));
                  break;
             case 4:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2],confirm[3]));
                  break;
             case 3:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1],confirm[2]));
                  break;
             case 2:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0],
                          confirm[1]));
                  break;
             case 1:
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError(confirm[0]));
          }
          return true;
      }
  
  
      /**
       * Simple test to render String version of instantiated
       * helpers. Should be overridden to provide functionality
       * (without calling super!).
       * @param mapping The ActionMapping used to select this instance
       * @param form The ActionForm
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @param helper The object instantiated from type given as parameter.
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers)
      throws IOException, ServletException {
          // override to provide new functionality
          response.setContentType("text/plain");
          for (int i = 0; i < helpers.length; i++)
              response.getWriter().print(helpers[i].toString());
          return (null);
      }
  
  
      /**
       * Instantiate helper objects from the type given as the
       * ActionMapping parameter (delimited with semicolons), and call
       * the alternate perform.
       * Will not call "helper" perform if helper creation fails.
       * The error is logged, and null returned.
       * <p>
       * Also checks for cancel and token conditions, if an
       * appropriate forward is present.
       * @param mapping The ActionMapping used to select this instance
       * @param form The ActionForm
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * <p>
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
          // Check for cancelled
          ActionForward forward = mapping.findForward(Tokens.CANCEL);
          if ((forward!=null) && (isCancelled(request))) {
              return (forward);
          }
  
          // Check for missing token
          forward = mapping.findForward(Tokens.TOKEN);
          if ((forward!=null) && (!isTokenValid(request))) {
              return (forward);
          }
  
          // This creates a helper for each request.
          // Using data fields in the helper object is thread safe.
          StringTokenizer helperClasses =
              new StringTokenizer(mapping.getParameter(),";");
          int i = -1;
          Object[] helpers = new Object[helperClasses.countTokens()];
          while (helperClasses.hasMoreTokens()) {
              String helperClass = helperClasses.nextToken().trim();
              if ((helperClass==null) || (helperClass.length()==0)) continue;
              servlet.log("  Creating Helper for class " + helperClass,1);
              try {
                  helpers[++i] = Class.forName(helperClass).newInstance();
              } catch (Throwable t) {
                  servlet.log("Error creating Helper instance for path '" +
                  mapping.getPath() + "', class name '" +
                  helperClass + "'",t);
                  return (null);
              }
              servlet.log("  Helper created " + helperClass,2);
              // Pass control to alternate perform
              // which should be overridden by subclass.
          }
  
          return perform(mapping,form,request,response,helpers);
  
      } // end perform
  
  } // end HelperAction
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/HelperAction.java,v 1.1 2001/11/10 11:53:11 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/HttpClient.java
  
  Index: HttpClient.java
  ===================================================================
  package org.apache.scaffold.http;
  
  import java.net.*;
  import java.io.*;
  
  /**
   * A network client that reads from a HTTP URL.
   * <P>
   * Taken from Core Servlets and JavaServer Pages
   * from Prentice Hall and Sun Microsystems Press,
   * http://www.coreservlets.com/.
   * &copy; 2000 Marty Hall; may be freely used or adapted.
   * <P>
   * Adapted for general use by a servlet to read a page
   * into a StringBuffer by Ted Husted, August 2001.
   * <P>
   * @author Marty Hall
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public class HttpClient {
  
      /**
       * Retrieve indicated page, returning headers and
       * page content.
       * <P>
       * @params host
       * @params port
       * @params requestLine
       * @params requestHeaders
       * @params content
       * @exception Catches IOException and UnknownHostException,
       * and returns messages in content.
       * @author Marty Hall
       * @author Ted Husted
       * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
       */
      public HttpClient(
              String host, int port,
              String requestLine, String[] requestHeaders,
              StringBuffer responseHeaders, StringBuffer responseContent)
                  throws UnknownHostException,IOException {
  
          // -- check host and connect - Will succeed or throw UHE
          InetAddress.getByName(host);
          Socket uriSocket = new Socket(host,port);
  
          // -- handleConnection - May throw IOE
          PrintWriter out = SocketUtil.getWriter(uriSocket);
          BufferedReader in = SocketUtil.getReader(uriSocket);
  
          // -- say howdy
          out.println(requestLine);
  
          // -- send any headers, and then blank
          for(int i=0; i<requestHeaders.length; i++) {
              if (requestHeaders[i] == null)
                  break;
              else
                  out.println(requestHeaders[i]);
          }
          out.println();
  
          // -- capture response
          String line;
          // - headers
          while ((line = in.readLine()) != null) {
              responseHeaders.append(line + "\n");
              if ("".equals(line)) break;
          }
          // - content
          while ((line = in.readLine()) != null)
              responseContent.append(line + "\n");
     }
  }
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/MasterDetailHelper.java
  
  Index: MasterDetailHelper.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionMapping;
  
  import org.apache.scaffold.model.ModelBean;
  import org.apache.scaffold.model.ModelResult;
  import org.apache.scaffold.model.ModelException;
  
  
  /**
   * Standard Action to manage helper objects.
   * This provides the same default behavior as ModelHelper,
   * but expects two helpers. The first retrieves a "master"
   * record that is returned in the ActionForm. The second
   * retrieves detail based on the master. (A field in the
   * master record would usually match a field in the detail.)
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public class MasterDetailHelper extends ModelHelper {
  
  
      /**
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param helpers The helper objects
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ModelResult getResult(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers) throws ModelException {
  
          // Run master query; populate form with master record
          ModelResult result = super.getResult(mapping,form,request,response,helpers);
  
          if (helpers.length==1)
              return result;
          else {
              // Return detail from helper, using master as key
              ModelBean detail = (ModelBean) helpers[1];
              result = detail.execute(helpers[0]);
              return result;
         }
  
      }
  
  
  } // end ModelResultHelper
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/MasterDetailHelper.java,v 1.1 2001/11/10 11:53:11 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/ModelHelper.java
  
  Index: ModelHelper.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  import java.util.Map;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  // import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionError;
  import org.apache.struts.action.ActionErrors;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.scaffold.lang.Tokens;
  import org.apache.scaffold.model.ModelBean;
  import org.apache.scaffold.model.ModelException;
  import org.apache.scaffold.model.ModelResult;
  
  
  /**
   * Standard Action to manage helper objects.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public class ModelHelper extends HelperAction {
  
  
      /**
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param helper The helper object
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       * :FIXME: is there any valid use of the response here?
       */
      public ModelResult getResult(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers) throws ModelException {
  
          ModelBean modelBean = (ModelBean) helpers[0];
          ModelResult modelResult = modelBean.execute(form);
              // Shouldn't return null
          if (modelResult!=null)
              modelResult.populate(form,0);
          return (modelResult);
  
      }
  
  
      /**
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @param helper The helper object
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response,
                   Object[] helpers)
      throws IOException, ServletException {
  
          ActionErrors errors = new ActionErrors();
          ModelResult modelResult = null;
  
          try {
              modelResult = getResult(
                  mapping,form,request,response,helpers);
          }
          catch (ModelException e) {
                  // Log and print to error console
              servlet.log("Model Exception: ", e );
              e.printStackTrace();
                  // General error message
              errors.add(ActionErrors.GLOBAL_ERROR,
                  new ActionError("error.general"));
                  // Generate error messages from exceptions
              errors.add(ActionErrors.GLOBAL_ERROR,
                  new ActionError("error.detail",e.getMessage()));
              if (e.isCause()) {
                  errors.add(ActionErrors.GLOBAL_ERROR,
                      new ActionError("error.detail",e.getCauseMessage()));
              }
          }
  
          // -- Report any errors
          if (!errors.empty()) {
              saveErrors(request, errors);
              if (mapping.getInput()!=null)
                  return (new ActionForward(mapping.getInput()));
              // If no input page, use error forwarding
              return (mapping.findForward("error"));
          }
  
          // -- Check for confirmation message
          if (modelResult!=null)
              saveMessage(errors,modelResult.getMessages());
  
          // -- Save any confirmations
          if (!errors.empty())
              saveErrors(request, errors);
  
          // -- Save the result
          request.setAttribute(ModelResult.TOKEN,modelResult);
  
          // -- Return empty (if appropriate) or continue
          ActionForward forward = null;
          if (modelResult.getSize()==0)
              forward = mapping.findForward(Tokens.EMPTY);
          if (forward!=null)
              return forward;
          return mapping.findForward(Tokens.CONTINUE);
      };
  
  } // end ModelResultHelper
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/ModelHelper.java,v 1.1 2001/11/10 11:53:11 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/RelayAction.java
  
  Index: RelayAction.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.io.IOException;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import org.apache.struts.action.Action;
  import org.apache.struts.action.ActionForm;
  import org.apache.struts.action.ActionForward;
  import org.apache.struts.action.ActionMapping;
  import org.apache.struts.action.ActionServlet;
  
  import org.apache.scaffold.lang.Tokens;
  
  
  /**
   * Standard Action to forward control to another mapping
   * given as a runtime parameter (?forward=).
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public final class RelayAction extends Action {
  
      /**
       * @param mapping The ActionMapping used to select this instance
       * @param actionForm The optional ActionForm bean for this request (if any)
       * @param request The HTTP request we are processing
       * @param response The HTTP response we are creating
       * @exception IOException if an input/output error occurs
       * @exception ServletException if a servlet exception occurs
       */
      public ActionForward perform(ActionMapping mapping,
                   ActionForm form,
                   HttpServletRequest request,
                   HttpServletResponse response)
      throws IOException, ServletException {
  
          return mapping.findForward(request.getParameter(Tokens.FORWARD));
  
      }
  
  } // end RelayAction
  
  
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/RelayAction.java,v 1.1 2001/11/10 11:53:11 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:11 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  # @author Ted Husted
  # @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
  #
  # --!! FOR REFERENCE ONLY !!-- 
  # --!! YOU MUST COPY THESE TO YOUR APPLICATION'S FILE !!--
  # -- See also constants in lang/Tokens --
  #
  # -- data --
  data.access.denied=<li>Access denied.</li>
  data.access.error=<li>Unable to access database.</li>
  data.access.empty=<li>Requested records were not found.</li>
  data.record.inserted=<li>Record {0} inserted.</li>
  data.record.updated=<li>Record {0} updated.</li>
  data.record.deleted=<li>Record {0} deleted.</li>
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/SocketUtil.java
  
  Index: SocketUtil.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import java.net.*;
  import java.io.*;
  
  
  /** A shorthand way to create BufferedReaders and
   *  PrintWriters associated with a Socket.
   *  <P>
   *  Taken from Core Servlets and JavaServer Pages
   *  from Prentice Hall and Sun Microsystems Press,
   *  http://www.coreservlets.com/.
   *  &copy; 2000 Marty Hall; may be freely used or adapted.
   */
  public class SocketUtil {
    /** Make a BufferedReader to get incoming data. */
  
    public static BufferedReader getReader(Socket s)
        throws IOException {
      return(new BufferedReader(
           new InputStreamReader(s.getInputStream())));
    }
  
    /** Make a PrintWriter to send outgoing data.
     *  This PrintWriter will automatically flush stream
     *  when println is called.
     */
  
    public static PrintWriter getWriter(Socket s)
        throws IOException {
      // 2nd argument of true means autoflush
      return(new PrintWriter(s.getOutputStream(), true));
    }
  }
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/http/TaskForm.java
  
  Index: TaskForm.java
  ===================================================================
  package org.apache.scaffold.http;
  
  
  import org.apache.struts.action.ActionForm;
  
  
  /**
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:11 $
   */
  public class TaskForm extends ActionForm {
  
  // --------------------------------------------------- Instance Variables
  // ----------------------------------------------------------- Properties
  
      /**
       */
      private String task = null;
  
      /**
       */
      public String getTask() {
          return (this.task);
      }
  
      /**
       */
      public void setTask(String task) {
          this.task = task;
      }
  
  
  // --------------------------------------------------------- Public Methods
  
  // ----- end TaskForm -----
  
  }
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/ChainedException.java
  
  Index: ChainedException.java
  ===================================================================
  /**
   * Mimicks new functionality in 1.4
   */
  
  package org.apache.scaffold.lang;
  
  
      /**
       * http://www.javaworld.com/javaworld/jw-08-2001/jw-0803-exceptions.html
       * @author Brian Geotz
       * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
       */
      public class ChainedException extends Exception {
  
           private Throwable cause;
  
           public ChainedException() {
               super();
           }
  
           public ChainedException(String message) {
               super(message);
           }
  
           public ChainedException(String message, Throwable cause) {
               super(message);
               this.cause = cause;
           }
  
           public Throwable getCause() {
               return this.cause;
           }
  
           public boolean isCause() {
               return (this.cause!=null);
           }
  
           public String getCauseMessage() {
               if (this.cause==null)
                  return null;
               return this.cause.getMessage();
           }
  
           public void printStackTrace() {
               super.printStackTrace();
               if (cause != null) {
                   System.err.println("Caused by:");
                   cause.printStackTrace();
               }
           }
  
           public void printStackTrace(java.io.PrintStream ps) {
               super.printStackTrace(ps);
               if (cause != null) {
                   ps.println("Caused by:");
                   cause.printStackTrace(ps);
               }
           }
  
           public void printStackTrace(java.io.PrintWriter pw) {
               super.printStackTrace(pw);
               if (cause != null) {
                   pw.println("Caused by:");
                   cause.printStackTrace(pw);
               }
           }
  
      }
  
  
  
   /*
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
    *
    * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
    *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
    *    the documentation and/or other materials provided with the
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
    *    any, must include the following acknowlegement:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowlegement may appear in the software itself,
    *    if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
    *    Foundation" must not be used to endorse or promote products derived
    *    from this software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache"
    *    nor may "Apache" appear in their names without prior written
    *    permission of the Apache Group.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    * SUCH DAMAGE.
    * ====================================================================
    *
    * This software consists of voluntary contributions made by many
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
    */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/ConfigureException.java
  
  Index: ConfigureException.java
  ===================================================================
  package org.apache.scaffold.lang;
  
  
  /**
   * http://www.javaworld.com/javaworld/javatips/jw-javatip91.html
   * @author Terren Suydam 
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ConfigureException extends NestingException {
  	 public ConfigureException() {}
  	 public ConfigureException(String msg) {
  			 super(msg);
  	 }
  	 public ConfigureException(Exception nestedException) {
  			 super(nestedException);
  	 }
  	 public ConfigureException(String msg, Exception nestedException){
  			 super(msg, nestedException);
  	 }
  }
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/Exceptions.java.save
  
  Index: Exceptions.java.save
  ===================================================================
  package org.apache.scaffold.util;
  
  
  import java.util.ArrayList;
  import java.util.Iterator;
  
  
  /**
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class Exceptions extends ArrayList {
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/Exceptions.text.txt
  
  Index: Exceptions.text.txt
  ===================================================================
  - DAOExceptions (SQL, Remote, Create et al) -> Scaffold
  - http://java.sun.com/j2ee/j2sdkee/techdocs/api/javax/ejb/package-summary.html
  - http://java.sun.com/j2se/1.3.0/docs/api/java/sql/package-summary.html
  - http://java.sun.com/j2ee/blueprints/design_patterns/data_access_object/index.html
  - http://java.sun.com/j2ee/blueprints/book/eis-tier13.html
  
  CreateException
  The CreateException exception must be included in the throws clauses of all create(...) methods define in an enterprise Bean's remote interface.
  
  DuplicateKeyException
  The DuplicateKeyException exception is thrown if an entity EJB object cannot be created because an object with the same key already exists.
  
  EJBException
  The EJBException exception is thrown by an enterprise Bean instance to its container to report that the invoked business method or callback method could not be completed because of an unexpected error (e.g.
  
  FinderException
  The FinderException exception must be included in the throws clause of every findMETHOD(...) method of an entity Bean's home interface.
  
  NoSuchEntityException
  The NoSuchEntityException exception is thrown by an enterprise Bean instance to its container to report that the invoked business method or callback method could not be completed because of the underlying entity was removed from the database.
  
  ObjectNotFoundException
  The ObjectNotFoundException exception is thrown by a finder method to indicate that the specified EJB object does not exist.
  
  RemoveException
  The RemoveException exception is thrown at an attempt to remove an EJB object when the enterprise Bean or the container does not allow the EJB object to be removed.
  
  BatchUpdateException
  An exception thrown when an error occurs during a batch update operation.
  
  DataTruncation
  An exception that reports a DataTruncation warning (on reads) or throws a DataTruncation exception (on writes) when JDBC unexpectedly truncates a data value.
  
  SQLException
  An exception that provides information on a database access error or other errors.
  
  SQLWarning
  An exception that provides information on database access warnings.
  
  []
  
  Date
  A thin wrapper around a millisecond value that allows JDBC to identify this as a SQL DATE.
  
  DriverManager
  The basic service for managing a set of JDBC drivers.
  NOTE: The DataSource interface, new in the JDBC 2.0 API, provides another way to connect to a
  data source.
  
  DriverPropertyInfo
  Driver properties for making a connection.
  
  SQLPermission
  The permission for which the SecurityManager will check when code that is running in an applet
  calls one of the setLogWriter methods.
  
  Time
  A thin wrapper around java.util.Date that allows JDBC to identify this as a SQL TIME value.
  
  Timestamp
  A thin wrapper around java.util.Date that allows the JDBC API to identify this as an SQL TIMESTAMP value.
  
  Types
  The class that defines the constants that are used to identify generic SQL types, called JDBC types.
  
  []
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/NestingException.java
  
  Index: NestingException.java
  ===================================================================
  package org.apache.scaffold.lang;
  
  
  import java.io.StringWriter;
  import java.io.PrintWriter;
  
  
  /**
   * http://www.javaworld.com/javaworld/javatips/jw-javatip91.html
   * @author Terren Suydam
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class NestingException extends Exception {
       // the nested exception
  
       private Throwable nestedException;
       // String representation of stack trace - not transient!
  
       private String stackTraceString;
       // convert a stack trace to a String so it can be serialized
  
       static public String generateStackTraceString(Throwable t) {
  
               StringWriter s = new StringWriter();
  
               t.printStackTrace(new PrintWriter(s));
  
               return s.toString();
  
       }
       // java.lang.Exception constructors
  
       public NestingException() {}
       public NestingException(String msg) {
  
               super(msg);
  
       }
       // additional c'tors - nest the exceptions, storing the stack trace
  
       public NestingException(Throwable nestedException) {
  
               this.nestedException = nestedException;
  
               stackTraceString = generateStackTraceString(nestedException);
  
       }
       public NestingException(String msg, Throwable nestedException) {
  
               this(msg);
  
               this.nestedException = nestedException;
  
               stackTraceString = generateStackTraceString(nestedException);
  
       }
       // methods
  
       public Throwable getNestedException() {return nestedException;}
       // descend through linked-list of nesting exceptions, & output trace
  
       // note that this displays the 'deepest' trace first
  
       public String getStackTraceString() {
  
               // if there's no nested exception, there's no stackTrace
  
               if (nestedException == null)
                       return null;
               StringBuffer traceBuffer = new StringBuffer();
               if (nestedException instanceof NestingException) {
  
  traceBuffer.append(((NestingException)nestedException).getStackTraceString());
  traceBuffer.append("-------- nested by:\n");
  
               }
               traceBuffer.append(stackTraceString);
  
               return traceBuffer.toString();
  
       }
       // overrides Exception.getMessage()
  
       public String getMessage() {
  
               // superMsg will contain whatever String was passed into the
               // constructor, and null otherwise.
  
               String superMsg = super.getMessage();
               // if there's no nested exception, do like we would always do
  
               if (getNestedException() == null)
  
                       return superMsg;
               StringBuffer theMsg = new StringBuffer();
               // get the nested exception's message
  
               String nestedMsg = getNestedException().getMessage();
               if (superMsg != null)
                       theMsg.append(superMsg).append(": ").append(nestedMsg);
               else
                       theMsg.append(nestedMsg);
               return theMsg.toString();
  
       }
       // overrides Exception.toString()
  
       public String toString() {
  
               StringBuffer theMsg = new StringBuffer(super.toString());
               if (getNestedException() != null)
  
                       theMsg.append("; \n\t---> nested ").append(getNestedException());
               return theMsg.toString();
  
       }
  }
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/lang/Tokens.java
  
  Index: Tokens.java
  ===================================================================
  package org.apache.scaffold.lang;
  
  
  /**
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public final class Tokens {
  
  
      // ---- Common Action Mapping tokens ---
  
      public static final String CANCEL   = "cancel";
      public static final String CONTINUE = "continue";
      public static final String DONE     = "done";
      public static final String EMPTY    = "empty";
      public static final String ERROR    = "error";
      public static final String EXIT     = "exit";
      public static final String FORWARD  = "forward";
      public static final String LOGON    = "logon";
      public static final String LOGOFF   = "logoff";
      public static final String MENU     = "menu";
      public static final String NEXT     = "next";
      public static final String PREVIOUS = "previous";
      public static final String TOKEN    = "token";
      public static final String WELCOME  = "welcome";
  
  
      // ---- Common Application Resource tokens ---
  
      public static final String DATA_ACCESS_DENIED =
          "data.access.denied";
  
      public static final String DATA_ACCESS_ERROR =
          "data.access.error";
  
      public static final String DATA_ACCESS_EMPTY =
          "data.access.empty"; // not found
  
      public static final String DATA_RECORD_INSERTED =
          "data.record.inserted";
  
      public static final String DATA_RECORD_UPDATED =
          "data.record.updated";
  
      public static final String DATA_RECORD_DELETED =
          "data.record.deleted";
  
      public static final String DATA_RECORD_ =
          "data.access.denied";
  
  
  // ---- End Tokens ----
  
  }
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelAbstractException.java
  
  Index: ModelAbstractException.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  /**
   * Exception for error accessing a non-concrete method.
   * (index file, data file).
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelAbstractException extends ModelException {
  
     public static final String MESSAGE =
          "Required method not implemented.";
  
      public ModelAbstractException (String message) {
          super (message);
      }
  
      public ModelAbstractException (String message, Throwable cause) {
          super (message, cause);
      }
  
      public ModelAbstractException (Throwable cause) {
          super (MESSAGE,cause);
      }
  
      public ModelAbstractException () {
          super (MESSAGE);
      }
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelBean.java
  
  Index: ModelBean.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  /**
   * Manages transfering data between the application layer
   * and the resource layer using JavaBeans.
   * A caller can pass one bean to populate a subclass,
   * and another bean to use as a factory for a
   * collection of beans to return. The ResultSetUtils
   * can be used to help create the collection.
   * The key fields are a convenience for framing
   * queries.
   * Known implementations: ModelBeanBase.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public interface ModelBean {
  
      // --------------------------------------------------- Instance Variables
      // ----------------------------------------------------------- Properties
  
      /**
       * Return the key
       * @return the key
       */
      public String getKey();
  
  
      /**
       * Set the key
       * @param key The new key
       */
      public void setKey(String key);
  
  
      /**
       * Return the key as an Integer
       * @return the key
       */
      public Integer getKeyInteger();
  
  
      /**
       * Set the key as an Integer
       * @param key The new key
       */
      public void setKeyInteger(Integer key);
  
  
      /**
       * Return the Key as an Int
       * @return the key
       */
      public int getKeyInt();
  
  
      /**
       * Set the key as an Int
       * @param key The new key
       */
      public void setKeyInt(int key);
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Set properties from given object.
       * Base method uses <code>BeanUtils.populate</code> and
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelException on any error.
       */
      public void set(Object o) throws ModelException;
  
  
      /**
       * Populate matching properties on given object.
       * Base method uses <code>BeanUtils.populate</code> and
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelException on any error.
       */
      public void populate(Object o) throws ModelException;
  
  
      /**
       * Perform query for this bean, and return outcome in a ModelResult
       * collection of this QueryBean class, e.g. execute(source, this).
       * @exception ModelException
       * @returns null on success, or the outcome in a ModelResult
       */
      public ModelResult execute(Object source) throws ModelException;
  
  
      /**
       * Set properties from object, perform query for this bean,
       * and return outcome in a ModelResult collection of the
       * target bean.
       * @exception ModelException
       * @returns null on success, or the outcome in a ModelResult
       */
      public ModelResult execute(Object source, Object target) throws ModelException;
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelBeanBase.java
  
  Index: ModelBeanBase.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * Base implementation of ModelBean with
   * default functionality.
   * The only method that must be overridden is
   * ModelResult execute(Object target).
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public abstract class ModelBeanBase implements ModelBean {
  
  // --------------------------------------------------- Instance Variables
  // ----------------------------------------------------------- Properties
  
      /**
       * A convenience property representing
       * a search key for this bean.
       */
      protected String key = null;
  
  
      /**
       * Return the Key.
       * @return the key
       */
      public String getKey() {
          return this.key;
      }
  
  
      /**
       * Set the Key.
       * @param key The new key.
       */
      public void setKey(String key) {
          this.key = key;
      }
  
  
      /**
       * Return the Key as an Integer, or null.
       * @return the key
       */
      public Integer getKeyInteger() {
          Integer keyInteger;
          String keyString = getKey();
          if (keyString==null)
              keyInteger = null;
          else {
              try {
                  keyInteger = Integer.valueOf(keyString);
              } catch (java.lang.NumberFormatException e) {
                  keyInteger = null;
              }
          }
          return keyInteger;
      }
  
  
      /**
       * Set the Key as an Integer.
       * @param key The new key
       */
      public void setKeyInteger(Integer key) {
          if (key==null)
              setKey(null);
          else
              setKey(key.toString());
      }
  
  
      /**
       * Value to return if int conversion fails.
       */
      protected int NULL_INT = 0;
  
  
      /**
       * Return the Key as an int, or NULL_INT.
       * Generic accessor linked to this object's key field, if any
       * @return the key
       */
      public int getKeyInt() {
          int keyInt;
          String keyString = getKey();
          if (isBlank(keyString))
              keyInt = NULL_INT;
          else {
              try {
                  keyInt = Integer.parseInt(key);
              } catch (java.lang.NumberFormatException e) {
                  keyInt = NULL_INT;
              }
          }
          return keyInt;
      }
  
  
      /**
       * Set the Key as an int.
       * @param key The new key
       */
      public void setKeyInt(int key) {
          setKey(new Integer(key).toString());
      }
  
  
  
  // --------------------------------------------------------- Public Methods
  
  
      /**
       * A static, empty String used by isBlank.
       */
       private static String EMPTY = "";
  
  
      /**
       * Convenience method to check for a null or empty String.
       */
      protected boolean isBlank(String s) {
          return ((s==null) || (EMPTY.equals(s)));
      }
  
  
      /**
       * Set properties from given object.
       * Base method uses <code>BeanUtils.populate</code> and
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelPopulateException on any error.
       */
      public void set(Object o) throws ModelException {
          try {
              BeanUtils.populate(this,BeanUtils.describe(o));
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
        }
      };
  
  
      /**
       * Populate matching properties on given object.
       * Base method uses <code>BeanUtils.populate</code> and
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelPopulateException on any error.
       */
      public void populate(Object o) throws ModelException {
          try {
              BeanUtils.populate(o,BeanUtils.describe(this));
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
        }
      }
  
  
      /**
       * Set properties from source, perform query for this bean,
       * and return outcome in a ModelResult collection of this
       * QueryBean class, e.g. execute(source, this).
       * @exception ModelException
       * @returns null on success, or the outcome in a ModelResult
       */
      public ModelResult execute(Object source)
          throws ModelException {
              set(source);
              return execute(source,this);
      }
  
  
      /**
       * Perform query for this bean and return outcome in a ModelResult
       * collection of the target bean. Does not autopopulate.
       * Default behavior calls populate and perform.
       * @exception ModelException
       * @returns null on success, or the outcome in a ModelResult
       */
      public abstract ModelResult execute(Object source, Object target)
          throws ModelException;
  
  
  // ----- end ModelBeanBase -----
  
  }
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelException.java
  
  Index: ModelException.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  import org.apache.scaffold.lang.ChainedException;
  
  
  /**
   * Exceptions for Model classes.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelException extends ChainedException {
  
      public ModelException (String message) {
          super (message);
      }
  
      public ModelException (String message, Throwable cause) {
          super (message, cause);
      }
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelParameterException.java
  
  Index: ModelParameterException.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  /**
   * Exception for error accessing a resource needed for a model
   * (index file, data file).
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelParameterException extends ModelException {
  
     public static final String MESSAGE =
          "Required input is missing or invalid.";
  
      public ModelParameterException (String message) {
          super (message);
      }
  
      public ModelParameterException (String message, Throwable cause) {
          super (message, cause);
      }
  
      public ModelParameterException (Throwable cause) {
          super (MESSAGE,cause);
      }
  
      public ModelParameterException () {
          super (MESSAGE);
      }
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelPopulateException.java
  
  Index: ModelPopulateException.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  /**
   * Exception for error populating model.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelPopulateException extends ModelException {
  
     public static final String MESSAGE =
          "Unable to transfer data";
  
      public ModelPopulateException (String message) {
          super (message);
      }
  
      public ModelPopulateException (String message, Throwable cause) {
          super (message, cause);
      }
  
      public ModelPopulateException (Throwable cause) {
          super (MESSAGE,cause);
      }
  
      public ModelPopulateException () {
          super (MESSAGE);
      }
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelResourceException.java
  
  Index: ModelResourceException.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  /**
   * Exception for error accessing a resource needed for a model
   * (index file, data file).
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelResourceException extends ModelException {
  
     public static final String MESSAGE =
          "A required resource is not available.";
  
      public ModelResourceException (String message) {
          super (message);
      }
  
      public ModelResourceException (String message, Throwable cause) {
          super (message, cause);
      }
  
      public ModelResourceException (Throwable cause) {
          super (MESSAGE,cause);
      }
  
      public ModelResourceException () {
          super (MESSAGE);
      }
  
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelResult.java
  
  Index: ModelResult.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  
  
  /**
   * Convenient wrapper for collections of JavaBeans returned
   * from the resource layer.
   * May be inserted in the request context and accessed by
   * tag extensions.
   * The message list can be used to pass confirmations
   * back up from the resource layer.
   * The description property is useful as a caption for the
   * collection.
   * Wrappers for interate and size are provided so that they
   * can be accessed as getIterate and getSize.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public interface ModelResult {
  
  
  // ------------------------------------------------------------- Statics
  
      /**
       * A standard token to identify this object.
       */
      public static String TOKEN = "RESULT";
  
  
      /**
       * The wild card character for a blank select.
       */
      public static String PARAM_ANY = "*";
  
  
      /**
       * The equality indicator for description property.
       */
      public static String PARAM_EQUALS = " = ";
  
  
  // ----------------------------------------------------------- Properties
  
      /**
       * Add a message to the List.
       */
      public boolean addMessage(String message);
  
  
      /**
       * Return the messages.
       */
      public List getMessages();
  
  
      /**
       * Return the description.
       * @return the description
       */
      public String getDescription();
  
  
      /**
       * Set the description.
       * @param description The new description
       */
      public void setDescription(String description);
  
  
      /**
       * Set the description as "column = key".
       * @param description1 The attribute description
       * @param description2 The value description
       */
      public void setDescription(String key, String column);
  
  
      /**
       * Return the number of elements on the List.
       * @return the size of the List
       */
      public int size();
  
  
      /**
       * Accessor for <code>size()</code>.
       * @return the size of the List
       */
      public int getSize();
  
  
      /**
       * Return an iterator for the List,
       * or null if there is no List.
       * @return an iterator for the List
       */
      public Iterator iterator();
  
  
      /**
       * Accessor for <code>iterator()</code>.
       * @return an iterator for the List
       */
      public Iterator getIterator();
  
  
      /**
       * Appends the specified element to the end of the List.
       * @return the row count
       */
      public boolean add(Object o);
  
  
      /**
       * Appends all of the elements in the specified Collection
       * to the end of this list, in the order that they are
       * returned by the specified Collection's Iterator.
       */
      public boolean addAll(Collection c);
  
  
      /**
       * Returns the element at the specified position in this list.
       */
      public Object get(int index);
  
  
      /**
       * Populate matching properties on given object,
       * using bean at given index. Returns false if index>size.
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelException on any error.
       */
      public boolean populate(Object o, int index) throws ModelException;
  
  }
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelResultBase.java
  
  Index: ModelResultBase.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * Concrete implementation of ModelResult that can be
   * used "as-is" to manage a collection of beans
   * returned from the resource layer.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelResultBase implements ModelResult {
  
  
  // ----------------------------------------------------------- Properties
  
  
      /**
       * The Message List.
       */
      protected ArrayList messages = null;
  
  
      /**
       * Instantiate messages if it does not already exist.
       */
      protected boolean isMessages() {
          if (this.messages==null) this.messages = new ArrayList();
          return (this.messages!=null);
      }
  
  
      /**
       * Add a message to the List.
       */
      public boolean addMessage(String message) {
          if (isMessages())
              return messages.add(message);
          return false;
      }
  
  
      /**
       * Return the messages.
       */
      public List getMessages() {
          return (List) this.messages;
      }
  
  
      /**
       * The search description as a phrase,
       * ie: column = key
       */
      private String description = null;
  
  
      /**
       * Return the description.
       * @return the description
       */
      public String getDescription() {
          return (this.description);
      }
  
  
      /**
       * Set the description.
       * @param description The new description
       */
      public void setDescription(String description) {
          this.description = description;
      }
  
  
      /**
       * Set the description as "column = key".
       * @param description1 The attribute description
       * @param description2 The value description
       */
      public void setDescription(String key, String column) {
          if ((key==null) || ("".equals(key))) {
              this.description = column + PARAM_EQUALS + PARAM_ANY;
          }
          else {
              this.description = column + PARAM_EQUALS + key;
          }
      }
  
  
      /**
       * The result list.
       */
      protected ArrayList result = null;
  
  
      /**
       * Instantiate result if it does not already exist.
       */
      protected boolean isResult() {
          if (this.result==null) this.result = new ArrayList();
          return (this.result!=null);
      }
  
  
  // ----------------------------------------------------------- Public Methods
  
  
      /**
       * Return the number of elements on the List.
       * @return the size of the List
       */
      public int size() {
          if (isResult())
              return result.size();
          return 0;
      }
  
  
      /**
       * Accessor for <code>size()</code>.
       * @return the size of the List
       */
      public int getSize() {
          return size();
      }
  
  
      /**
       * Return an iterator for the List,
       * or null if there is no List.
       * @return an iterator for the List
       */
      public Iterator iterator() {
          if (isResult())
              return result.iterator();
          return null;
      }
  
  
      /**
       * Accessor for <code>iterator()</code>.
       * @return an iterator for the List
       */
      public Iterator getIterator() {
          return iterator();
      }
  
  
      /**
       * Appends the specified element to the end of the List.
       * @return the row count
       */
      public boolean add(Object o) {
          if (isResult())
              return result.add(o);
          return false;
      }
  
  
      /**
       * Appends all of the elements in the specified Collection
       * to the end of this list, in the order that they are
       * returned by the specified Collection's Iterator.
       */
      public boolean addAll(Collection c) {
          if (isResult())
              return result.addAll(c);
          return false;
      }
  
  
      /**
       * Returns the element at the specified position in this list.
       */
      public Object get(int index) {
          if (isResult())
              return result.get(index);
          return null;
      }
  
  
      /**
       * Populate matching properties on given object,
       * using bean at given index. Returns false if index>size.
       * <code>BeanUtils.describe</code>.
       * @exception Throws ModelException on any error.
       */
      public boolean populate(Object o, int index) throws ModelException {
          Object bean = null;
          if (size()>index)
              bean = get(index);
          if (bean==null) return false;
          try {
              BeanUtils.populate(o,BeanUtils.describe(bean));
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
          }
          return true;
      }
  
  
  // ----------------------------------------------------------- Constructors
  
  
      /**
       * Default constructor.
       */
      public ModelResultBase() {
          super();
      }
  
  
      /**
       * Convenience constructor to populate result with a ModelBean.
       */
      public ModelResultBase(Object o) {
          super();
          add(o);
      }
  
  
      /**
       * Convenience constructor to populate result with a Collection
       * (e.g. of ModelBeans).
       */
      public ModelResultBase(Collection c) {
          super();
          addAll(c);
      }
  
  }
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/model/ModelUtils.java
  
  Index: ModelUtils.java
  ===================================================================
  package org.apache.scaffold.model;
  
  
  import org.apache.struts.util.BeanUtils;
  
  
  /**
   * Convenience method for transfering data to model beans
   * if not based on QuerBean or ModelBeanBase.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ModelUtils {
  
  // --------------------------------------------------- Instance Variables
  // ----------------------------------------------------------- Properties
  // --------------------------------------------------------- Public Methods
  
  
      /**
       * Populate the JavaBeans properties of the target bean,
       * based on the public accessors of the source bean.
       * @exception Throws ModelException on any error.
       */
      public static void populate(Object target, Object source) throws ModelException {
          try {
              BeanUtils.populate(target,BeanUtils.describe(source));
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
        }
      }
  
  
  
  // ----- end ModelUtils -----
  
  }
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/search/LuceneUtils.java
  
  Index: LuceneUtils.java
  ===================================================================
  package org.apache.scaffold.search;
  
  
  import java.lang.reflect.InvocationTargetException;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Enumeration;
  import java.util.HashMap;
  import java.util.Map;
  
  import com.lucene.document.Document;
  import com.lucene.document.Field;
  import com.lucene.search.Hits;
  
  import org.apache.struts.util.BeanUtils;
  // import org.apache.commons.beanutil.BeanUtils;
  
  import org.apache.scaffold.model.ModelException;
  import org.apache.scaffold.model.ModelPopulateException;
  
  
  /**
   * General purpose utility methods related to Hits
   *
   * @author Craig R. McClanahan
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
   public class LuceneUtils {
  
      /**
       * Populate the properties of the specified JavaBean from the specified
       * Lucene document, based on matching each parameter name against the
       * corresponding JavaBeans "property setter" methods in the bean's class.
       * Suitable conversion is done for argument types as described under
       * <code>setProperties()</code>.
       * <p>
       *
       * @param bean The JavaBean whose properties are to be set
       * @param document The Lucene document whose parameters are to be used
       *                to populate bean properties
       *
       * @exception ModelMapException if an exception is thrown while setting
       *            property values
       */
      public static void populate(Object bean, Document document)
          throws ModelException {
  
          // Build a list of relevant fields and values
          HashMap properties = new HashMap();
  
          // Iterator of field names
          Enumeration fields = document.fields();
  
          while (fields.hasMoreElements()) {
              Field field = (Field) fields.nextElement();
              properties.put(field.name(),field.stringValue());
          }
  
          // Set the corresponding properties of our bean
          try {
              BeanUtils.populate(bean, properties);
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
          }
  
      }
  
  
     /**
       * Return a ArrayList of hits by looping and calling populate.
       * No assumptions are made about fields in document. Each is
       * processed with a separate call to populate. Whatever fields
       * in each document that match the target bean will be
       * transferred.
       *
       * @param hits The Hits whose documents are to be used
       * to populate bean properties
       * @param target An instance of the bean to populate
       *
       * @exception ModelMapException if an exception is thrown while setting
       * property values, populating the bean, or accessing the Hits
       */
       public static Collection getCollection(Object target, Hits hits)
          throws ModelException {
  
          // Use ArrayList to maintain sequence
          ArrayList list = new ArrayList();
  
          // Acquire target class
          Class factory = target.getClass();
  
          try {
              // Scroll to each document; populate bean, and add to list
              for (int i=0; i<hits.length(); ++i) {
                  Object bean = factory.newInstance();
                  Document doc = hits.doc(i);
                  populate(bean,doc);
                  list.add(bean);
              }
          } catch (Throwable t) {
              throw new ModelPopulateException(t);
          }
          return ((Collection) list);
      }
  }
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/sql/ConnectionPool.java
  
  Index: ConnectionPool.java
  ===================================================================
  package org.apache.scaffold.sql;
  
  
  /**
   * Starter class to access a datasource connection pool.
   * :TODO: At some point, this will have to be refactored
   * so that another class using a different implemenation
   * could be loaded here instead.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  
  import java.sql.Connection;
  import java.sql.SQLException;
  import javax.sql.DataSource;
  
  import com.codestudio.sql.PoolMan;
  
  
  public final class ConnectionPool {
  
  
      /**
       * An exception message to throw if datasource is null.
       */
      public static final String RESOURCE_ERROR = "Connection pool " +
          "not available. Check your poolman.xml config, and be sure " +
          "you are using a valid dbname parameter (use dbname, not jndiName)";
  
  
      /**
       * The application scope attribute under which our datasource
       * is stored.
       */
      public static final String RESOURCE_KEY = "DATASOURCE";
  
  
      /**
       * Returns a JDBC connection from a connection pool or other
       * resource, to be used and closed promptly.
       * <p>
       * @returns JDBC connection from resource layer.
       * @exception SQLException on SQL or other errors. May wrap other
       * exceptions depending on implementation. Will not return null.
       */
      public static final Connection getConnection() throws SQLException {
          return getConnection(RESOURCE_KEY);
      }
  
  
      /**
       * Returns a JDBC connection from a connection pool or other
       * resource, to be used and closed promptly.
       * <p>
       * @returns JDBC connection from resource layer.
       * @exception SQLException on SQL or other errors. May wrap other
       * exceptions depending on implementation. Will not return null.
       */
      public static final Connection getConnection(String resource) throws SQLException {
          DataSource ds = null;
          if (resource==null)
              ds = PoolMan.findDataSource(RESOURCE_KEY);
          else
              ds = PoolMan.findDataSource(resource);
          if (ds==null)
              throw new SQLException(RESOURCE_ERROR);
          return(ds.getConnection());
      }
  }
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/sql/ResultSetUtils.java
  
  Index: ResultSetUtils.java
  ===================================================================
  package org.apache.scaffold.sql;
  
  
  import java.beans.PropertyDescriptor;
  
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.SQLException;
  import java.sql.Types;
  
  import java.sql.Date;
  import java.sql.Time;
  import java.sql.Timestamp;
  
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.struts.util.BeanUtils;
  // import org.apache.commons.beanutil.BeanUtils;
  import org.apache.struts.util.PropertyUtils;
  // import org.apache.commons.beanutil.PropertyUtils;
  
  
  /**
   * General purpose utility methods related to ResultSets
   * <p>
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
   public class ResultSetUtils {
  
      /**
       * Populate the JavaBean properties of the specified bean, based on
       * the specified name/value pairs.  This method uses Java reflection APIs
       * to identify corresponding "property setter" method names. The type of
       * the value in the Map must match the setter type. The setter must
       * expect a single arguement (the one on the Map).
       * <p>
       * The particular setter method to be called for each property is
       * determined using the usual JavaBeans introspection mechanisms. Thus,
       * you may identify custom setter methods using a BeanInfo class that is
       * associated with the class of the bean itself. If no such BeanInfo
       * class is available, the standard method name conversion ("set" plus
       * the capitalized name of the property in question) is used.
       * <p>
       * <strong>NOTE</strong>:  It is contrary to the JavaBeans Specification
       * to have more than one setter method (with different argument
       * signatures) for the same property.
       * <p>
       * This method adopted from the Jakarta Commons BeanUtils.populate.
       * @author Craig R. McClanahan
       * @author Ralph Schaer
       * @author Chris Audley
       * @author Rey Fran�ois
       * @author Gregor Ra�man
       * @author Ted Husted
       *
       * @param bean JavaBean whose properties are being populated
       * @param properties Map keyed by property name, with the
       *  corresponding value to be set
       *
       * @exception IllegalAccessException if the caller does not have
       *  access to the property accessor method
       * @exception InvocationTargetException if the property accessor method
       *  throws an exception
       */
      public static void setProperties(Object bean, Map properties)
          throws IllegalAccessException, InvocationTargetException {
  
          if ((bean == null) || (properties == null))
              return;
  
          /*
          if (debug >= 1)
              System.out.println("BeanUtils.populate(" + bean + ", " +
                                 properties + ")");
          */
  
          // Loop through the property name/value pairs to be set
          Iterator names = properties.keySet().iterator();
          while (names.hasNext()) {
  
              // Identify the property name and value(s) to be assigned
              String name = (String) names.next();
              if (name == null)
                  continue;
  
              // Get the property descriptor of the requested property (if any)
              PropertyDescriptor descriptor = null;
              try {
                  descriptor = PropertyUtils.getPropertyDescriptor(bean, name);
              } catch (Throwable t) {
                  /*
                  if (debug >= 1)
                      System.out.println("    getPropertyDescriptor: " + t);
                  */
                  descriptor = null;
              }
              if (descriptor == null) {
                  /*
                  if (debug >= 1)
                      System.out.println("    No such property, skipping");
                  */
                  continue;
              }
  
              /*
              if (debug >= 1)
                  System.out.println("    Property descriptor is '" +
                                     descriptor + "'");
              */
  
              // Identify the relevant setter method (if there is one)
              Method setter = descriptor.getWriteMethod();
              if (setter == null) {
                  /*
                  if (debug >= 1)
                      System.out.println("    No setter method, skipping");
                  */
                  continue;
              }
  
              // Obtain value to be set
              Object[] args = new Object[1];
              args[0] = properties.get(name); // This MUST match setter type
  
              /*
              if (debug >= 1)
                  System.out.println("  name='" + name + "', value.class='" +
                                     (value == null ? "NONE" :
                                     value.getClass().getName()) + "'");
              */
              /*
              if (debug >= 1)
                  System.out.println("    Setting to " +
                                     (parameters[0] == null ? "NULL" :
                                      "'" + parameters[0] + "'"));
              */
  
              // Invoke the setter method
              setter.invoke(bean,args);
          }
  
          /*
          if (debug >= 1)
              System.out.println("============================================");
          */
  
      }
  
  
      /**
       * Return a ArrayList of beans populated form a ResultSet.
       * @param resultSet The ResultSet whose parameters are to be used
       * to populate bean properties
       * @param target An instance of the bean to populate
       * @exception SQLException if an exception is thrown while setting
       * property values, populating the bean, or accessing the ResultSet
       */
       public static Collection getCollection(Object target, ResultSet resultSet)
          throws SQLException {
  
          // Check prerequisites
          if ((target==null) || (resultSet==null))
              throw new SQLException("getCollection: Null parameter");
  
          // Acquire resultSet MetaData
          ResultSetMetaData metaData = resultSet.getMetaData();
          int cols = metaData.getColumnCount();
  
          // Create hashmap, sized to number of columns
          HashMap properties = new HashMap(cols,1);
  
          // Use ArrayList to maintain ResultSet sequence
          ArrayList list = new ArrayList();
  
          // Acquire target class
          Class factory = target.getClass();
  
          // Scroll to next record and pump into hashmap
          while (resultSet.next()) {
              for (int i=1; i<=cols ; i++) {
                  String columnName = metaData.getColumnName(i);
                  switch (metaData.getColumnType(i)) {
                      // http://java.sun.com/j2se/1.3.0/docs/api/java/sql/Types.html
  
                      // Convert known types
  
                      case Types.BIGINT:
                          properties.put(columnName,
                              new Long(resultSet.getLong(i)));
                          break;
  
                      case Types.DATE:
                          properties.put(columnName,
                              resultSet.getDate(i));
                          break;
  
                      case Types.DECIMAL:
                      case Types.DOUBLE:
                          properties.put(columnName,
                              new Double(resultSet.getDouble(i)));
                          break;
  
                      case Types.FLOAT:
                          properties.put(columnName,
                              new Float(resultSet.getFloat(i)));
                          break;
  
                      case Types.INTEGER:
                          properties.put(columnName,
                              new Integer(resultSet.getInt(i)));
                          break;
  
                      case Types.REAL:
                          properties.put(columnName,
                              new Double(resultSet.getString(i)));
                          break;
  
                      case Types.SMALLINT:
                          properties.put(columnName,
                              new Short(resultSet.getShort(i)));
                          break;
  
                      case Types.TIME:
                          properties.put(columnName,
                              resultSet.getTime(i));
                          break;
  
                      case Types.TIMESTAMP:
                          properties.put(columnName,
                              resultSet.getTimestamp(i));
                          break;
  
  // :FIXME: Throws java.lang.ClassCastException: java.lang.Integer
  // :FIXME: with Poolman and MySQL unless uses getString.
                      case Types.TINYINT:
                          properties.put(columnName,
                              new Byte(resultSet.getString(i)));
                          break;
  
                      case Types.CHAR:
                      case Types.CLOB:
                      case Types.VARCHAR:
                      case Types.LONGVARCHAR:
                          // :FIXME: Handle binaries differently?
                      case Types.BLOB:
                      case Types.LONGVARBINARY:
                      case Types.VARBINARY:
                          properties.put(columnName,
                              resultSet.getString(i));
                          break;
  
  /*
  :FIXME: Add handlers for
  ARRAY
  BINARY
  BIT
  DECIMAL
  DISTINCT
  JAVA_OBJECT
  NULL
  NUMERIC
  OTHER
  REF
  STRUCT
  
  */
                       // Otherwise, pass as *String property to be converted
                      default:
                          properties.put(columnName + "String",
                              resultSet.getString(i));
                          break;
                  }
              }
  
              try {
                  Object bean = factory.newInstance();
                  setProperties(bean,properties);
                  list.add(bean);
              }
              catch (Exception e) {
                  throw new SQLException("RequestUtils.getCollection: " +
                      e.getMessage());
              }
  
              properties.clear();
  
          } // end while
  
          return ((Collection) list);
       }
  
      /**
       * Return a ArrayList of beans populated form a ResultSet,
       * transferring all properties as Strings.
       * If resultSet is empty, then an empty list will be returned.
       * If properties of target and resultSet do not match, a list of
       * blank target beans will be returned.
       * Otherwise, a list of target beans populated from matching
       * properties (columns) in resultSet will be returned.
       * @param resultSet The ResultSet whose parameters are to be used
       * to populate bean properties
       * @param target An instance of the bean to populate
       * @exception SQLException if an exception is thrown while setting
       * property values, populating the bean, or accessing the ResultSet
       */
       public static Collection getCollectionString(Object target, ResultSet resultSet)
          throws SQLException {
  
          // Acquire resultSet MetaData
          ResultSetMetaData metaData = resultSet.getMetaData();
          int cols = metaData.getColumnCount();
  
          // Create hashmap, sized to number of columns
          HashMap properties = new HashMap(cols,1);
  
          // Use ArrayList to maintain ResultSet sequence
          ArrayList list = new ArrayList();
  
          // Acquire target class
          Class factory = target.getClass();
  
          // Scroll to next record and pump into hashmap
          while (resultSet.next()) {
              for (int i=1; i<=cols ; i++) {
                  properties.put(metaData.getColumnName(i),
                      resultSet.getString(i));
              }
              try {
                  Object bean = factory.newInstance();
                  BeanUtils.populate(bean,properties);
                  list.add(bean);
              }
              catch (Exception e) {
                  throw new SQLException("RequestUtils.getCollectionString: " +
                      e.getMessage());
              }
              properties.clear();
          } // end while
  
          return ((Collection) list);
       }
  }
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/sql/StatementUtils.java
  
  Index: StatementUtils.java
  ===================================================================
  package org.apache.scaffold.sql;
  
  
  import java.sql.Connection;
  import java.sql.SQLException;
  import java.sql.PreparedStatement;
  import java.sql.Statement;
  import java.sql.ResultSet;
  
  import java.util.Collection;
  
  
  /**
   * General purpose SQL Statements.
   * :FIXME: getCollection returns blank string exceptions when used with multiple parameters (single OK).
   * :TODO: Refactor executeUpdate methods like getCollection methods.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public final class StatementUtils {
  
  
      /**
       * Prepares statement using SQL statement and executes
       * with DBMS configured with the ConnectionPool.
       * <p>
       * Command may be an INSERT, UPDATE, or DELETE statement
       * or anything that returns nothing, such as a DDL
       * statement.
       * <p>
       * @param command The SQL statement to execute.
       * @exception SQLException if SQL error occurs
       */
      public static final int executeUpdate(String resource, String command)
          throws SQLException {
  
          Connection connection = null;
          Statement statement = null;
          int result = 0;
          try {
              connection = ConnectionPool.getConnection(resource);
              statement = connection.createStatement();
              result = statement.executeUpdate(command);
          } // end try
  
          finally {
              try {
                  if (statement != null)
                      statement.close();
                  if (connection!= null)
                      connection.close();
              }
              catch (SQLException sqle) {
                  // non-fatal; only closing if pooled.
                  // don't overthrow original exception
              }
          }
          return result;
  
      } // ---- End executeUpdate ----
  
  
      /**
       * Prepares statement using SQL statement and executes
       * with DBMS configured with the ConnectionPool.
       * <p>
       * Command may be an INSERT, UPDATE, or DELETE statement
       * or anything that returns nothing, such as a DDL
       * statement.
       * @param resource The database resource, or null for default
       * @param command The SQL statement to execute.
       * @param key The parameter
       * @exception SQLException if SQL error occurs
       */
      public static final int executeUpdate(String resource,
              String command, String key)
          throws SQLException {
  
          Connection connection = null;
          PreparedStatement statement = null;
          int result = 0;
          try {
              connection = ConnectionPool.getConnection(resource);
              statement = connection.prepareStatement(command);
              if (key!=null)
                  statement.setString(1, key);
              result = statement.executeUpdate();
          } // end try
  
          finally {
              try {
                  if (statement != null)
                      statement.close();
                  if (connection!= null)
                      connection.close();
              }
              catch (SQLException sqle) {
                  // non-fatal; only closing if pooled.
                  // don't overthrow original exception
              }
          }
          return result;
  
      } // ---- End executeUpdate ----
  
  
      /**
       * Prepares statement using SQL statement and executes
       * with DBMS configured with the ConnectionPool.
       * <p>
       * Command may be an INSERT, UPDATE, or DELETE statement
       * or anything that returns nothing, such as a DDL
       * statement.
       * @param resource The database resource, or null for default
       * @param command The SQL statement to execute.
       * @param key The parameter
       * @exception SQLException if SQL error occurs
       */
      public static final int executeUpdate(String resource,
              String command, Integer key)
          throws SQLException {
  
          Connection connection = null;
          PreparedStatement statement = null;
          int result = 0;
          try {
              connection = ConnectionPool.getConnection(resource);
              statement = connection.prepareStatement(command);
              if (key!=null)
                  statement.setInt(1, key.intValue());
              result = statement.executeUpdate();
          } // end try
  
          finally {
              try {
                  if (statement != null)
                      statement.close();
                  if (connection!= null)
                      connection.close();
              }
              catch (SQLException sqle) {
                  // non-fatal; only closing if pooled.
                  // don't overthrow original exception
              }
          }
          return result;
  
      } // ---- End executeUpdate ----
  
  
  
      /**
       * Prepares statement using SQL statement and executes
       * with DBMS configured with the ConnectionPool.
       * <p>
       * Command may be an INSERT, UPDATE, or DELETE statement
       * or anything that returns nothing, such as a DDL
       * statement.
       * @param resource The database resource, or null for default
       * @param command The SQL statement to execute.
       * @param parameters An array of parameter objects
       * @exception SQLException if SQL error occurs
       */
      public static final int executeUpdate(String resource,
              String command, Object[] parameters)
          throws SQLException {
  
          Connection connection = null;
          PreparedStatement statement = null;
          int result = 0;
          try {
              connection = ConnectionPool.getConnection(resource);
              statement = connection.prepareStatement(command);
              for (int i=0; i<parameters.length; i++) {
                  statement.setObject(i, parameters[i]);
              }
              result = statement.executeUpdate();
          } // end try
  
          finally {
              try {
                  if (statement != null)
                      statement.close();
                  if (connection!= null)
                      connection.close();
              }
              catch (SQLException sqle) {
                  // non-fatal; only closing if pooled.
                  // don't overthrow original exception
              }
          }
          return result;
  
      } // ---- End executeUpdate ----
  
  
      /**
       * Create a new database table in an existing database,
       * by sending "CREATE TABLE " and the parameters to
       * the DBMS configured with the ConnectionPool.
       * <p>
       * For safety, does <b>not</b> drop table first.
       * <p>
       * Returns false if a SQL exception is thrown; exception
       * is written to the servlet log.
       * <p>
       * @param tableName The name of the table to create
       * @param tableCreate The SQL command defining the
       * fields and indices
       * @return Result of statement.execute()
       * @exception SQL Exception if SQL error occurs
       */
      public static final int createTable(
              String resource, String tableName, String tableCreate)
              throws SQLException {
  
          return executeUpdate(resource,"CREATE TABLE " +
              tableName + " " + tableCreate);
  
      } // ---- End createTable ----
  
  
      /**
       * Prepares the given statement using key, and executes
       * it with DBMS configured with the ConnectionPool to return
       * a ResultSet. The ResultSet is transferred to a Collection
       * using the getCollection() method of the Object object.
       * The ResultSet is released, and the Collection returned.
       * <p>
       * @param key The replaceable parameter, if any.
       * @param command The SQL statement to prepare and execute.
       * @param target The Object class to create collection from ResultSet
       * @exception SQLException if SQL error occurs
       */
       public static final Collection getCollection(String resource,
                  Object target, String command, Object[] parameters)
                  throws SQLException {
              Object collection = null;
              Connection connection = null;
              Statement statement = null;
              PreparedStatement preparedStatement = null;
              ResultSet resultSet = null;
              try {
                  connection = ConnectionPool.getConnection(resource);
  
                  if ((parameters==null) || (parameters.length==0)) {
                      statement = connection.createStatement();
                      resultSet = statement.executeQuery(command);
                  }
                  else {
                      preparedStatement = connection.prepareStatement(command);
                      for (int i=0; i<parameters.length; i++) {
                          preparedStatement.setObject(i+1, parameters[i]);
                      }
                      resultSet = preparedStatement.executeQuery();
                  }
  
                  // ** Transfer ResultSet to Collection of target beans **
                  // Worst case, will return an empty list
                  collection = ResultSetUtils.getCollection(
                      target,resultSet);
              }
              finally {
                  try {
                      if (resultSet != null) resultSet.close();
                      if (statement != null) statement.close();
                      if (connection!= null) connection.close();
                  }
                  catch (SQLException sqle) {}
              }
  
              return (Collection) collection;
  
          } // ---- End getCollection ----
  
  
       public static final Collection getCollection(String resource,
                  Object target, String command, Object key)
              throws SQLException {
          Object[] parameters = new Object[1];
          parameters[0] = key;
          return getCollection(resource,target,command,parameters);
       }
  
  
       public static final Collection getCollection(String resource,
                  Object target, String command, int key)
              throws SQLException {
          Object[] parameters = new Object[1];
          parameters[0] = new Integer(key);
          return getCollection(resource,target,command,parameters);
       }
  
  
       public static final Collection getCollection(String resource,
                  Object target, String command) throws SQLException {
              return getCollection(resource,target,command,null);
       }
  
  
      /**
       * Variation of <code>getCollection()</code> for commands
       * that use LIKE operator.
       * @param key The replaceable parameter to use with LIKE.
       * @param command The SQL statement to prepare and execute.
       * @param target The ResultList class to create list from ResultSet
       * @exception SQLException if SQL error occurs
       * @see getResultList
       */
       public static final Collection getCollectionLike(String resource,
                  Object target, String command, String key) throws SQLException {
              Object[] parameters = new Object[1];
              parameters[0] = new String("%" + key + "%");
              return getCollection(resource,target,command,parameters);
       }
  
  
  } // ---- End StatementUtils ---
  
  
  
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/text/ConvertUtils.java
  
  Index: ConvertUtils.java
  ===================================================================
  package org.apache.scaffold.text;
  
  
  import java.text.DateFormat;
  import java.text.DecimalFormat;
  import java.text.DecimalFormatSymbols;
  import java.text.NumberFormat;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  
  import java.util.Date;
  import java.util.Locale;
  
  import java.sql.Timestamp;
  
  
  /**
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
  public class ConvertUtils {
  
  /*
      protected Locale[] availableLocales = null;
      public static Locale[] getAvailableLocales() {
          return availableLocales;
      }
      public static void setAvailableLocales(Locale[] _availableLocales) {
          availableLocales = _availableLocales;
      }
  
  */
  
      /**
       * An empty string.
       */
      public static String EMPTY_STRING = "";
  
  
      /**
       * Returns true if null or trims to an empty string.
       */
      public static boolean isBlank(String s) {
          return ((s==null) || (s.trim().equals(EMPTY_STRING)));
      }
  
  
      /**
       * Return String with of digits only (0..9).
       * http://java.sun.com/j2se/1.4/docs/api/java/lang/Character.html
       */
      public static String getDigits(String s) {
          if (s==null) return null;
          int n = s.length();
          StringBuffer sb = new StringBuffer(n);
          for (int i = 0; i < n; i++) {
              char c = s.charAt(i);
              if (Character.isDigit(c)) sb.append(c);
          }
          return (sb.toString());
      }
  
      /**
       */
      public static String getNumber(Number value, Locale locale) {
          if (locale==null)
              return (NumberFormat.getInstance().format(value));
         return (NumberFormat.getInstance(locale).format(value));
      }
  
      /**
       */
      public static String getDecimal(Number value, Locale locale) {
          if (locale==null)
              return (DecimalFormat.getInstance().format(value));
          return (DecimalFormat.getInstance().format(value));
      }
  
      /**
       */
      public static String getPercent(Number value, Locale locale) {
          if (locale==null)
              return (NumberFormat.getPercentInstance().format(value));
          return (NumberFormat.getPercentInstance(locale).format(value));
      }
  
  
      /*
      public static String getInteger(Number value, Locale locale) {
          if (locale==null)
              return (NumberFormat.getIntegerInstance().format(value));
          return (NumberFormat.getIntegerInstance(locale).format(value));
      }
      */
  
  
      /**
       */
      public static DecimalFormatSymbols getGenericDecimal(Locale locale) {
          DecimalFormatSymbols symbols =
              new DecimalFormatSymbols(locale);
          symbols.setGroupingSeparator('`'); // :FIXME: Want apostrophe here
          return symbols;
      }
  
      /**
       * http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html
       */
      public static String DECIMAL_PATTERN ="###,###.###";
  
      /**
       * http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html
       */
      public static String CURRENCY_PATTERN ="$" + DECIMAL_PATTERN;
  
  
      /**
       */
      public static String getDecimal(Number value, Locale locale, String pattern) {
          NumberFormat formatter;
          if (locale==null)
              formatter = new java.text.DecimalFormat(pattern);
          else {
              formatter = NumberFormat.getNumberInstance(locale);
              DecimalFormat df = (DecimalFormat) formatter;
              df.applyPattern(pattern);
              return df.format(value);
          }
          return (formatter.format(value));
      }
  
  
      /**
       */
      public static String getDecimal(Number value) {
          return getDecimal(value,(Locale) null,DECIMAL_PATTERN);
      }
  
  
      /**
       */
      public static String getCurrency(Number value) {
          return getDecimal(value,null,CURRENCY_PATTERN);
      }
  
  
      /**
       * Convert String to Date using given format.
       * Returns null if conversion fails.
       * Set lenient=false to disallow dates like 2001-9-32.
       * http://java.sun.com/j2se/1.4/docs/api/java/text/SimpleDateFormat.html
       * @author Hal Deadman
       */
      public static Date getDate(String dateText,
              String format, boolean lenient) {
          if (dateText == null) {
              return null;
          }
          try {
              DateFormat df = new SimpleDateFormat(format);
                  // setLenient avoids allowing dates like 9/32/2001
                  // which would otherwise parse to 10/2/2001
              df.setLenient(false);
              return df.parse(dateText);
          }
          catch(ParseException e) {
              return null;
          }
      }
  
  
      /**
       * Default lenient setting for getDate.
       */
      private static boolean LENIENT_DATE = false;
  
  
      /**
       * Convert String to Date using given format.
       * Returns null if conversion fails.
       * Uses "strict" coNversion (lenient=false).
       * @author Hal Deadman
       */
      public static Date getDate(String dateString, String format) {
          return getDate(dateString,format,LENIENT_DATE);
      }
  
  
      /**
       * A "default" date format.
       */
      public static String DEFAULT_DATE_PATTERN = "d-MMM-yy";
  
  
      /**
       * Convert String to Date using a medium (weekday day month year) format.
       * Returns null if conversion fails.
       * Uses "strict" coNversion (lenient=false).
       * @author Hal Deadman
       */
      public static Date getDate(String dateString) {
          return getDate(dateString,DEFAULT_DATE_PATTERN,LENIENT_DATE);
      }
  
  
      /**
       * Default style for dates and times.
       */
      public static int DEFAULT = DateFormat.DEFAULT;
  
      /**
       * Short style for dates and times.
       */
      public static int SHORT = DateFormat.SHORT;
  
      /**
       * Medium style for dates and times.
       */
      public static int MEDIUM = DateFormat.MEDIUM;
  
      /**
       * Long style for dates and times.
       */
      public static int LONG = DateFormat.LONG;
  
      /**
       * Full style for dates and times.
       */
      public static int FULL = DateFormat.FULL;
  
  /*
            dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT,
                                                       currentLocale);
            today = new Date();
            dateOut = dateFormatter.format(today);
  */
  
      /**
       * Convert date to String for given locale in given style.
       * A null locale will return the default locale.
       */
      public static String getDate(Date date, Locale locale, int style) {
          if (locale==null)
              return (DateFormat.getDateInstance(style).format(date));
          return (DateFormat.getDateInstance(style,locale).format(date));
     }
  
  
      /**
       * Convert date to String for default locale in given style.
       * A null locale will return the default locale.
       */
      public static String getDate(Date date, int style) {
         return getDate(date,(Locale) null,style);
      }
  
      /**
       * Convert date to String for default locale in DEFAULT style.
       * A null locale will return the default locale.
       */
      public static String getDate(Date date) {
         return getDate(date,(Locale) null,DEFAULT);
     }
  
      /**
       * Convert timestamp to String for given locale in given style.
       * A null locale will return the default locale.
       */
      public static String getTimestamp(Timestamp timestamp, Locale locale, int style) {
          Date date = (Date) timestamp;
          if (locale==null)
              return (DateFormat.getDateTimeInstance(style,style).format(date));
          return (DateFormat.getDateTimeInstance(style,style,locale).format(date));
     }
  
      /**
       * Convert date to String for default locale in given style.
       * A null locale will return the default locale.
       */
      public static String getTimestamp(Timestamp timestamp, int style) {
         return getTimestamp(timestamp,(Locale) null,style);
      }
  
      /**
       * Convert date to String for default locale in DEFAULT style.
       * A null locale will return the default locale.
       */
      public static String getTimestamp(Timestamp timestamp) {
         return getTimestamp(timestamp,(Locale) null,DEFAULT);
     }
  
  
      /**
       * Return Timestamp value using a String.
       * Null or conversion error returns null.
       * @param String representing Timestamp
       */
      public static Timestamp toTimestamp(String string) {
          if (string==null)
              return null;
          else try {
              return Timestamp.valueOf(string);
          } catch (Throwable t) {
              return null;
          }
      }
  
  
      /**
       * Return String value representing Timestamp.
       * Null returns null.
       * @param Timestamp
       */
      public static String toString(Timestamp timestamp) {
          if (timestamp==null)
              return null;
          else
              return timestamp.toString();
      }
  
  
      /**
       * Return Date value using a String.
       * Null or conversion error returns null.
       * @param String representing Date
       */
      public static Date toDate(String string) {
          if (string==null)
              return null;
          else try {
              return getDate(string);
          } catch (Throwable t) {
              return null;
          }
      }
  
  
      /**
       * Return String value representing Date.
       * Null returns null.
       * @param Date
       */
      public static String toString(Date date) {
          if (date==null)
              return null;
          else
              return getDate(date);
      }
  
  }
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/text/Merge.java
  
  Index: Merge.java
  ===================================================================
  package org.apache.scaffold.text;
  
  
  import java.util.Map;
  
  
  /**
   * Merge utilities.
   * @author Ted Husted
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:12 $
   */
   public class Merge {
  
  
      /**
       * The token markers for replacement variables, i.e. ${a1}
       */
      public static String TOKEN_PREFIX= "${";
      public static String TOKEN_SUFFIX = "}";
      private static int TOKEN_PREFIX_LEN = TOKEN_PREFIX.length();
      private static int TOKEN_SUFFIX_LEN = TOKEN_SUFFIX.length();
  
  
      /**
       * Merge a Map of tokens with a template in a StringBuffer.
       * The parameters are marked by ${key} where (String) Map.get(key)!=null.
       * The merged content is returned in the same StringBuffer.
       * Tokens cannot be nested. Unmatched tokens are ignored.
       * @param content The text containing merge tokens to be replaced.
       *
       * @returns int Number of replacements made
       */
      public static int keys(StringBuffer content, Map tokens) {
  
          String t = content.toString();
          int start = t.length();
          int count = 0;
  
          while ((start = t.lastIndexOf(TOKEN_PREFIX,start-1)) != -1) {
  
              int end = t.indexOf(TOKEN_SUFFIX,start);
              String key = t.substring(start+TOKEN_PREFIX_LEN,end);
              String value = (String) tokens.get(key);
              if (value!=null) {
                  content.replace(start,end+TOKEN_SUFFIX_LEN,value);
                  count++;
              }
          }
          return count;
      }
    }
  
    /*
  
  
    <forward name="bookmark" path = "/do/item/View?key=${key}"/>
  
    form implements Bookmark;
  
    forward = findForward("bookmark");
  
    if (forward!=null) {
  
    StringBuffer bmPath = new StringBuffer( forward.getPath() );
  
    merge(bmPath,describe(form));
  
    Bookmark bmForm = (Bookmark) form;
    bmForm.setBookmark(bookmark.toString());
  
    }
  
    ...
  
    if (isBookmark())
      return getBookmarkForward();
    return findForward("continue");
  
  
    */
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/text/Validator.java.text
  
  Index: Validator.java.text
  ===================================================================
  package org.apache.scaffold.text;
  
  import java.util.Locale;
  import java.io.Serializable;
  
  // import com.capco.mapper.parser.ValidationData;
  
  /**
   * Base class for all validators.
   * A validator is a class capable of validating the value of an array of objects.
   * This validation can be Locale sensitive.
   * As a convenience, this base class already contains properties for holding
   * a message and a message key that can be used for creating <CODE>ValidationFailure</CODE>s.
   * @author Fran�ois Rey
   */
  public abstract class Validator implements Serializable
  {
      public static final String EMPTY_STRING = "";
  
          /** Holds value of property message. */
      private String name = null;
  
          /** Holds value of property message. */
          private String message;
  
          /** Holds value of property messageKey. */
          private String messageKey;
  
      public Validator() {
          super();
      }
  
      public Validator(String name) {
          this();
          this.name = name;
      }
  
          /**
           * Utility method that returns true if the given string is blank (it is empty when trimmed).
           */
          public static final boolean isBlank(String value) {
              return (value!=null) && value.trim().length()==0;
          }
  
          /**
           * Utility method that returns true if the given string is empty (zero length string).
           */
          public static final boolean isEmptyString(String value) {
              return (value!=null) && value.length()==0;
          }
  
      /**
       * Validation method that all validators must implement.
       * @param objects The objects to validate. When this validator is called
       * the whole set of source objects defined in the mapping,this array
       * instance should be the same as the one contained in the
       * <code>ValidationData</code> instance passed as parameter.
       * @param locale The locale to use for the conversion. Same as the one in the
       * <code>ValidationData</code> instance given as parameter.
       * @param failures The collection of <code>ValidationFailure</code>s
       * to populate if the validation fails.
       * @return boolean The result of the validation (true if success, false otherwise).
       */
      public abstract boolean validate (Object[] objects, Locale locale);
  
          /** Setter for property name.
           * @param name New value of property name.
           */
          public void setName(String name) {
              this.name = name;
          }
  
          /** Getter for property name.
           * @return Value of property name.
           */
          public String getName() {
              return name;
          }
  
          /** Getter for property message.
           * @return Value of property message.
           */
          public String getMessage() {
              return message;
          }
  
          /** Setter for property message.
           * @param message New value of property message.
           */
          public void setMessage(String message) {
              this.message = message;
          }
  
          /** Getter for property messageKey.
           * @return Value of property messageKey.
           */
          public String getMessageKey() {
              return messageKey;
          }
  
          /** Setter for property messageKey.
           * @param messageKey New value of property messageKey.
           */
          public void setMessageKey(String messageKey) {
              this.messageKey = messageKey;
          }
  
  }
  
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/util/FunctionBean.java
  
  Index: FunctionBean.java
  ===================================================================
  package org.apache.scaffold.util;
  
  
  public class FunctionBean {
  
      /**
       * The count
       */
      private Integer count = null;
  
  
      /**
       * Return the count.
       * @return the count
       */
      public Integer getCount() {
          return (this.count);
      }
  
  
      /**
       * Set the count.
       * @param count The new count
       */
      public void setCount(Integer count) {
          this.count = count;
      }
  
  }
  
  
  1.1                  jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/util/LabelValueBean.java
  
  Index: LabelValueBean.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/contrib/scaffold/WEB-INF/src/java/org/apache/scaffold/util/LabelValueBean.java,v 1.1 2001/11/10 11:53:13 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2001/11/10 11:53:13 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.scaffold.util;
  
  
  /**
   * Simple JavaBean to represent label-value pairs for use in collections
   * that are utilized by the <code>&lt;form:options&gt;</code> tag.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2001/11/10 11:53:13 $
   */
  
  public class LabelValueBean {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new LabelValueBean with the specified values.
       *
       * @param label The label to be displayed to the user
       * @param value The value to be returned to the server
       */
      public LabelValueBean(String label, String value) {
          this.label = label;
          this.value = value;
      }
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * The label to be displayed to the user.
       */
      protected String label = null;
  
      public String getLabel() {
          return (this.label);
      }
  
  
      /**
       * The value to be returned to the server.
       */
      protected String value = null;
  
      public String getValue() {
          return (this.value);
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Return a string representation of this object.
       */
      public String toString() {
          StringBuffer sb = new StringBuffer("LabelValueBean[");
          sb.append(this.label);
          sb.append(", ");
          sb.append(this.value);
          sb.append("]");
          return (sb.toString());
      }
  
  
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>