avalon-dev 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 AbstractColumn.java VarCharColumn.java DefaultColumn.java
Date Mon, 12 Nov 2001 23:09:57 GMT
hammant     01/11/12 15:09:57

  Modified:    apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicCreateQueryable.java BasicCreateTable.java
               apps/db/src/java/org/apache/avalon/db/basic/parser
                        BasicLXSQLParser.java
               apps/db/src/java/org/apache/avalon/db/bcel/parser
                        BCELHelper.java BCELLXSQLParser.java
                        BCELSQLParser.java
               apps/db/src/java/org/apache/avalon/db/data Column.java
  Added:       apps/db/src/java/org/apache/avalon/db/data/impl
                        AbstractColumn.java VarCharColumn.java
  Removed:     apps/db/src/java/org/apache/avalon/db/data/impl
                        DefaultColumn.java
  Log:
  start of different column types
  
  Revision  Changes    Path
  1.2       +7 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicCreateQueryable.java	2001/11/11 13:03:45	1.1
  +++ BasicCreateQueryable.java	2001/11/12 23:09:56	1.2
  @@ -13,7 +13,8 @@
   import org.apache.avalon.db.actions.impl.AbstractAction;
   import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.Table;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
  +import org.apache.avalon.db.data.impl.VarCharColumn;
   import org.apache.avalon.db.basic.data.BasicTable;
   import org.apache.avalon.db.services.DatabasePersistor;
   import org.w3c.dom.Element;
  @@ -28,7 +29,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class BasicCreateQueryable extends AbstractAction implements CreateTable
{
   
  @@ -53,7 +54,11 @@
                           String fieldName = columnNode.getAttributes().getNamedItem("name").getNodeValue();
                           String sqlFieldType = columnNode.getAttributes().getNamedItem("type").getNodeValue();
                           String fieldType = getJavaType(sqlFieldType).toString();
  -                        Column column = new DefaultColumn(fieldName, sqlFieldType, fieldType);
  +                        Column column = null;
  +                        if (sqlFieldType.equals("varchar")) {
  +                            int maxLength = Integer.parseInt(columnNode.getAttributes().getNamedItem("max").getNodeValue());
  +                            column= new VarCharColumn(fieldName, maxLength);
  +                        }
                           columns.add(column);
                       } else {
                           // TODO  There should be no other element types inside <columns>
  
  
  
  1.8       +1 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateTable.java
  
  Index: BasicCreateTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateTable.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BasicCreateTable.java	2001/11/11 21:44:47	1.7
  +++ BasicCreateTable.java	2001/11/12 23:09:56	1.8
  @@ -13,7 +13,7 @@
   import org.apache.avalon.db.actions.impl.AbstractAction;
   import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.Table;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.db.basic.data.BasicTable;
   import org.apache.avalon.db.services.DatabasePersistor;
   import org.w3c.dom.Element;
  
  
  
  1.11      +1 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicLXSQLParser.java
  
  Index: BasicLXSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/parser/BasicLXSQLParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- BasicLXSQLParser.java	2001/11/11 21:44:47	1.10
  +++ BasicLXSQLParser.java	2001/11/12 23:09:56	1.11
  @@ -21,7 +21,7 @@
   import org.apache.avalon.db.transport.CreateViewRequest;
   import org.apache.avalon.db.transport.CreateIndexRequest;
   import org.apache.avalon.db.data.Column;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.db.bcel.actions.AbstractBCELAction;
   import org.apache.avalon.db.basic.actions.BasicCreateTable;
   import org.apache.avalon.db.basic.actions.BasicInsert;
  
  
  
  1.3       +1 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELHelper.java
  
  Index: BCELHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELHelper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BCELHelper.java	2001/11/10 21:45:03	1.2
  +++ BCELHelper.java	2001/11/12 23:09:56	1.3
  @@ -25,7 +25,7 @@
   import org.apache.avalon.db.bcel.data.BCELTable;
   import org.apache.avalon.db.data.Table;
   import org.apache.avalon.db.data.Column;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.phoenix.Block;
   import org.apache.avalon.phoenix.BlockContext;
   import org.apache.avalon.framework.context.Contextualizable;
  
  
  
  1.4       +2 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELLXSQLParser.java
  
  Index: BCELLXSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELLXSQLParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BCELLXSQLParser.java	2001/11/11 21:44:47	1.3
  +++ BCELLXSQLParser.java	2001/11/12 23:09:56	1.4
  @@ -24,7 +24,7 @@
   import org.apache.avalon.db.transport.InsertRequest;
   import org.apache.avalon.db.transport.CreateViewRequest;
   import org.apache.avalon.db.data.Column;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.bcel.generic.InstructionFactory;
  @@ -124,7 +124,7 @@
                           String fieldName = columnNode.getAttributes().getNamedItem("name").getNodeValue();
                           String sqlFieldType = columnNode.getAttributes().getNamedItem("type").getNodeValue();
                           Type fieldType = bcelHelper.getType(sqlFieldType);
  -                        Column column = new DefaultColumn(fieldName, sqlFieldType, fieldType.toString());
  +                        Column column = null; // TODO new AbstractColumn(fieldName, sqlFieldType,
fieldType.toString());
   
                           columns.add(column);
                           bcelHelper.createFieldAndSetter(cp, cg, factory, fieldType, fieldName,
tableName);
  
  
  
  1.10      +3 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELSQLParser.java
  
  Index: BCELSQLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/bcel/parser/BCELSQLParser.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- BCELSQLParser.java	2001/11/11 21:44:47	1.9
  +++ BCELSQLParser.java	2001/11/12 23:09:56	1.10
  @@ -19,7 +19,7 @@
   import org.apache.avalon.db.transport.InsertRequest;
   import org.apache.avalon.db.transport.CreateViewRequest;
   import org.apache.avalon.db.utils.StringUtils;
  -import org.apache.avalon.db.data.impl.DefaultColumn;
  +import org.apache.avalon.db.data.impl.AbstractColumn;
   import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.Table;
   import org.apache.avalon.db.bcel.actions.BCELCreateTable;
  @@ -40,7 +40,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    */
   public class BCELSQLParser extends AbstractSQLParser {
   
  @@ -102,7 +102,7 @@
               String fieldName = st2.nextToken();
               String sqlFieldType = st2.nextToken();
               Type fieldType = bcelHelper.getType(sqlFieldType);
  -            Column column = new DefaultColumn(fieldName, sqlFieldType, fieldType.toString());
  +            Column column = null; // TODO new AbstractColumn(fieldName, sqlFieldType, fieldType.toString());
   
               columns.add(column);
               bcelHelper.createFieldAndSetter(cp, cg, factory, fieldType, fieldName, tableName);
  
  
  
  1.6       +4 -1      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/Column.java
  
  Index: Column.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/Column.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Column.java	2001/11/09 16:36:44	1.5
  +++ Column.java	2001/11/12 23:09:56	1.6
  @@ -14,9 +14,12 @@
    *
    * @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.5 $
  + * @version * $Revision: 1.6 $
    */
   public interface Column extends Nameable {
  +
  +    void test(Object obj) throws ValidationException;
  +
       String getSQLType();
       String getJavaType();
       int getColumnDisplaySize();
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/AbstractColumn.java
  
  Index: AbstractColumn.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.Table;
  import org.apache.avalon.db.data.Queryable;
  import org.apache.avalon.db.data.Column;
  
  
  /**
   * Class AbstractColumn
   *
   *
   * @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 $
   */
  public abstract class AbstractColumn implements Column {
  
      protected String mName;
      protected String mSqlType;
      protected String mJavaType;
  
      /**
       * Constructor AbstractColumn
       *
       *
       * @param name
       * @param sqlType
       * @param javaType
       *
       */
      public AbstractColumn(String name, String sqlType, String javaType) {
  
          mName = name;
          mSqlType = sqlType;
          mJavaType = javaType;
      }
  
      /**
       * Method getSQLType
       *
       *
       * @return
       *
       */
      public String getSQLType() {
          return mSqlType;
      }
  
      /**
       * Method getName
       *
       *
       * @return
       *
       */
      public String getName() {
          return mName;
      }
  
      /**
       * Method getJavaType
       *
       *
       * @return
       *
       */
      public String getJavaType() {
          return mJavaType;
      }
  
      /** methods for the metadata */
      public int getColumnDisplaySize() {
          //ToDo: implementation
          return 0;
      }
  
      public String getColumnLabel() {
          return mName;
      }
  
      public String getColumnName() {
          return mName;
      }
  
      public int getColumnType() {
          //ToDo: implementation
          return 0;
      }
  
      public String getColumnTypeName() {
          return mSqlType;
      }
  
      public int getPrecision() {
          //ToDo: implementation
          return 0;
      }
  
      public int getScale() {
          //ToDo: implementation
          return 0;
      }
  
      public String getSchemaName() {
          //ToDo: implementation
          return null;
      }
  
      public String getCatalogName() {
          //ToDo: implementation
          return null;
      }
  
      public String getColumnClassName() {
          //ToDo: implementation
          return null;
      }
  
      public String getTableName() {
          //ToDo: implementation
          return null;
      }
  
      public boolean isAutoIncrement() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isCaseSensitive() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isCurrency() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isDefinitelyWritable() {
          //ToDo: implementation
          return false;
      }
  
      public int isNullable() {
          //ToDo: implementation
          return 0;
      }
  
      public boolean isReadOnly() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isSearchable() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isSigned() {
          //ToDo: implementation
          return false;
      }
  
      public boolean isWritable() {
          //ToDo: implementation
          return false;
       }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/VarCharColumn.java
  
  Index: VarCharColumn.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.Table;
  import org.apache.avalon.db.data.Queryable;
  import org.apache.avalon.db.data.Column;
  import org.apache.avalon.db.data.ValidationException;
  
  
  /**
   * Class VarCharColumn
   *
   *
   * @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 $
   */
  public class VarCharColumn extends AbstractColumn {
  
      private int mMaxLength;
  
      /**
       * Constructor VarCharColumn
       *
       *
       * @param name
       * @param maxLength
       * @param javaType
       *
       */
      public VarCharColumn(String name, int maxLength) {
          super(name,"varchar",String.class.getName());
          mMaxLength = maxLength;
      }
  
      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());
          }
      }
  
  
  
  }
  
  
  

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


Mime
View raw message