avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From froehl...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions TestHelper.java BasicSelectSimple.java
Date Mon, 17 Dec 2001 15:59:31 GMT
froehlich    01/12/17 07:59:31

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        TestHelper.java BasicSelectSimple.java
  Log:
  create, insert, select + criteria is working 90%
  
  Revision  Changes    Path
  1.6       +266 -173  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/TestHelper.java
  
  Index: TestHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/TestHelper.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestHelper.java	2001/12/02 14:45:57	1.5
  +++ TestHelper.java	2001/12/17 15:59:31	1.6
  @@ -1,69 +1,79 @@
   /*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *  Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE file.
  + *  This software is published under the terms of the Apache Software License
  + *  version 1.1, a copy of which has been included with this distribution in
  + *  the LICENSE file.
    */
  -
   package org.apache.avalon.db.basic.actions;
   
   import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.db.data.Column;
  -import org.apache.avalon.db.data.ValidationException;
   import org.apache.avalon.db.data.Row;
  -import org.apache.avalon.db.data.types.StringColumn;
  +import org.apache.avalon.db.data.ValidationException;
   import org.apache.avalon.db.data.types.NumericColumn;
  +import org.apache.avalon.db.data.types.StringColumn;
   import org.apache.avalon.db.data.types.StringConstantColumn;
   
   /**
  - * Helper class for BSF
  + *  Helper class for BSF
    *
  - * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @version $Revision: 1.19 $
  + * @author     Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
  + *      g-froehlich@gmx.de</a>
  + * @version    $Revision: 1.19 $
    */
   public class TestHelper {
   
  -    public boolean testEqual(Column lCol,Column rCol,Row row) throws ActionException {
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -           || oneIsNumericType(lCol,rCol))  {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testEqual(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
               System.out.println("lNumCol.getPrecesion()=" + lNumCol.getPrecesion());
               System.out.println("rNumCol.getPrecesion()=" + rNumCol.getPrecesion());
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) == 0) {
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) == 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) == 0)
{
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) == 0)
{
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) == 0) {
                       return true;
                   } else {
                       return false;
  @@ -71,53 +81,64 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
               return lNumCol.toString(row).equals(rNumCol.toString(row));
           } else {
               throw new ActionException("Type not supported, yet");
           }
       }
  +
   
  -    public boolean SmallerThan(Column lCol,Column rCol,Row row) throws ActionException
{
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -            || oneIsNumericType(lCol,rCol)) {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testSmallerThan(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) < 0) {
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) < 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) <
0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) <
0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) < 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) < 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) < 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) < 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) < 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) < 0) {
                       return true;
                   } else {
                       return false;
  @@ -125,12 +146,12 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0) {
  +            if (lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0) {
                   return true;
               } else {
                   return false;
  @@ -139,44 +160,55 @@
               throw new ActionException("Type not supported, yet");
           }
       }
  +
   
  -    public boolean testGreaterThan(Column lCol,Column rCol,Row row) throws ActionException
{
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -            || oneIsNumericType(lCol,rCol)) {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testGreaterThan(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) > 0) {
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) > 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) >
0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) >
0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) > 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) > 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) > 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) > 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) > 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) > 0) {
                       return true;
                   } else {
                       return false;
  @@ -184,12 +216,12 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0) {
  +            if (lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0) {
                   return true;
               } else {
                   return false;
  @@ -199,43 +231,54 @@
           }
       }
   
  -    public boolean testNotEqual(Column lCol,Column rCol,Row row) throws ActionException
{
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -            || oneIsNumericType(lCol,rCol)) {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) != 0) {
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testNotEqual(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
  +
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) != 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) != 0)
{
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) != 0)
{
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) != 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) != 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) != 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) != 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) != 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) != 0) {
                       return true;
                   } else {
                       return false;
  @@ -243,63 +286,85 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
               return !lNumCol.toString(row).equals(rNumCol.toString(row));
           } else {
               throw new ActionException("Type not supported, yet");
           }
       }
  +
   
  -    public boolean testLike(String leftexpr,String rightexpr,Column col) throws ActionException
{
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  leftexpr             Description of Parameter
  +     * @param  rightexpr            Description of Parameter
  +     * @param  col                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testLike(String leftexpr, String rightexpr, Column col)
  +        throws ActionException {
           throw new ActionException("operation not supported ");
       }
   
  -    public boolean testGreaterThanOrEqual(Column lCol,Column rCol,Row row) throws ActionException
{
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -            || oneIsNumericType(lCol,rCol)) {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) > 0
  -                    || lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) == 0) {
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testGreaterThanOrEqual(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
  +
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) > 0
  +                         || lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) ==
0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) >
0
  -                    || lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) ==
0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) >
0
  +                         || lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row))
