avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl Default13BooleanColumn.java DefaultBooleanColumn.java
Date Fri, 21 Dec 2001 18:31:43 GMT
hammant     01/12/21 10:31:43

  Modified:    apps/db/src/java/org/apache/avalon/db/data/impl
                        DefaultBooleanColumn.java
  Added:       apps/db/src/java/org/apache/avalon/db/data/impl
                        Default13BooleanColumn.java
  Log:
  boolean field for pre jdk 1.4 platforms.
  
  Revision  Changes    Path
  1.2       +2 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/DefaultBooleanColumn.java
  
  Index: DefaultBooleanColumn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/DefaultBooleanColumn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultBooleanColumn.java	2001/12/20 11:08:16	1.1
  +++ DefaultBooleanColumn.java	2001/12/21 18:31:43	1.2
  @@ -13,7 +13,6 @@
   import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.types.SQLType;
   import org.apache.avalon.db.data.types.BooleanColumn;
  -import org.apache.avalon.db.utils.StringUtils;
   import java.math.BigDecimal;
   
   
  @@ -23,7 +22,7 @@
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>*
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class DefaultBooleanColumn extends AbstractWritableColumn implements BooleanColumn
{
   
  @@ -88,7 +87,7 @@
       }
   
       public int getPrecesion() {
  -        return Column.PREC_STRING;
  +        return Column.PREC_BOOLEAN;
       }
   
       public boolean getBooleanValue(Row row) {
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/Default13BooleanColumn.java
  
  Index: Default13BooleanColumn.java
  ===================================================================
  
  /*
   * 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.
   */
  package org.apache.avalon.db.data.impl;
  
  import org.apache.avalon.db.data.ValidationException;
  import org.apache.avalon.db.data.Row;
  import org.apache.avalon.db.data.Column;
  import org.apache.avalon.db.data.types.SQLType;
  import org.apache.avalon.db.data.types.BooleanColumn;
  import java.math.BigDecimal;
  
  
  /**
   * Class DefaultBooleanColumn for Java 1.3
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class Default13BooleanColumn extends AbstractWritableColumn implements BooleanColumn
{
  
      /**
       * Constructor DefaultBooleanColumn
       *
       *
       * @param name
       * @param maxLength
       *
       */
      public Default13BooleanColumn(String name) {
          super(name, SQLType.INTEGER);
      }
  
      public Object convertFromObject(Object obj) throws ValidationException {
          if (obj instanceof String) {
            return Boolean.valueOf(obj.toString());
          } else if (obj instanceof Boolean) {
              return obj;
          } else {
              throw new ValidationException("Boolean " + mName + " is not passed up as String
or Boolean");
          }
      }
  
      public Object getValue(Row row) {
          return row.getValue(mIndex);
      }
  
      public String toString(Row row) {
          return row.getValue(mIndex).toString();
      }
  
      private static Integer INT_TRUE = new Integer(1);
      private static Integer INT_FALSE = new Integer(0);
      public Integer toInteger(Row row) {
          return getBooleanValue(row) ? INT_TRUE : INT_FALSE;
      }
  
      private static Long LONG_TRUE = new Long(1);
      private static Long LONG_FALSE = new Long(0);
      public Long toLong(Row row) {
          return getBooleanValue(row) ? LONG_TRUE : LONG_FALSE;
      }
  
      private static BigDecimal BD_TRUE = new BigDecimal(1);
      private static BigDecimal BD_FALSE = new BigDecimal(0);
      public BigDecimal toBigDecimal(Row row) {
          return getBooleanValue(row) ? BD_TRUE : BD_FALSE;
      }
  
      private static Float FLOAT_TRUE = new Float(1);
      private static Float FLOAT_FALSE = new Float(0);
      public Float toFloat(Row row) {
          return getBooleanValue(row) ? FLOAT_TRUE : FLOAT_FALSE;
      }
  
      private static Short SHORT_TRUE = new Short((short)1);
      private static Short SHORT_FALSE = new Short((short)0);
      public Short toShort(Row row) {
          return getBooleanValue(row) ? SHORT_TRUE : SHORT_FALSE;
      }
  
      public int getPrecesion() {
          return Column.PREC_INT;
      }
  
      public boolean getBooleanValue(Row row) {
          Integer i = (Integer) getValue(row);
          return (i.intValue() == 1);
      }
  
  
  }
  
  
  

--
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