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/functions/impl AbstractTemporalStringFunction.java DayHourMinuteSecondTemporalFunction.java HourMinuteSecondTemporalFunction.java HourMinuteTemporalFunction.java MinuteSecondTemporalFunction.java YearMonthTemporalFunction.java CurrentDateTemporalFunction.java CurrentTimeTemporalFunction.java CurrentTimestampTemporalFunction.java
Date Fri, 04 Jan 2002 21:53:50 GMT
hammant     02/01/04 13:53:50

  Modified:    apps/db  build.xml
               apps/db/src/java/org/apache/avalon/db/basic/actions
                        BasicCreateAggregateView.java BasicCreateTable.java
                        BasicCreateView.java
               apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql
                        SelectColumnHelper.java
               apps/db/src/java/org/apache/avalon/db/functions/impl
                        CurrentDateTemporalFunction.java
                        CurrentTimeTemporalFunction.java
                        CurrentTimestampTemporalFunction.java
  Added:       apps/db/src/java/org/apache/avalon/db/functions/impl
                        AbstractTemporalStringFunction.java
                        DayHourMinuteSecondTemporalFunction.java
                        HourMinuteSecondTemporalFunction.java
                        HourMinuteTemporalFunction.java
                        MinuteSecondTemporalFunction.java
                        YearMonthTemporalFunction.java
  Log:
  More Temporal functions from Larry McCay
  
  Revision  Changes    Path
  1.29      +9 -0      jakarta-avalon-cornerstone/apps/db/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/build.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- build.xml	30 Dec 2001 09:13:56 -0000	1.28
  +++ build.xml	4 Jan 2002 21:53:49 -0000	1.29
  @@ -461,6 +461,15 @@
       </java>  
     </target>
   
  +  <target name="testl3" depends="main">
  +    <property name="script" location="src/scripts/lxsql/Test3.script"/>
  +    <java classname="org.apache.avalon.db.test.Tester" fork="true">          
  +      <arg value="lxsql"/>    
  +      <arg value="${script}"/>
  +      <classpath refid="test.path"/>
  +    </java>  
  +  </target>
  +
     <target name="tests1" depends="main">
       <property name="script" location="src/scripts/sql/Test1.script"/>
       <java classname="org.apache.avalon.db.test.Tester" fork="true">          
  
  
  
  1.6       +2 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateAggregateView.java
  
  Index: BasicCreateAggregateView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateAggregateView.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BasicCreateAggregateView.java	1 Dec 2001 17:50:26 -0000	1.5
  +++ BasicCreateAggregateView.java	4 Jan 2002 21:53:49 -0000	1.6
  @@ -18,11 +18,11 @@
   
   
   /**
  - * Class BCELCreateTable
  + * Class BasicCreateAggregateView
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public class BasicCreateAggregateView extends BasicCreateQueryable implements CreateAggregateView
{
   
  
  
  
  1.14      +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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- BasicCreateTable.java	18 Nov 2001 20:47:20 -0000	1.13
  +++ BasicCreateTable.java	4 Jan 2002 21:53:49 -0000	1.14
  @@ -21,7 +21,7 @@
   
   
   /**
  - * Class BCELCreateTable
  + * Class BasicCreateTable
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  
  
  
  1.17      +2 -2      jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateView.java
  
  Index: BasicCreateView.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/actions/BasicCreateView.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- BasicCreateView.java	14 Dec 2001 21:31:52 -0000	1.16
  +++ BasicCreateView.java	4 Jan 2002 21:53:49 -0000	1.17
  @@ -25,11 +25,11 @@
   
   
   /**
  - * Class BCELCreateTable
  + * Class BasicCreateView
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.16 $
  + * @version $Revision: 1.17 $
    */
   public class BasicCreateView extends BasicCreateQueryable implements CreateView {
   
  
  
  
  1.7       +17 -1     jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/SelectColumnHelper.java
  
  Index: SelectColumnHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/basic/handlers/lxsql/SelectColumnHelper.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SelectColumnHelper.java	2 Jan 2002 20:03:33 -0000	1.6
  +++ SelectColumnHelper.java	4 Jan 2002 21:53:49 -0000	1.7
  @@ -41,6 +41,12 @@
   import org.apache.avalon.db.functions.impl.LeadingTrimStringFunction;
   import org.apache.avalon.db.functions.impl.TrailingTrimStringFunction;
   import org.apache.avalon.db.functions.impl.CurrentDateTemporalFunction;
  +import org.apache.avalon.db.functions.impl.MinuteSecondTemporalFunction;
  +import org.apache.avalon.db.functions.impl.HourMinuteTemporalFunction;
  +import org.apache.avalon.db.functions.impl.HourMinuteSecondTemporalFunction;
  +import org.apache.avalon.db.functions.impl.DayHourMinuteSecondTemporalFunction;
  +import org.apache.avalon.db.functions.impl.YearMonthTemporalFunction;
  +//>>>>>>> 1.6
   import org.apache.avalon.db.functions.StringFunction;
   import org.apache.avalon.db.functions.NumericFunction;
   import org.apache.avalon.db.functions.Function;
  @@ -59,7 +65,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
   public class SelectColumnHelper {
   
  @@ -115,6 +121,16 @@
               return getColumnFromFunction(queryable, elem, new MinuteIntegerFunction(),
colHldr);
           } else if (nodeName.equals("month")) {
               return getColumnFromFunction(queryable, elem, new MonthIntegerFunction(), colHldr);
  +        } else if (nodeName.equals("yearmonth")) {
  +            return getColumnFromFunction(queryable, elem, new YearMonthTemporalFunction(),
colHldr);
  +        } else if (nodeName.equals("daysecond")) {
  +            return getColumnFromFunction(queryable, elem, new DayHourMinuteSecondTemporalFunction(),
colHldr);
  +        } else if (nodeName.equals("hoursecond")) {
  +            return getColumnFromFunction(queryable, elem, new HourMinuteSecondTemporalFunction(),
colHldr);
  +        } else if (nodeName.equals("hourminute")) {
  +            return getColumnFromFunction(queryable, elem, new HourMinuteTemporalFunction(),
colHldr);
  +        } else if (nodeName.equals("minutesecond")) {
  +            return getColumnFromFunction(queryable, elem, new MinuteSecondTemporalFunction(),
colHldr);
           } else if (nodeName.equals("second")) {
               return getColumnFromFunction(queryable, elem, new SecondIntegerFunction(),
colHldr);
           } else if (nodeName.equals("year")) {
  
  
  
  1.2       +49 -22    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentDateTemporalFunction.java
  
  Index: CurrentDateTemporalFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentDateTemporalFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CurrentDateTemporalFunction.java	2 Jan 2002 20:03:34 -0000	1.1
  +++ CurrentDateTemporalFunction.java	4 Jan 2002 21:53:50 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -7,53 +8,79 @@
    */
   package org.apache.avalon.db.functions.impl;
   
  +
  +
   import org.apache.avalon.db.data.Row;
   import org.apache.avalon.db.data.types.StringColumn;
   import org.apache.avalon.db.functions.DateFunction;
   
   import java.sql.Date;
   
  +
   /**
    * Class CurrentDateTemporalFunction
    *
    * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class CurrentDateTemporalFunction extends AbstractFunction implements DateFunction
{
   
       private Date mDate;
   
  +    /**
  +     * Constructor CurrentDateTemporalFunction
  +     *
  +     *
  +     */
       public CurrentDateTemporalFunction() {
           mDate = new Date(System.currentTimeMillis());
       }
   
  +    /**
  +     * Method getValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Object getValue(Row row) {
           return mDate;
       }
   
  +    /**
  +     * Method getDateValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Date getDateValue(Row row) {
           return mDate;
       }
   
  -   /**
  -    * Method getMinCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMinCols() {
  -       return 0;
  -   }
  -
  -   /**
  -    * Method getMaxCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMaxCols() {
  -       return 0;
  -   }
  +    /**
  +     * Method getMinCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMinCols() {
  +        return 0;
  +    }
  +
  +    /**
  +     * Method getMaxCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMaxCols() {
  +        return 0;
  +    }
   }
  
  
  
  1.2       +49 -22    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentTimeTemporalFunction.java
  
  Index: CurrentTimeTemporalFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentTimeTemporalFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CurrentTimeTemporalFunction.java	2 Jan 2002 20:03:34 -0000	1.1
  +++ CurrentTimeTemporalFunction.java	4 Jan 2002 21:53:50 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -7,53 +8,79 @@
    */
   package org.apache.avalon.db.functions.impl;
   
  +
  +
   import org.apache.avalon.db.data.Row;
   import org.apache.avalon.db.data.types.StringColumn;
   import org.apache.avalon.db.functions.TimeFunction;
   
   import java.sql.Time;
   
  +
   /**
    * Class CurrentTimeTemporalFunction
    *
    * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class CurrentTimeTemporalFunction extends AbstractFunction implements TimeFunction
{
   
       private Time mTime;
   
  +    /**
  +     * Constructor CurrentTimeTemporalFunction
  +     *
  +     *
  +     */
       public CurrentTimeTemporalFunction() {
           mTime = new Time(System.currentTimeMillis());
       }
   
  +    /**
  +     * Method getValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Object getValue(Row row) {
           return mTime;
       }
   
  +    /**
  +     * Method getTimeValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Time getTimeValue(Row row) {
           return mTime;
       }
   
  -   /**
  -    * Method getMinCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMinCols() {
  -       return 0;
  -   }
  -
  -   /**
  -    * Method getMaxCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMaxCols() {
  -       return 0;
  -   }
  +    /**
  +     * Method getMinCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMinCols() {
  +        return 0;
  +    }
  +
  +    /**
  +     * Method getMaxCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMaxCols() {
  +        return 0;
  +    }
   }
  
  
  
  1.2       +51 -23    jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentTimestampTemporalFunction.java
  
  Index: CurrentTimestampTemporalFunction.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/CurrentTimestampTemporalFunction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CurrentTimestampTemporalFunction.java	2 Jan 2002 20:03:34 -0000	1.1
  +++ CurrentTimestampTemporalFunction.java	4 Jan 2002 21:53:50 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -7,53 +8,80 @@
    */
   package org.apache.avalon.db.functions.impl;
   
  +
  +
   import org.apache.avalon.db.data.Row;
   import org.apache.avalon.db.data.types.StringColumn;
   import org.apache.avalon.db.functions.TimestampFunction;
   
   import java.sql.Timestamp;
   
  +
   /**
    * Class CurrentTimestampTemporalFunction
    *
    * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public class CurrentTimestampTemporalFunction extends AbstractFunction implements TimestampFunction
{
  +public class CurrentTimestampTemporalFunction extends AbstractFunction
  +        implements TimestampFunction {
   
       private Timestamp mTimestamp;
   
  +    /**
  +     * Constructor CurrentTimestampTemporalFunction
  +     *
  +     *
  +     */
       public CurrentTimestampTemporalFunction() {
           mTimestamp = new Timestamp(System.currentTimeMillis());
       }
   
  +    /**
  +     * Method getValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Object getValue(Row row) {
           return mTimestamp;
       }
   
  +    /**
  +     * Method getTimestampValue
  +     *
  +     *
  +     * @param row
  +     *
  +     * @return
  +     *
  +     */
       public Timestamp getTimestampValue(Row row) {
           return mTimestamp;
       }
   
  -   /**
  -    * Method getMinCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMinCols() {
  -       return 0;
  -   }
  -
  -   /**
  -    * Method getMaxCols
  -    *
  -    *
  -    * @return
  -    *
  -    */
  -   public int getMaxCols() {
  -       return 0;
  -   }
  +    /**
  +     * Method getMinCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMinCols() {
  +        return 0;
  +    }
  +
  +    /**
  +     * Method getMaxCols
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getMaxCols() {
  +        return 0;
  +    }
   }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/AbstractTemporalStringFunction.java
  
  Index: AbstractTemporalStringFunction.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.functions.StringFunction;
  
  import java.util.GregorianCalendar;
  
  /**
   * Class AbstractTemporalIntegerFunction
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public abstract class AbstractTemporalStringFunction extends AbstractStringFunction implements
StringFunction {
  
      private final int mDesiredLength;
      protected final GregorianCalendar mGregorianCalendar = new GregorianCalendar();
  
      public AbstractTemporalStringFunction(int desiredLength) {
          mDesiredLength = desiredLength;
      }
  
  
      public int getMinCols() {
          return 1;
      }
  
      public int getMaxCols() {
          return 1;
      }
  
     protected String padInterval( String interval, int padTo )
     {
        if( interval.length() < padTo )
        {
           for( int i = 0; i < 1; i++ )
           {
              interval = "0" + interval;
           }
        }
        return interval;
     }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/DayHourMinuteSecondTemporalFunction.java
  
  Index: DayHourMinuteSecondTemporalFunction.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;
  import org.apache.avalon.db.data.types.TemporalColumn;
  
  import java.util.Date;
  
  import java.util.Calendar;
  
  
  /**
   * Class CurrentDateTemporalFunction
   *
   * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
   * @version $Revision: 1.1 $
   */
  public class DayHourMinuteSecondTemporalFunction extends AbstractTemporalStringFunction
{
  
      /**
       * Constructor DayHourMinuteSecondTemporalFunction
       *
       *
       */
      public DayHourMinuteSecondTemporalFunction() {
          super(11);
      }
  
      /**
       * Method getMaxLength
       *
       *
       * @return
       *
       */
      public int getMaxLength() {
          return 11;
      }
  
      /**
       * Method getStringValue
       *
       *
       * @param row
       *
       * @return
       *
       */
      public String getStringValue(Row row) {
  
          TemporalColumn tc = (TemporalColumn) mColumns[0];
          Date date = (Date) tc.getValue(row);
  
          mGregorianCalendar.setTime(date);
  
          String days = Integer.toString(mGregorianCalendar.get(Calendar.DATE));
  
          days = padInterval(days, 2);
  
          String hours = Integer.toString(mGregorianCalendar.get(Calendar.HOUR));
  
          hours = padInterval(hours, 2);
  
          String minutes = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          minutes = padInterval(minutes, 2);
  
          String seconds = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          seconds = padInterval(seconds, 2);
  
          StringBuffer value =
              new StringBuffer(days).append(" ").append(hours).append(":").append(minutes)
                  .append(":").append(seconds);
  
          return value.toString();
      }
  
      /**
       * Method getMinCols
       *
       *
       * @return
       *
       */
      public int getMinCols() {
          return 1;
      }
  
      /**
       * Method getMaxCols
       *
       *
       * @return
       *
       */
      public int getMaxCols() {
          return 1;
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/HourMinuteSecondTemporalFunction.java
  
  Index: HourMinuteSecondTemporalFunction.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;
  import org.apache.avalon.db.data.types.TemporalColumn;
  
  import java.util.Date;
  
  import java.util.Calendar;
  
  
  /**
   * Class CurrentDateTemporalFunction
   *
   * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
   * @version $Revision: 1.1 $
   */
  public class HourMinuteSecondTemporalFunction extends AbstractTemporalStringFunction {
  
      /**
       * Constructor HourMinuteSecondTemporalFunction
       *
       *
       */
      public HourMinuteSecondTemporalFunction() {
          super(8);
      }
  
      /**
       * Method getMaxLength
       *
       *
       * @return
       *
       */
      public int getMaxLength() {
          return 5;
      }
  
      /**
       * Method getStringValue
       *
       *
       * @param row
       *
       * @return
       *
       */
      public String getStringValue(Row row) {
  
          TemporalColumn tc = (TemporalColumn) mColumns[0];
          Date date = (Date) tc.getValue(row);
  
          mGregorianCalendar.setTime(date);
  
          String hours = Integer.toString(mGregorianCalendar.get(Calendar.HOUR));
  
          hours = padInterval(hours, 2);
  
          String minutes = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          minutes = padInterval(minutes, 2);
  
          String seconds = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          seconds = padInterval(seconds, 2);
  
          StringBuffer value =
              new StringBuffer(hours).append(":").append(minutes).append(":").append(seconds);
  
          return value.toString();
      }
  
      /**
       * Method getMinCols
       *
       *
       * @return
       *
       */
      public int getMinCols() {
          return 1;
      }
  
      /**
       * Method getMaxCols
       *
       *
       * @return
       *
       */
      public int getMaxCols() {
          return 1;
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/HourMinuteTemporalFunction.java
  
  Index: HourMinuteTemporalFunction.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;
  import org.apache.avalon.db.data.types.TemporalColumn;
  
  import java.util.Date;
  
  import java.util.Calendar;
  
  
  /**
   * Class CurrentDateTemporalFunction
   *
   * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
   * @version $Revision: 1.1 $
   */
  public class HourMinuteTemporalFunction extends AbstractTemporalStringFunction {
  
      /**
       * Constructor HourMinuteTemporalFunction
       *
       *
       */
      public HourMinuteTemporalFunction() {
          super(8);
      }
  
      /**
       * Method getMaxLength
       *
       *
       * @return
       *
       */
      public int getMaxLength() {
          return 5;
      }
  
      /**
       * Method getStringValue
       *
       *
       * @param row
       *
       * @return
       *
       */
      public String getStringValue(Row row) {
  
          TemporalColumn tc = (TemporalColumn) mColumns[0];
          Date date = (Date) tc.getValue(row);
  
          mGregorianCalendar.setTime(date);
  
          String hours = Integer.toString(mGregorianCalendar.get(Calendar.HOUR));
  
          hours = padInterval(hours, 2);
  
          String minutes = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          minutes = padInterval(minutes, 2);
  
          StringBuffer value = new StringBuffer(hours).append(":").append(minutes);
  
          return value.toString();
      }
  
      /**
       * Method getMinCols
       *
       *
       * @return
       *
       */
      public int getMinCols() {
          return 1;
      }
  
      /**
       * Method getMaxCols
       *
       *
       * @return
       *
       */
      public int getMaxCols() {
          return 1;
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/MinuteSecondTemporalFunction.java
  
  Index: MinuteSecondTemporalFunction.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;
  import org.apache.avalon.db.data.types.TemporalColumn;
  
  import java.util.Date;
  
  import java.util.Calendar;
  
  
  /**
   * Class CurrentDateTemporalFunction
   *
   * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
   * @version $Revision: 1.1 $
   */
  public class MinuteSecondTemporalFunction extends AbstractTemporalStringFunction {
  
      /**
       * Constructor MinuteSecondTemporalFunction
       *
       *
       */
      public MinuteSecondTemporalFunction() {
          super(5);
      }
  
      /**
       * Method getMaxLength
       *
       *
       * @return
       *
       */
      public int getMaxLength() {
          return 5;
      }
  
      /**
       * Method getStringValue
       *
       *
       * @param row
       *
       * @return
       *
       */
      public String getStringValue(Row row) {
  
          TemporalColumn tc = (TemporalColumn) mColumns[0];
          Date date = (Date) tc.getValue(row);
  
          mGregorianCalendar.setTime(date);
  
          String minutes = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          minutes = padInterval(minutes, 2);
  
          String seconds = Integer.toString(mGregorianCalendar.get(Calendar.MINUTE));
  
          seconds = padInterval(seconds, 2);
  
          StringBuffer value = new StringBuffer(minutes).append(":").append(seconds);
  
          return value.toString();
      }
  
      /**
       * Method getMinCols
       *
       *
       * @return
       *
       */
      public int getMinCols() {
          return 1;
      }
  
      /**
       * Method getMaxCols
       *
       *
       * @return
       *
       */
      public int getMaxCols() {
          return 1;
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/functions/impl/YearMonthTemporalFunction.java
  
  Index: YearMonthTemporalFunction.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;
  import org.apache.avalon.db.data.types.TemporalColumn;
  
  import java.util.Date;
  
  import java.util.Calendar;
  
  
  /**
   * Class CurrentDateTemporalFunction
   *
   * @author Larry McCay <a href="mailto:lawrence_mccay-iii@hp.com">lawrence_mccay-iii@hp.com</a>
   * @version $Revision: 1.1 $
   */
  public class YearMonthTemporalFunction extends AbstractTemporalStringFunction {
  
      /**
       * Constructor YearMonthTemporalFunction
       *
       *
       */
      public YearMonthTemporalFunction() {
          super(6);
      }
  
      /**
       * Method getMaxLength
       *
       *
       * @return
       *
       */
      public int getMaxLength() {
          return 6;
      }
  
      /**
       * Method getStringValue
       *
       *
       * @param row
       *
       * @return
       *
       */
      public String getStringValue(Row row) {
  
          TemporalColumn tc = (TemporalColumn) mColumns[0];
          Date date = (Date) tc.getValue(row);
  
          mGregorianCalendar.setTime(date);
  
          String years = Integer.toString(mGregorianCalendar.get(Calendar.YEAR));
  
          years = padInterval(years, 4);
  
          int mth = mGregorianCalendar.get(Calendar.MONTH) + 1;
          String months = Integer.toString(mth);
  
          months = padInterval(months, 2);
  
          StringBuffer value = new StringBuffer(years).append("-").append(months);
  
          return value.toString();
      }
  
      /**
       * Method getMinCols
       *
       *
       * @return
       *
       */
      public int getMinCols() {
          return 1;
      }
  
      /**
       * Method getMaxCols
       *
       *
       * @return
       *
       */
      public int getMaxCols() {
          return 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