commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-commons/beanutils/src/test/org/apache/commons/beanutils DynaResultSetTestCase.java TestResultSet.java TestResultSetMetaData.java
Date Fri, 12 Jul 2002 22:38:21 GMT
craigmcc    2002/07/12 15:38:21

  Modified:    beanutils build.xml
               beanutils/src/java/org/apache/commons/beanutils package.html
  Added:       beanutils/src/java/org/apache/commons/beanutils
                        ResultSetDynaClass.java ResultSetIterator.java
               beanutils/src/test/org/apache/commons/beanutils
                        DynaResultSetTestCase.java TestResultSet.java
                        TestResultSetMetaData.java
  Log:
  Initial checkin of a way to wrap DynaBean APIs around the rows in a
  java.sql.ResultSet, along with associated test cases and docco updates.
  FIXME - does not support indexed or mapped propeties.
  
  Revision  Changes    Path
  1.34      +19 -3     jakarta-commons/beanutils/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/build.xml,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- build.xml	29 Apr 2002 22:17:51 -0000	1.33
  +++ build.xml	12 Jul 2002 22:38:21 -0000	1.34
  @@ -80,7 +80,7 @@
     <property name="compile.debug"           value="true"/>
   
     <!-- Should Java compilations set the 'deprecation' compiler option? -->
  -  <property name="compile.deprecation"     value="true"/>
  +  <property name="compile.deprecation"     value="false"/>
   
     <!-- Should Java compilations set the 'optimize' compiler option? -->
     <property name="compile.optimize"        value="true"/>
  @@ -258,7 +258,8 @@
                                   test.dyna.bean,
                                   test.bean,
                                   test.convert,
  -                                test.method
  +                                test.method,
  +                                test.dyna.result
                                  "
      description="Run all unit test cases">
     </target>
  @@ -380,6 +381,21 @@
         <sysproperty key="org.apache.commons.logging.simplelog.defaultlog"
                    value="${test.level}"/>
         <arg value="org.apache.commons.beanutils.MethodUtilsTestCase"/>
  +      <classpath refid="test.classpath"/>
  +    </java>
  +  </target>
  +
  +  <target name="test.dyna.result" depends="compile.tests">
  +    <echo message="Running DynaBean ResultSet tests ..."/>
  +    <java classname="${test.runner}" fork="yes"
  +        failonerror="${test.failonerror}">
  +      <sysproperty key="org.apache.commons.logging.LogFactory"
  +                 value="${test.factory}"/>
  +      <sysproperty key="org.apache.commons.logging.Log"
  +                 value="${test.log}"/>
  +      <sysproperty key="org.apache.commons.logging.simplelog.defaultlog"
  +                 value="${test.level}"/>
  +      <arg value="org.apache.commons.beanutils.DynaResultSetTestCase"/>
         <classpath refid="test.classpath"/>
       </java>
     </target>
  
  
  
  1.8       +28 -0     jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/package.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- package.html	29 Apr 2002 21:37:47 -0000	1.7
  +++ package.html	12 Jul 2002 22:38:21 -0000	1.8
  @@ -27,6 +27,7 @@
       <ul>
       <li><a href="#dynamic.background">Background</a></li>
       <li><a href="#dynamic.basic">BasicDynaBean and BasicDynaClass</a></li>
  +    <li><a href="#dynamic.resultSet">ResultSetDynaClass (Wraps ResultSet in DynaBeans)</a></li>
       <li><a href="#dynamic.wrap">WrapDynaBean and WrapDynaClass</a></li>
       </ul></li>
   <li><a href="#conversion">Data Type Conversions</a>
  @@ -460,6 +461,33 @@
   will be interpreted as you expect -- the dynamic properties of the DynaBean
   will be retrieved or modified, instead of underlying properties on the
   actual BasicDynaBean implementation class.</p>
  +
  +<a name="dynamic.resultSet"></a>
  +<h3><code>ResultSetDynaClass</code> (Wraps ResultSet in DynaBeans)</h3>
  +
  +<p>A very common use case for DynaBean APIs is to wrap other collections of
  +"stuff" that do not normally present themselves as JavaBeans.  One of the most
  +common collections that would be nice to wrap is the
  +<code>java.sql.ResultSet</code> that is returned when you ask a JDBC driver
  +to perform a SQL SELECT statement.  Commons BeanUtils offers a standard
  +mechanism for making each row of the result set visible as a DynaBean,
  +which you can utilize as shown in this example:</p>
  +<pre>
  +  Connection conn = ...;
  +  Statement stmt = conn.createStatement();
  +  ResultSet rs = stmt.executeQuery
  +    ("select account_id, name from customers");
  +  ResultSetDynaClass rsdc = new ResultSetDynaClass(rs);
  +  Iterator rows = (new ResultSetDynaClass(rs)).iterator();
  +  while (rows.hasNext()) {
  +    DynaBean row = (DynaBean) rows.next();
  +    System.out.println("Account number is " +
  +                       row.get("account_id") +
  +                       " and name is " + row.get("name"));
  +  }
  +  rs.close();
  +  stmt.close();
  +</pre>
   
   <a name="dynamic.wrap"></a>
   <h3><code>WrapDynaBean</code> and <code>WrapDynaClass</code></h3>
  
  
  
  1.1                  jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetDynaClass.java
  
  Index: ResultSetDynaClass.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetDynaClass.java,v 1.1 2002/07/12 22:38:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/12 22:38:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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.commons.beanutils;
  
  
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.SQLException;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  
  
  /**
   * <p>Implementation of <code>DynaClass</code> for DynaBeans that wrap the
   * <code>java.sql.Row</code> objects of a <code>java.sql.ResultSet</code>.
   * The normal usage pattern is something like:</p>
   * <pre>
   *   ResultSet rs = ...;
   *   ResutSetDynaClass rsdc = new ResultSetDynaClass(rs);
   *   Iterator rows = rsdc.iterator();
   *   while (rows.hasNext())  {
   *     DynaBean row = (DynaBean) rows.next();
   *     ... process this row ...
   *   }
   *   rs.close();
   * </pre>
   *
   * <p>Each column in the result set will be represented as a DynaBean
   * property of the corresponding name (forced to lower case for portability).
   * </p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/12 22:38:21 $
   */
  
  public class ResultSetDynaClass implements DynaClass {
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * <p>Construct a new ResultSetDynaClass for the specified
       * <code>ResultSet</code>.</p>
       *
       * @param resultSet The result set to be wrapped
       *
       * @exception NullPointerException if <code>resultSet</code>
       *  is <code>false</code>
       * @exception SQLException if the metadata for this result set
       *  cannot be introspected
       */
      public ResultSetDynaClass(ResultSet resultSet) throws SQLException {
  
          if (resultSet == null) {
              throw new NullPointerException();
          }
          this.resultSet = resultSet;
          introspect();
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The set of dynamic properties that are part of this DynaClass.
       */
      protected DynaProperty properties[] = null;
  
  
      /**
       * The set of dynamic properties that are part of this DynaClass,
       * keyed by the property name.  Individual descriptor instances will
       * be the same instances as those in the <code>properties</code> list.
       */
      protected HashMap propertiesMap = new HashMap();
  
  
      /**
       * <p>The <code>ResultSet</code> we are wrapping.</p>
       */
      protected ResultSet resultSet = null;
  
  
  
      // ------------------------------------------------------ DynaClass Methods
  
  
  
      /**
       * Return the name of this DynaClass (analogous to the
       * <code>getName()</code> method of <code>java.lang.Class</code), which
       * allows the same <code>DynaClass</code> implementation class to support
       * different dynamic classes, with different sets of properties.
       */
      public String getName() {
  
          return (this.getClass().getName());
  
      }
  
  
      /**
       * Return a property descriptor for the specified property, if it exists;
       * otherwise, return <code>null</code>.
       *
       * @param name Name of the dynamic property for which a descriptor
       *  is requested
       *
       * @exception IllegalArgumentException if no property name is specified
       */
      public DynaProperty getDynaProperty(String name) {
  
          if (name == null) {
              throw new IllegalArgumentException
                      ("No property name specified");
          }
          return ((DynaProperty) propertiesMap.get(name));
  
      }
  
  
      /**
       * <p>Return an array of <code>ProperyDescriptors</code> for the properties
       * currently defined in this DynaClass.  If no properties are defined, a
       * zero-length array will be returned.</p>
       *
       * <p><strong>FIXME</strong> - Should we really be implementing
       * <code>getBeanInfo()</code> instead, which returns property descriptors
       * and a bunch of other stuff?</p>
       */
      public DynaProperty[] getDynaProperties() {
  
          return (properties);
  
      }
  
  
      /**
       * <p>Instantiate and return a new DynaBean instance, associated
       * with this DynaClass.  <strong>NOTE</strong> - This operation is not
       * supported, and throws an exception.  The <code>Iterator</code> that
       * is returned by <code>iterator()</code> will create DynaBean instances
       * for each row as needed.</p>
       *
       * @exception IllegalAccessException if the Class or the appropriate
       *  constructor is not accessible
       * @exception InstantiationException if this Class represents an abstract
       *  class, an array class, a primitive type, or void; or if instantiation
       *  fails for some other reason
       */
      public DynaBean newInstance()
              throws IllegalAccessException, InstantiationException {
  
          throw new UnsupportedOperationException("newInstance() not supported");
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * <p>Return an <code>Iterator</code> of {@link DynaBean} instances for
       * each row of the wrapped <code>ResultSet</code>, in "forward" order.
       * Unless the underlying result set supports scrolling, this method
       * should be called only once.</p>
       */
      public Iterator iterator() {
  
          return (new ResultSetIterator(this));
  
      }
  
  
      // -------------------------------------------------------- Package Methods
  
  
      /**
       * <p>Return the result set we are wrapping.</p>
       */
      ResultSet getResultSet() {
  
          return (this.resultSet);
  
      }
  
  
      // ------------------------------------------------------ Protected Methods
  
  
      /**
       * <p>Introspect the metadata associated with our result set, and populate
       * the <code>properties</code> and <code>propertiesMap</code> instance
       * variables.</p>
       *
       * @exception SQLException if an error is encountered processing the
       *  result set metadata
       */
      protected void introspect() throws SQLException {
  
          // Accumulate an ordered list of DynaProperties
          ArrayList list = new ArrayList();
          ResultSetMetaData metadata = resultSet.getMetaData();
          int n = metadata.getColumnCount();
          for (int i = 1; i <= n; i++) { // JDBC is one-relative!
              String name = metadata.getColumnName(i).toLowerCase();
              String className = metadata.getColumnClassName(i);
              Class clazz = null;
              try {
                  clazz = Class.forName(className);
              } catch (Exception e) {
                  throw new SQLException("Cannot load column class '" +
                                         className + "': " + e);
              }
              list.add(new DynaProperty(name, clazz));
          }
  
          // Convert this list into the internal data structures we need
          properties =
              (DynaProperty[]) list.toArray(new DynaProperty[list.size()]);
          for (int i = 0; i < properties.length; i++) {
              propertiesMap.put(properties[i].getName(), properties[i]);
          }
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetIterator.java
  
  Index: ResultSetIterator.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetIterator.java,v 1.1 2002/07/12 22:38:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/12 22:38:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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.commons.beanutils;
  
  
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.Iterator;
  import java.util.NoSuchElementException;
  
  
  /**
   * <p>Implementation of <code>java.util.Iterator</code> returned by the
   * <code>iterator()</code> method of {@link ResultSetDynaClass}.  Each
   * object returned by this iterator will be a {@link DynaBean} that
   * represents a single row from the result set being wrapped.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/12 22:38:21 $
   */
  
  public class ResultSetIterator implements DynaBean, Iterator {
  
  
      // ------------------------------------------------------------ Constructor
  
  
      /**
       * <p>Construct an <code>Iterator</code> for the result set being wrapped
       * by the specified {@link ResultSetDynaClass}.</p>
       *
       * @param dynaClass The {@link ResultSetDynaClass} wrapping the
       *  result set we will iterate over
       */
      ResultSetIterator(ResultSetDynaClass dynaClass) {
  
          this.dynaClass = dynaClass;
  
      }
  
  
      // ----------------------------------------------------- Instance Variables
  
  
  
      /**
       * <p>Flag indicating whether the result set is currently positioned at a
       * row for which we have not yet returned an element in the iteration.</p>
       */
      protected boolean current = false;
  
  
      /**
       * <p>The {@link ResultSetDynaClass} we are associated with.</p>
       */
      protected ResultSetDynaClass dynaClass = null;
  
  
      /**
       * <p>Flag indicating whether the result set has indicated that there are
       * no further rows.</p>
       */
      protected boolean eof = false;
  
  
      // ------------------------------------------------------- DynaBean Methods
  
  
      /**
       * Does the specified mapped property contain a value for the specified
       * key value?
       *
       * @param name Name of the property to check
       * @param key Name of the key to check
       *
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       */
      public boolean contains(String name, String key) {
  
          throw new UnsupportedOperationException
              ("FIXME - mapped properties not currently supported");
  
      }
  
  
      /**
       * Return the value of a simple property with the specified name.
       *
       * @param name Name of the property whose value is to be retrieved
       *
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       */
      public Object get(String name) {
  
          if (dynaClass.getDynaProperty(name) == null) {
              throw new IllegalArgumentException(name);
          }
          try {
              return (dynaClass.getResultSet().getObject(name));
          } catch (SQLException e) {
              throw new RuntimeException
                  ("get(" + name + "): SQLException: " + e);
          }
  
      }
  
  
      /**
       * Return the value of an indexed property with the specified name.
       *
       * @param name Name of the property whose value is to be retrieved
       * @param index Index of the value to be retrieved
       *
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       * @exception IllegalArgumentException if the specified property
       *  exists, but is not indexed
       * @exception IndexOutOfBoundsException if the specified index
       *  is outside the range of the underlying property
       * @exception NullPointerException if no array or List has been
       *  initialized for this property
       */
      public Object get(String name, int index) {
  
          throw new UnsupportedOperationException
              ("FIXME - indexed properties not currently supported");
  
      }
  
  
      /**
       * Return the value of a mapped property with the specified name,
       * or <code>null</code> if there is no value for the specified key.
       *
       * @param name Name of the property whose value is to be retrieved
       * @param key Key of the value to be retrieved
       *
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       * @exception IllegalArgumentException if the specified property
       *  exists, but is not mapped
       */
      public Object get(String name, String key) {
  
          throw new UnsupportedOperationException
              ("FIXME - mapped properties not currently supported");
  
      }
  
  
      /**
       * Return the <code>DynaClass</code> instance that describes the set of
       * properties available for this DynaBean.
       */
      public DynaClass getDynaClass() {
  
          return (this.dynaClass);
  
      }
  
  
      /**
       * Remove any existing value for the specified key on the
       * specified mapped property.
       *
       * @param name Name of the property for which a value is to
       *  be removed
       * @param key Key of the value to be removed
       *
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       */
      public void remove(String name, String key) {
  
          throw new UnsupportedOperationException
              ("FIXME - mapped operations not currently supported");
  
      }
  
  
      /**
       * Set the value of a simple property with the specified name.
       *
       * @param name Name of the property whose value is to be set
       * @param value Value to which this property is to be set
       *
       * @exception ConversionException if the specified value cannot be
       *  converted to the type required for this property
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       * @exception NullPointerException if an attempt is made to set a
       *  primitive property to null
       */
      public void set(String name, Object value) {
  
          if (dynaClass.getDynaProperty(name) == null) {
              throw new IllegalArgumentException(name);
          }
          try {
              dynaClass.getResultSet().updateObject(name, value);
          } catch (SQLException e) {
              throw new RuntimeException
                  ("set(" + name + "): SQLException: " + e);
          }
  
      }
  
  
      /**
       * Set the value of an indexed property with the specified name.
       *
       * @param name Name of the property whose value is to be set
       * @param index Index of the property to be set
       * @param value Value to which this property is to be set
       *
       * @exception ConversionException if the specified value cannot be
       *  converted to the type required for this property
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       * @exception IllegalArgumentException if the specified property
       *  exists, but is not indexed
       * @exception IndexOutOfBoundsException if the specified index
       *  is outside the range of the underlying property
       */
      public void set(String name, int index, Object value) {
  
          throw new UnsupportedOperationException
              ("FIXME - indexed properties not currently supported");
  
      }
  
  
      /**
       * Set the value of a mapped property with the specified name.
       *
       * @param name Name of the property whose value is to be set
       * @param key Key of the property to be set
       * @param value Value to which this property is to be set
       *
       * @exception ConversionException if the specified value cannot be
       *  converted to the type required for this property
       * @exception IllegalArgumentException if there is no property
       *  of the specified name
       * @exception IllegalArgumentException if the specified property
       *  exists, but is not mapped
       */
      public void set(String name, String key, Object value) {
  
          throw new UnsupportedOperationException
              ("FIXME - mapped properties not currently supported");
  
      }
  
  
      // ------------------------------------------------------- Iterator Methods
  
  
      /**
       * <p>Return <code>true</code> if the iteration has more elements.</p>
       */
      public boolean hasNext() {
  
          try {
              advance();
              return (!eof);
          } catch (SQLException e) {
              throw new RuntimeException("hasNext():  SQLException:  " + e);
          }
  
      }
  
  
      /**
       * <p>Return the next element in the iteration.</p>
       */
      public Object next() {
  
          try {
              advance();
              if (eof) {
                  throw new NoSuchElementException();
              }
              current = false;
              return (this);
          } catch (SQLException e) {
              throw new RuntimeException("next():  SQLException:  " + e);
          }
  
      }
  
  
      /**
       * <p>Remove the current element from the iteration.  This method is
       * not supported.</p>
       */
      public void remove() {
  
          throw new UnsupportedOperationException("remove()");
  
      }
  
  
      // ------------------------------------------------------ Protected Methods
  
  
      /**
       * <p>Advance the result set to the next row, if there is not a current
       * row (and if we are not already at eof).</p>
       *
       * @exception SQLException if the result set throws an exception
       */
      protected void advance() throws SQLException {
  
          if (!current && !eof) {
              if (dynaClass.getResultSet().next()) {
                  current = true;
                  eof = false;
              } else {
                  current = false;
                  eof = true;
              }
          }
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/DynaResultSetTestCase.java
  
  Index: DynaResultSetTestCase.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/DynaResultSetTestCase.java,v 1.1 2002/07/12 22:38:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/12 22:38:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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.commons.beanutils;
  
  
  import java.lang.reflect.InvocationTargetException;
  import java.math.BigDecimal;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import junit.framework.TestCase;
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  
  /**
   * Test accessing ResultSets via DynaBeans.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/12 22:38:21 $
   */
  
  public class DynaResultSetTestCase extends TestCase {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The mock result set DynaClass to be tested.
       */
      protected ResultSetDynaClass dynaClass = null;
  
  
      /**
       * Names of the columns for this test.  Must match the order they are
       * defined in {@link TestResultSetMetaData}, and must be all lower case.
       */
      protected String columns[] =
      { "bigdecimalproperty", "booleanproperty",
        "byteproperty", "dateproperty",
        "doubleproperty", "floatproperty",
        "intproperty", "longproperty",
        "nullproperty", "shortproperty",
        "stringproperty", "timeproperty",
        "timestampproperty" };
  
  
      // ----------------------------------------------------------- Constructors
  
  
      /**
       * Construct a new instance of this test case.
       *
       * @param name Name of the test case
       */
      public DynaResultSetTestCase(String name) {
  
          super(name);
  
      }
  
  
      // --------------------------------------------------- Overall Test Methods
  
  
      /**
       * Set up instance variables required by this test case.
       */
      public void setUp() throws Exception {
  
          dynaClass = new ResultSetDynaClass(new TestResultSet());
  
      }
  
  
      /**
       * Return the tests included in this test suite.
       */
      public static Test suite() {
  
          return (new TestSuite(DynaResultSetTestCase.class));
  
      }
  
  
      /**
       * Tear down instance variables required by this test case.
       */
      public void tearDown() {
  
          dynaClass = null;
  
      }
  
  
  
      // ------------------------------------------------ Individual Test Methods
  
  
      public void testGetName() {
  
          assertEquals("DynaClass name",
                       "org.apache.commons.beanutils.ResultSetDynaClass",
                       dynaClass.getName());
  
  
      }
  
  
      public void testGetDynaProperty() {
  
          // Invalid argument test
          try {
              dynaClass.getDynaProperty(null);
              fail("Did not throw IllegaArgumentException");
          } catch (IllegalArgumentException e) {
              ; // Expected result
          }
  
          // Negative test
          DynaProperty dynaProp = dynaClass.getDynaProperty("unknownProperty");
          assertTrue("unknown property returns null",
                     (dynaProp == null));
  
          // Positive test
          dynaProp = dynaClass.getDynaProperty("stringproperty");
          assertNotNull("string property exists", dynaProp);
          assertEquals("string property name", "stringproperty",
                       dynaProp.getName());
          assertEquals("string property class", String.class,
                       dynaProp.getType());
  
      }
  
  
      public void testGetDynaProperties() {
  
          DynaProperty dynaProps[] = dynaClass.getDynaProperties();
          assertNotNull("dynaProps exists", dynaProps);
          assertEquals("dynaProps length", columns.length, dynaProps.length);
          for (int i = 0; i < columns.length; i++) {
              assertEquals("Property " + columns[i],
                           columns[i], dynaProps[i].getName());
          }
  
      }
  
  
      public void testNewInstance() {
  
          try {
              dynaClass.newInstance();
              fail("Did not throw UnsupportedOperationException()");
          } catch (UnsupportedOperationException e) {
              ; // Expected result
          } catch (Exception e) {
              fail("Threw exception " + e);
          }
  
      }
  
  
      public void testIteratorCount() {
  
          Iterator rows = dynaClass.iterator();
          assertNotNull("iterator exists", rows);
          int n = 0;
          while (rows.hasNext()) {
              DynaBean row = (DynaBean) rows.next();
              n++;
              if (n > 10) {
                  fail("Returned too many rows");
              }
          }
          assertEquals("iterator rows", 5, n);
  
      }
  
  
      public void testIteratorResults() {
  
          // Grab the third row
          Iterator rows = dynaClass.iterator();
          rows.next();
          rows.next();
          DynaBean row = (DynaBean) rows.next();
  
          // Invalid argument test
          try {
              row.get("unknownProperty");
              fail("Did not throw IllegalArgumentException");
          } catch (IllegalArgumentException e) {
              ; // Expected result
          }
  
          // Verify property values
  
          Object bigDecimalProperty = row.get("bigdecimalproperty");
          assertNotNull("bigDecimalProperty exists", bigDecimalProperty);
          assertTrue("bigDecimalProperty type",
                     bigDecimalProperty instanceof BigDecimal);
          assertEquals("bigDecimalProperty value",
                       123.45,
                       ((BigDecimal) bigDecimalProperty).doubleValue(),
                       0.005);
  
          Object intProperty = row.get("intproperty");
          assertNotNull("intProperty exists", intProperty);
          assertTrue("intProperty type",
                     intProperty instanceof Integer);
          assertEquals("intProperty value",
                       103,
                       ((Integer) intProperty).intValue());
  
          Object nullProperty = row.get("nullproperty");
          assertNull("nullProperty null", nullProperty);
  
          Object stringProperty = row.get("stringproperty");
          assertNotNull("stringProperty exists", stringProperty);
          assertTrue("stringProperty type",
                     stringProperty instanceof String);
          assertEquals("stringProperty value",
                       "This is a string",
                       (String) stringProperty);
  
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestResultSet.java
  
  Index: TestResultSet.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestResultSet.java,v 1.1 2002/07/12 22:38:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/12 22:38:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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.commons.beanutils;
  
  
  import java.io.InputStream;
  import java.io.Reader;
  import java.math.BigDecimal;
  import java.net.URL;
  import java.sql.Array;
  import java.sql.Blob;
  import java.sql.Clob;
  import java.sql.Date;
  import java.sql.Ref;
  import java.sql.ResultSet;
  import java.sql.ResultSetMetaData;
  import java.sql.SQLException;
  import java.sql.SQLWarning;
  import java.sql.Statement;
  import java.sql.Time;
  import java.sql.Timestamp;
  import java.util.Calendar;
  import java.util.Map;
  
  
  /**
   * <p>Mock object that implements enough of <code>java.sql.ResultSet</code>
   * to exercise the {@link ResultSetDyaClass} functionality.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/12 22:38:21 $
   */
  
  public class TestResultSet implements ResultSet {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * Current row number (0 means "before the first one").
       */
      protected int row = 0;
  
  
      /**
       * The constant (per run) value used to initialize date/time/timestamp.
       */
      protected long timestamp = System.currentTimeMillis();
  
  
      // ---------------------------------------------------- Implemented Methods
  
  
      public void close() throws SQLException {
          ; // No action required
      }
  
  
      public ResultSetMetaData getMetaData() throws SQLException {
          return (new TestResultSetMetaData());
      }
  
  
      public Object getObject(String columnName) throws SQLException {
          if (row > 5) {
              throw new SQLException("No current row");
          }
          if ("bigdecimalproperty".equals(columnName)) {
              return (new BigDecimal(123.45));
          } else if ("booleanproperty".equals(columnName)) {
              if ((row % 2) == 0) {
                  return (Boolean.TRUE);
              } else {
                  return (Boolean.FALSE);
              }
          } else if ("byteproperty".equals(columnName)) {
              return (new Byte((byte) row));
          } else if ("dateproperty".equals(columnName)) {
              return (new Date(timestamp));
          } else if ("doubleproperty".equals(columnName)) {
              return (new Double(321.0));
          } else if ("floatproperty".equals(columnName)) {
              return (new Float((float) 123.0));
          } else if ("intproperty".equals(columnName)) {
              return (new Integer(100 + row));
          } else if ("longproperty".equals(columnName)) {
              return (new Long(200 + row));
          } else if ("nullproperty".equals(columnName)) {
              return (null);
          } else if ("shortproperty".equals(columnName)) {
              return (new Short((short) (300 + row)));
          } else if ("stringproperty".equals(columnName)) {
              return ("This is a string");
          } else if ("timeproperty".equals(columnName)) {
              return (new Time(timestamp));
          } else if ("timestampproperty".equals(columnName)) {
              return (new Timestamp(timestamp));
          } else {
              throw new SQLException("Unknown column name " + columnName);
          }
      }
  
  
      public boolean next() throws SQLException {
          if (row++ < 5) {
              return (true);
          } else {
              return (false);
          }
      }
  
  
      public void updateObject(String columnName, Object x)
          throws SQLException {
          if (row > 5) {
              throw new SQLException("No current row");
          }
          ; // FIXME - updateObject()
      }
  
  
      // -------------------------------------------------- Unimplemented Methods
  
  
      public boolean absolute(int row) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void afterLast() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void beforeFirst() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void cancelRowUpdates() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void clearWarnings() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void deleteRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int findColumn(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean first() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Array getArray(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Array getArray(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getAsciiStream(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getAsciiStream(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public BigDecimal getBigDecimal(int columnIndex, int scale)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public BigDecimal getBigDecimal(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public BigDecimal getBigDecimal(String columnName, int scale)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getBinaryStream(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getBinaryStream(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Blob getBlob(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Blob getBlob(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean getBoolean(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean getBoolean(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public byte getByte(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public byte getByte(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public byte[] getBytes(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public byte[] getBytes(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Reader getCharacterStream(int columnIndex)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Reader getCharacterStream(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Clob getClob(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Clob getClob(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getConcurrency() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getCursorName() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Date getDate(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Date getDate(int columnIndex, Calendar cal) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Date getDate(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Date getDate(String columnName, Calendar cal) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public double getDouble(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public double getDouble(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getFetchDirection() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getFetchSize() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public float getFloat(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public float getFloat(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getInt(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getInt(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public long getLong(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public long getLong(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Object getObject(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Object getObject(int columnIndex, Map map) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Object getObject(String columnName, Map map) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Ref getRef(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Ref getRef(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public short getShort(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public short getShort(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Statement getStatement() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getString(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getString(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Time getTime(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Time getTime(int columnIndex, Calendar cal) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Time getTime(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Time getTime(String columnName, Calendar cal) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Timestamp getTimestamp(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Timestamp getTimestamp(int columnIndex, Calendar cal)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Timestamp getTimestamp(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public Timestamp getTimestamp(String columnName, Calendar cal)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getType() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getUnicodeStream(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public InputStream getUnicodeStream(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public URL getURL(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public URL getURL(String columnName) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public SQLWarning getWarnings() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void insertRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isAfterLast() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isBeforeFirst() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isFirst() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isLast() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean last() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void moveToCurrentRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void moveToInsertRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean previous() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void refreshRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean relative(int rows) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean rowDeleted() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean rowInserted() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean rowUpdated() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void setFetchDirection(int direction) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void setFetchSize(int size) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateArray(int columnPosition, Array x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateArray(String columnName, Array x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateAsciiStream(int columnPosition, InputStream x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateAsciiStream(String columnName, InputStream x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBigDecimal(int columnPosition, BigDecimal x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBigDecimal(String columnName, BigDecimal x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBinaryStream(int columnPosition, InputStream x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBinaryStream(String columnName, InputStream x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBlob(int columnPosition, Blob x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBlob(String columnName, Blob x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBoolean(int columnPosition, boolean x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBoolean(String columnName, boolean x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateByte(int columnPosition, byte x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateByte(String columnName, byte x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBytes(int columnPosition, byte x[])
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateBytes(String columnName, byte x[])
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateCharacterStream(int columnPosition, Reader x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateCharacterStream(String columnName, Reader x, int len)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateClob(int columnPosition, Clob x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateClob(String columnName, Clob x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateDate(int columnPosition, Date x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateDate(String columnName, Date x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateDouble(int columnPosition, double x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateDouble(String columnName, double x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateFloat(int columnPosition, float x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateFloat(String columnName, float x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateInt(int columnPosition, int x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateInt(String columnName, int x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateLong(int columnPosition, long x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateLong(String columnName, long x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateNull(int columnPosition)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateNull(String columnName)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateObject(int columnPosition, Object x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateObject(int columnPosition, Object x, int scale)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateObject(String columnName, Object x, int scale)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateRef(int columnPosition, Ref x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateRef(String columnName, Ref x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateRow() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateShort(int columnPosition, short x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateShort(String columnName, short x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateString(int columnPosition, String x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateString(String columnName, String x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateTime(int columnPosition, Time x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateTime(String columnName, Time x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateTimestamp(int columnPosition, Timestamp x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public void updateTimestamp(String columnName, Timestamp x)
          throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean wasNull() throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestResultSetMetaData.java
  
  Index: TestResultSetMetaData.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/beanutils/src/test/org/apache/commons/beanutils/TestResultSetMetaData.java,v 1.1 2002/07/12 22:38:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2002/07/12 22:38:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 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", "Commons", 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.commons.beanutils;
  
  
  import java.sql.ResultSetMetaData;
  import java.sql.SQLException;
  
  
  /**
   * <p>Mock object that implements enough of
   * <code>java.sql.ResultSetMetaData</code>
   * to exercise the {@link ResultSetDyaClass} functionality.</p>
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2002/07/12 22:38:21 $
   */
  
  public class TestResultSetMetaData implements ResultSetMetaData {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * <p>Array of column names and class names for metadata.</p>
       */
      protected String metadata[][] = {
          { "bigDecimalProperty", "java.math.BigDecimal" },
          { "booleanProperty", Boolean.class.getName() },
          { "byteProperty", Byte.class.getName() },
          { "dateProperty", "java.sql.Date" },
          { "doubleProperty", Double.class.getName() },
          { "floatProperty", Float.class.getName() },
          { "intProperty", Integer.class.getName() },
          { "longProperty", Long.class.getName() },
          { "nullProperty", "java.lang.String" },
          { "shortProperty", Short.class.getName() },
          { "stringProperty", "java.lang.String" },
          { "timeProperty", "java.sql.Time" },
          { "timestampProperty", "java.sql.Timestamp" },
      };
  
  
      // ---------------------------------------------------- Implemented Methods
  
  
      public String getColumnClassName(int columnIndex) throws SQLException {
          return (metadata[columnIndex - 1][1]);
      }
  
  
      public int getColumnCount() throws SQLException {
          return (metadata.length);
      }
  
      public String getColumnName(int columnIndex) throws SQLException {
          return (metadata[columnIndex - 1][0]);
      }
  
  
      // -------------------------------------------------- Unimplemented Methods
  
  
      public String getCatalogName(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getColumnDisplaySize(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getColumnLabel(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getColumnType(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getColumnTypeName(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getPrecision(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int getScale(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getSchemaName(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public String getTableName(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isAutoIncrement(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isCaseSensitive(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isCurrency(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isDefinitelyWritable(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public int isNullable(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isReadOnly(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isSearchable(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isSigned(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
      public boolean isWritable(int columnIndex) throws SQLException {
          throw new UnsupportedOperationException();
      }
  
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message