== 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) > 0
  -                    || lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) > 0
  +                         || lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0)
{
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) > 0
  -                    || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) > 0
  +                         || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) > 0
  -                    || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) > 0
  +                         || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
                       return true;
                   } else {
                       return false;
  @@ -307,13 +372,13 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.toString(row).compareTo(rNumCol.toString(row)) > 0
  -                || lNumCol.toString(row).compareTo(rNumCol.toString(row)) == 0) {
  +            if (lNumCol.toString(row).compareTo(rNumCol.toString(row)) > 0
  +                     || lNumCol.toString(row).compareTo(rNumCol.toString(row)) == 0) {
                   return true;
               } else {
                   return false;
  @@ -322,49 +387,60 @@
               throw new ActionException("Type not supported, yet");
           }
       }
  +
   
  -    public boolean testSmallerThanOrEqual(Column lCol,Column rCol,Row row) throws ActionException
{
  -        if(lCol instanceof NumericColumn && rCol instanceof NumericColumn
  -            || oneIsNumericType(lCol,rCol)) {
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +    /**
  +     *  A unit test for JUnit
  +     *
  +     * @param  lCol                 Description of Parameter
  +     * @param  rCol                 Description of Parameter
  +     * @param  row                  Description of Parameter
  +     * @return                      Description of the Returned Value
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public boolean testSmallerThanOrEqual(Column lCol, Column rCol, Row row)
  +        throws ActionException {
  +        if (lCol instanceof NumericColumn && rCol instanceof NumericColumn
  +                 || oneIsNumericType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.getPrecesion() == Column.PREC_INT
  -                || rNumCol.getPrecesion() == Column.PREC_INT) {
  -                if(lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) < 0
  -                    || lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) == 0) {
  +            if (lNumCol.getPrecesion() == Column.PREC_INT
  +                     || rNumCol.getPrecesion() == Column.PREC_INT) {
  +                if (lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) < 0
  +                         || lNumCol.toInteger(row).compareTo(rNumCol.toInteger(row)) ==
0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_BIGDEC
  -                || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  -                if(lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) <
0
  -                    || lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) ==
0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_BIGDEC
  +                     || rNumCol.getPrecesion() == Column.PREC_BIGDEC) {
  +                if (lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row)) <
0
  +                         || lNumCol.toBigDecimal(row).compareTo(rNumCol.toBigDecimal(row))
== 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_FLOAT
  -                || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  -                if(lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) < 0
  -                    || lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_FLOAT
  +                     || rNumCol.getPrecesion() == Column.PREC_FLOAT) {
  +                if (lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) < 0
  +                         || lNumCol.toFloat(row).compareTo(rNumCol.toFloat(row)) == 0)
{
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_LONG
  -                || rNumCol.getPrecesion() == Column.PREC_LONG) {
  -                if(lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) < 0
  -                    || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_LONG
  +                     || rNumCol.getPrecesion() == Column.PREC_LONG) {
  +                if (lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) < 0
  +                         || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
                       return true;
                   } else {
                       return false;
                   }
  -            } else if(lNumCol.getPrecesion() == Column.PREC_SHORT
  -                || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  -                if(lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) < 0
  -                    || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
  +            } else if (lNumCol.getPrecesion() == Column.PREC_SHORT
  +                     || rNumCol.getPrecesion() == Column.PREC_SHORT) {
  +                if (lNumCol.toShort(row).compareTo(rNumCol.toShort(row)) < 0
  +                         || lNumCol.toLong(row).compareTo(rNumCol.toLong(row)) == 0) {
                       return true;
                   } else {
                       return false;
  @@ -372,13 +448,13 @@
               } else {
                   throw new ActionException("Type not supported, yet");
               }
  -        } else if(lCol instanceof StringColumn && rCol instanceof StringColumn
  -            || oneIsStringType(lCol,rCol)){
  -            Column lNumCol = (Column)lCol;
  -            Column rNumCol = (Column)rCol;
  +        } else if (lCol instanceof StringColumn && rCol instanceof StringColumn
  +                 || oneIsStringType(lCol, rCol)) {
  +            Column lNumCol = (Column) lCol;
  +            Column rNumCol = (Column) rCol;
   
  -            if(lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0
  -                || lNumCol.toString(row).compareTo(rNumCol.toString(row)) == 0) {
  +            if (lNumCol.toString(row).compareTo(rNumCol.toString(row)) < 0
  +                     || lNumCol.toString(row).compareTo(rNumCol.toString(row)) == 0) {
                   return true;
               } else {
                   return false;
  @@ -388,21 +464,38 @@
           }
       }
   
  +
  +    /**
  +     *  Description of the Method
  +     *
  +     * @param  lCol  Description of Parameter
  +     * @param  rCol  Description of Parameter
  +     * @return       Description of the Returned Value
  +     */
       private boolean oneIsNumericType(Column lCol, Column rCol) {
           if ((lCol instanceof NumericColumn && rCol instanceof StringConstantColumn)
  -            || (lCol instanceof StringConstantColumn && rCol instanceof NumericColumn))
{
  +                 || (lCol instanceof StringConstantColumn && rCol instanceof NumericColumn))
{
               return true;
           } else {
               return false;
           }
       }
   
  +
  +    /**
  +     *  Description of the Method
  +     *
  +     * @param  lCol  Description of Parameter
  +     * @param  rCol  Description of Parameter
  +     * @return       Description of the Returned Value
  +     */
       private boolean oneIsStringType(Column lCol, Column rCol) {
           if ((lCol instanceof StringColumn && rCol instanceof StringConstantColumn)
  -            || (lCol instanceof StringConstantColumn && rCol instanceof StringColumn))
{
  +                 || (lCol instanceof StringConstantColumn && rCol instanceof StringColumn))
{
               return true;
           } else {
               return false;
           }
       }
   }
  +
  
  
  
  1.4       +131 -55   jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelectSimple.java
  
  Index: BasicSelectSimple.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicSelectSimple.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicSelectSimple.java	2001/12/01 17:50:26	1.3
  +++ BasicSelectSimple.java	2001/12/17 15:59:31	1.4
  @@ -1,38 +1,42 @@
   /*
  - * Copyright (C) The Apache Software Foundation. All rights reserved.
  + *  Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  - * This software is published under the terms of the Apache Software License
  - * version 1.1, a copy of which has been included with this distribution in
  - * the LICENSE file.
  + *  This software is published under the terms of the Apache Software License
  + *  version 1.1, a copy of which has been included with this distribution in
  + *  the LICENSE file.
    */
   package org.apache.avalon.db.basic.actions;
   
  -import org.apache.avalon.db.actions.impl.AbstractAction;
  -import org.apache.avalon.db.actions.Select;
  -import org.apache.avalon.db.actions.ParameterAdaptable;
   import org.apache.avalon.db.actions.ActionException;
  -import org.apache.avalon.db.results.RowSet;
  -import org.apache.avalon.db.results.Columns;
  -import org.apache.avalon.db.basic.data.BasicTable;
  +import org.apache.avalon.db.actions.ParameterAdaptable;
  +import org.apache.avalon.db.actions.Select;
  +import org.apache.avalon.db.actions.impl.AbstractAction;
   import org.apache.avalon.db.basic.data.BasicRow;
  -import org.apache.avalon.db.basic.results.BasicRowSet;
  +import org.apache.avalon.db.basic.data.BasicTable;
   import org.apache.avalon.db.basic.results.BasicColumns;
  +import org.apache.avalon.db.basic.results.BasicRowSet;
   import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.Row;
   import org.apache.avalon.db.data.impl.AbstractQueryable;
  +import org.apache.avalon.db.results.Columns;
  +import org.apache.avalon.db.results.RowSet;
   import org.apache.avalon.framework.logger.LogEnabled;
   
   import java.util.Vector;
   import java.util.Iterator;
   
   /**
  - * This class represents the BasicSelectSimple
  - * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  + *  This class represents the BasicSelectSimple
    *
  - * @version $Revision: 1.3 $
  + * @author     Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">
  + *      g-froehlich@gmx.de</a>
  + * @author     Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">
  + *      Paul_Hammant@yahoo.com</a>
  + * @version    $Revision: 1.4 $
    */
  -public class BasicSelectSimple extends AbstractAction implements Select,ParameterAdaptable,LogEnabled
{
  +public class BasicSelectSimple 
  +extends AbstractAction 
  +implements Select, ParameterAdaptable, LogEnabled {
   
       private RowSet mRowSet;
       private Columns mColumns;
  @@ -43,39 +47,130 @@
       private Column[] mCols;
       private String[] mTablenames;
       private BasicCriteria mBasicCriteria;
  +
   
  -    public BasicSelectSimple(String[] tableNames, Column[] columns, BasicCriteria basicCriteria)
{
  +    /**
  +     *  Constructor for the BasicSelectSimple object
  +     *
  +     * @param  tableNames     Description of Parameter
  +     * @param  columns        Description of Parameter
  +     * @param  basicCriteria  Description of Parameter
  +     */
  +    public BasicSelectSimple(String[] tableNames,
  +                             Column[] columns,
  +                             BasicCriteria basicCriteria) {
           mTablenames = tableNames;
           mCols = columns;
           mBasicCriteria = basicCriteria;
       }
  +
  +
  +    /**
  +     *  Sets the prepared attribute of the BasicSelectSimple object
  +     *
  +     * @param  b  The new prepared value
  +     */
  +    public void setPrepared(boolean b) {
  +        mPrepared = b;
  +    }
  +
  +
  +    /**
  +     *  Sets the withParams attribute of the BasicSelectSimple object
  +     *
  +     * @param  b  The new withParams value
  +     */
  +    public void setWithParams(boolean b) {
  +        mWithParams = b;
  +    }
  +
  +
  +    /**
  +     *  Sets the paramCount attribute of the BasicSelectSimple object
  +     *
  +     * @param  i  The new paramCount value
  +     */
  +    public void setParamCount(int i) {
  +        this.mParamCount = i;
  +    }
  +
  +
  +    /**
  +     *  Gets the prepared attribute of the BasicSelectSimple object
  +     *
  +     * @return    The prepared value
  +     */
  +    public boolean getPrepared() {
  +        return mPrepared;
  +    }
  +
  +
  +    /**
  +     *  Gets the withParams attribute of the BasicSelectSimple object
  +     *
  +     * @return    The withParams value
  +     */
  +    public boolean getWithParams() {
  +        return mWithParams;
  +    }
   
  -    public void initialize() throws ActionException {
  +
  +    /**
  +     *  Gets the rowSet attribute of the BasicSelectSimple object
  +     *
  +     * @return    The rowSet value
  +     */
  +    public RowSet getRowSet() {
  +        return mRowSet;
  +    }
  +
  +
  +    /**
  +     *  Gets the paramCount attribute of the BasicSelectSimple object
  +     *
  +     * @return    The paramCount value
  +     */
  +    public int getParamCount() {
  +        return this.mParamCount;
  +    }
  +
  +
  +    /**
  +     *  Description of the Method
  +     *
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public void initialize()
  +        throws ActionException {
           getLogger().debug("BasicSelectSimple.initialize()");
           getLogger().debug("cols.length=" + mCols.length);
           getLogger().debug("tablenames.length=" + mTablenames.length);
       }
   
  +
       /**
  -     * The execute method for this action
  +     *  The execute method for this action
  +     *
  +     * @exception  ActionException  Description of Exception
        */
  -    public void execute() throws ActionException {
  +    public void execute()
  +        throws ActionException {
           StringBuffer strbuf = new StringBuffer();
           Vector selectedRows = new Vector();
           Object[] selectedRow = null;
           selectedRows = new Vector();
  +
  +        for (int i = 0; i < mTablenames.length; i++) {
   
  -        for(int i=0; i < mTablenames.length; i++) {
  -            /** get the table, should be only one */
               mQueryable = (AbstractQueryable) mDatabasePersistor.getQueryable(mTablenames[i]);
               Iterator it = mQueryable.getRows().iterator();
  -            while(it.hasNext()) {
  -                /** iterate rows and select only the needed cols */
  +            while (it.hasNext()) {
  +
                   Row row = (Row) it.next();
                   if (mBasicCriteria.testActionRow(row)) {
                       getLogger().debug("specific select=" + mCols);
                       selectedRow = new Object[mCols.length];
  -                    for (int j=0; j < mCols.length; j++) {
  +                    for (int j = 0; j < mCols.length; j++) {
                           getLogger().debug("mCols[" + j + "]=" + mCols[j]);
                           Object o = mCols[j].getValue(row);
                           getLogger().debug("row.getValue(mCols[" + j + "]=" + o);
  @@ -86,39 +181,20 @@
               }
               getLogger().debug("selectedRows.size()=" + selectedRows.size());
               mColumns = new BasicColumns();
  -            mRowSet = new BasicRowSet(mColumns,selectedRows);
  +            mRowSet = new BasicRowSet(mColumns, selectedRows);
           }
       }
   
  -    public void execute(Object[] params) throws ActionException {
  -        getLogger().debug("select execute prepared");
  -    }
  -
  -    public void setPrepared(boolean b) {
  -        mPrepared = b;
  -    }
  -
  -    public boolean getPrepared() {
  -        return mPrepared;
  -    }
  -
  -    public void setWithParams(boolean b) {
  -        mWithParams = b;
  -    }
  -
  -    public boolean getWithParams() {
  -        return mWithParams;
  -    }
  -
  -    public RowSet getRowSet() {
  -        return mRowSet;
  -    }
  -
  -    public int getParamCount() {
  -        return this.mParamCount;
  -    }
   
  -    public void setParamCount(int i) {
  -        this.mParamCount = i;
  +    /**
  +     *  Description of the Method
  +     *
  +     * @param  params               Description of Parameter
  +     * @exception  ActionException  Description of Exception
  +     */
  +    public void execute(Object[] params)
  +        throws ActionException {
  +        getLogger().debug("select execute prepared");
       }
   }
  +
  
  
  

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


Mime
View raw message