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/14 19:35:31 UTC

cvs commit: jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl ConcatFunction.java AbstractFunction.java

hammant     01/11/14 10:35:31

  Modified:    apps/db/src/java/org/apache/avalon/db/functions
                        Function.java
               apps/db/src/java/org/apache/avalon/db/functions/impl
                        AbstractFunction.java
  Added:       apps/db/src/java/org/apache/avalon/db/data/impl
                        ConcatVarCharColumn.java
               apps/db/src/java/org/apache/avalon/db/functions/impl
                        ConcatFunction.java
  Log:
  Concat and StringConst function
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/ConcatVarCharColumn.java
  
  Index: ConcatVarCharColumn.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.Column;
  import org.apache.avalon.db.data.Row;
  import org.apache.avalon.db.functions.Function;
  import org.apache.avalon.db.functions.impl.ConcatFunction;
  import org.apache.avalon.db.actions.ActionException;
  
  
  /**
   * Class ConcatVarCharColumn
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ConcatVarCharColumn extends AbstractColumn {
  
      private int mMaxLength;
      private Column[] mDependantColumns;
      ConcatFunction mConcatFunction;
  
      /**
       * Constructor ConcatVarCharColumn
       *
       *
       * @param columns
       * @param name
       * @param maxLength
       *
       */
      public ConcatVarCharColumn(Column[] columns, String name, int maxLength) throws ActionException {
          // TODO other constructors a) without maxsize, b) with generated name
          super(name,"varchar",String.class.getName());
          mMaxLength = maxLength;
          mConcatFunction = new ConcatFunction();
          mConcatFunction.initialize(columns);
      }
  
      public Object getValue(Row row) {
          // TODO should trim to size?
          return mConcatFunction.getValue(row);
      }
  
  
      public void test(Object obj) throws ValidationException {
          throw new ValidationException("ConcatVarCharColumn is not settable");
      }
  
      public Object convertFromString(String str) throws ValidationException {
          test(str);
          return str;
      }
  }
  
  
  
  1.5       +4 -3      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/Function.java
  
  Index: Function.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/Function.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Function.java	2001/11/14 11:40:51	1.4
  +++ Function.java	2001/11/14 18:35:31	1.5
  @@ -8,15 +8,16 @@
   package org.apache.avalon.db.functions;
   
   import org.apache.avalon.db.actions.ActionException;
  +import org.apache.avalon.db.data.Column;
   import org.apache.avalon.db.data.Row;
   
   /**
    * Interface Function
    *
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @version * $Revision: 1.4 $
  + * @version * $Revision: 1.5 $
    */
   public interface Function {
  -    void initialize(String[] columns) throws ActionException;
  -    Object evaluate(Row row) throws ActionException;
  +    void initialize(Column[] columns) throws ActionException;
  +    Object getValue(Row row);
   }
  
  
  
  1.2       +9 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractFunction.java
  
  Index: AbstractFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractFunction.java	2001/11/13 18:10:20	1.1
  +++ AbstractFunction.java	2001/11/14 18:35:31	1.2
  @@ -7,14 +7,21 @@
    */
   package org.apache.avalon.db.functions.impl;
   
  +import org.apache.avalon.db.functions.Function;
  +import org.apache.avalon.db.data.Column;
  +import org.apache.avalon.db.actions.ActionException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   
   /**
    * Class AbstractFunction
    *
    * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
  - * @version $Revision: 1.1 $
  + * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  + * @version $Revision: 1.2 $
    */
  -public class AbstractFunction extends AbstractLogEnabled {
  -
  +public abstract class AbstractFunction extends AbstractLogEnabled implements Function {
  +    protected Column[] mColumns;
  +    public void initialize(Column[] columns) throws ActionException {
  +        mColumns = columns;
  +    }
   }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/ConcatFunction.java
  
  Index: ConcatFunction.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.functions.impl;
  
  import org.apache.avalon.db.data.Row;
  
  
  /**
   * Class ConcatFunction
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class ConcatFunction extends AbstractFunction {
      public Object getValue(Row row) {
          String retVal = "";
          for (int i = 0; i < mColumns.length; i++) {
              retVal += mColumns[i].getValue(row);
          }
          return retVal;
      }
  }
  
  
  

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