Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 96   Methods: 12
NCLOC: 64   Classes: 1
This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
AbstractDecimalData.java 25% 37% 50% 38,3%
 1   
 /*
 2   
  * JBind
 3   
  *
 4   
  * Copyright (c) by Stefan Wachter. All rights reserved.
 5   
  *
 6   
  * Usage, modification, and redistribution is subject to license terms that are
 7   
  * available at 'http://www.jbind.org'. The JBind license is like the
 8   
  * 'Apache Software License V 1.1'.
 9   
  */
 10   
 package org.jbind.xml.instance.data;
 11   
 
 12   
 import org.jbind.xml.core.data.IAnyTypeData;
 13   
 import org.jbind.xml.core.data.IDecimalData;
 14   
 import org.jbind.xml.core.data.IHasOrder;
 15   
 import org.jbind.xml.msg.XmlException;
 16   
 
 17   
 public abstract class AbstractDecimalData extends AbstractSimpleData implements IDecimalData {
 18   
 
 19  369
   protected void doAccept(String aString) throws XmlException {
 20  369
     super.doAccept(aString);
 21   
   }
 22   
 
 23  81
   public final boolean simpleStorageValueEquals(IAnyTypeData aData) {
 24  81
     return (aData instanceof IDecimalData) && (0 == compareDecimal_((IDecimalData)aData));
 25   
   }
 26   
 
 27  86
   public final int simpleStorageValueHashCode() {
 28  86
     return getCanonicalForm_().hashCode();
 29   
   }
 30   
 
 31  0
   public boolean isLess(IHasOrder aData) {
 32  0
     return compareDecimal_((IDecimalData)aData) < 0;
 33   
   }
 34   
 
 35  1
   public boolean isLessOrEqual(IHasOrder aData) {
 36  1
     return compareDecimal_((IDecimalData)aData) <= 0;
 37   
   }
 38   
 
 39  0
   public boolean isEqual(IHasOrder aData) {
 40  0
     return compareDecimal_((IDecimalData)aData) == 0;
 41   
   }
 42   
 
 43  0
   public boolean isGreaterOrEqual(IHasOrder aData) {
 44  0
     return compareDecimal_((IDecimalData)aData) >= 0;
 45   
   }
 46   
 
 47  94
   public boolean isGreater(IHasOrder aData) {
 48  94
     return compareDecimal_((IDecimalData)aData) > 0;
 49   
   }
 50   
 
 51  176
   public final int compareDecimal_(IDecimalData aData) {
 52  176
     int res;
 53  176
     if (getType_().isBaseType(aData.getType_())) {
 54  172
       res = compareSubTypeData_(aData);
 55   
     } else {
 56  4
       res = aData.compareSubTypeData_(this);
 57   
     }
 58  176
     return res;
 59   
   }
 60   
 
 61  0
   public final int getNbDigits() {
 62  0
     return getNbDigits(getCanonicalForm_());
 63   
   }
 64   
 
 65  0
   public final int getNbFractionDigits() {
 66  0
     int res;
 67  0
     String s = getCanonicalForm_();
 68  0
     int idx = s.indexOf('.');
 69  0
     if (idx >= 0) {
 70  0
       res = getNbDigits(s.substring(idx + 1));
 71   
     } else {
 72  0
       res = 0;
 73   
     }
 74  0
     return res;
 75   
   }
 76   
 
 77   
   /**
 78   
    * Gets the number of digits contained in the specified string.
 79   
    *
 80   
    * @param aString <i>(required)</i>.
 81   
    * @return The number of digits.
 82   
    */
 83  0
   private static int getNbDigits(String aString) {
 84  0
     int res = 0;
 85  0
     for (int i = aString.length(); --i >= 0; ) {
 86  0
       char c = aString.charAt(i);
 87  0
       if (Character.isDigit(c)) {
 88  0
         res++;
 89   
       }
 90   
     }
 91  0
     return res;
 92   
   }
 93   
 
 94   
 
 95   
 }
 96