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

cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl IntegerColumn.java VarCharColumn.java

hammant     01/11/13 01:07:26

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicCreateQueryable.java
               apps/db/src/java/org/apache/avalon/db/data/impl
                        VarCharColumn.java
  Added:       apps/db/src/java/org/apache/avalon/db/data/impl
                        IntegerColumn.java
  Log:
  integer column type
  
  Revision  Changes    Path
  1.3       +4 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateQueryable.java
  
  Index: BasicCreateQueryable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateQueryable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BasicCreateQueryable.java	2001/11/12 23:09:56	1.2
  +++ BasicCreateQueryable.java	2001/11/13 09:07:25	1.3
  @@ -15,6 +15,7 @@
   import org.apache.avalon.db.data.Table;
   import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.db.data.impl.VarCharColumn;
  +import org.apache.avalon.db.data.impl.IntegerColumn;
   import org.apache.avalon.db.basic.data.BasicTable;
   import org.apache.avalon.db.services.DatabasePersistor;
   import org.w3c.dom.Element;
  @@ -29,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public abstract class BasicCreateQueryable extends AbstractAction implements CreateTable {
   
  @@ -58,6 +59,8 @@
                           if (sqlFieldType.equals("varchar")) {
                               int maxLength = Integer.parseInt(columnNode.getAttributes().getNamedItem("max").getNodeValue());
                               column= new VarCharColumn(fieldName, maxLength);
  +                        } else if (sqlFieldType.equals("integer")) {
  +                            column= new IntegerColumn(fieldName);
                           }
                           columns.add(column);
                       } else {
  
  
  
  1.2       +2 -11     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/VarCharColumn.java
  
  Index: VarCharColumn.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/VarCharColumn.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- VarCharColumn.java	2001/11/12 23:09:56	1.1
  +++ VarCharColumn.java	2001/11/13 09:07:26	1.2
  @@ -8,11 +8,6 @@
    */
   package org.apache.avalon.db.data.impl;
   
  -
  -
  -import org.apache.avalon.db.data.Table;
  -import org.apache.avalon.db.data.Queryable;
  -import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.ValidationException;
   
   
  @@ -22,7 +17,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 VarCharColumn extends AbstractColumn {
   
  @@ -34,7 +29,6 @@
        *
        * @param name
        * @param maxLength
  -     * @param javaType
        *
        */
       public VarCharColumn(String name, int maxLength) {
  @@ -45,10 +39,7 @@
       public void test(Object obj) throws ValidationException {
           String str = (String) obj;
           if (str.length() > mMaxLength) {
  -            throw new ValidationException("String " + mName + "at is too long at " + str.length());
  +            throw new ValidationException("String " + mName + " is too long at " + str.length());
           }
       }
  -
  -
  -
   }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/IntegerColumn.java
  
  Index: IntegerColumn.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;
  
  
  /**
   * Class IntegerColumn
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class IntegerColumn extends AbstractColumn {
  
      /**
       * Constructor IntegerColumn
       *
       *
       * @param name
       *
       */
      public IntegerColumn(String name) {
          super(name,"integer",Integer.class.getName());
      }
  
      public void test(Object obj) throws ValidationException {
          try {
              int i = Integer.parseInt(obj.toString());
          } catch (NumberFormatException nfe) {
              throw new ValidationException("Integer " + mName + " is not a valid number (" + obj + ")");
          }
      }
  }
  
  
  

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