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

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

froehlich    01/11/13 04:32:54

  Added:       apps/db/src/java/org/apache/avalon/db/data/impl
                        DecimalColumn.java
  Log:
  
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-cornerstone/apps/db/src/java/org/apache/avalon/db/data/impl/DecimalColumn.java
  
  Index: DecimalColumn.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 java.math.BigDecimal;
  
  /**
   * Class DecimalColumn
   *
   * @author Gerhard Froehlich <a href="mailto:g-froehlich@gmx.de">g-froehlich@gmx.de</a>
   * @version $Revision: 1.1 $
   */
  public class DecimalColumn extends AbstractColumn {
  
      /**
       * Constructor DecimalColumn
       * @param name
       */
      public DecimalColumn(String name) {
          super(name,"decimal",BigDecimal.class.getName());
      }
  
      public void test(Object obj) throws ValidationException {
          try {
              BigDecimal bd = new BigDecimal(obj.toString());
          } catch (NumberFormatException nfe) {
              throw new ValidationException("Decimal " + mName + " is not a valid number (" + obj + ")");
          }
      }
  
      public Object convertFromString(String str) throws ValidationException {
          try {
              return new BigDecimal(str);
          } catch (NumberFormatException nfe) {
              throw new ValidationException("Decimal " + mName + " is not a valid number (" + str + ")");
          }
      }
  }
  
  
  

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