Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 87   Methods: 9
NCLOC: 65   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
PointInTime.java 50% 96,8% 100% 89,6%
 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 java.math.BigDecimal;
 13   
 
 14   
 import org.jbind.util.other.StrBuffer;
 15   
 import org.jbind.xml.core.data.IPointInTime;
 16   
 
 17   
 public class PointInTime implements IPointInTime {
 18   
 
 19   
   private static final BigDecimal ZERO = new BigDecimal("0");
 20   
 
 21   
   protected int myHour;
 22   
   protected int myMinute;
 23   
   protected int mySecond;
 24   
   protected BigDecimal myFraction = null;
 25   
 
 26   
   protected boolean myHadTimeZone;
 27   
 
 28  35
   public PointInTime(int aHour, int aMinute, int aSecond, BigDecimal aFraction, boolean aHadTimeZone) {
 29  35
     myHour = aHour;
 30  35
     myMinute = aMinute;
 31  35
     mySecond = aSecond;
 32  35
     myFraction = aFraction;
 33  35
     myHadTimeZone = aHadTimeZone;
 34   
   }
 35   
 
 36  59
   public int getHour() {
 37  59
     return myHour;
 38   
   }
 39  59
   public int getMinute() {
 40  59
     return myMinute;
 41   
   }
 42  59
   public int getSecond() {
 43  59
     return mySecond;
 44   
   }
 45  74
   public BigDecimal getFraction() {
 46  74
     return myFraction;
 47   
   }
 48  23
   public boolean hadTimeZone() {
 49  23
     return myHadTimeZone;
 50   
   }
 51   
 
 52  8
   public boolean equals(Object anObject) {
 53  8
     boolean res = anObject instanceof IPointInTime;
 54  8
     if (res) {
 55  8
       IPointInTime t = (IPointInTime)anObject;
 56  8
       res = (myHour == t.getHour()) && (myMinute == t.getMinute()) && (mySecond == t.getSecond()) && (myHadTimeZone == t.hadTimeZone());
 57  8
       if (res) {
 58  8
         BigDecimal f1 = (null == myFraction) ? ZERO : myFraction;
 59  8
         BigDecimal f2 = (null == t.getFraction()) ? ZERO : t.getFraction();
 60  8
         res = f1.compareTo(f2) == 0;
 61   
       }
 62   
     }
 63  8
     return res;
 64   
   }
 65   
 
 66  16
   public int hashCode() {
 67  16
     return myHour + myMinute + mySecond;
 68   
   }
 69   
 
 70  1
   public String toString() {
 71  1
     StrBuffer sb = new StrBuffer();
 72  1
     TimeHelper.output(myHour, 2, sb);
 73  1
     sb.append(':');
 74  1
     TimeHelper.output(myMinute, 2, sb);
 75  1
     sb.append(':');
 76  1
     TimeHelper.output(mySecond, 2, sb);
 77  1
     if (null != myFraction) {
 78  1
       sb.append(myFraction.toString().substring(1));
 79   
     }
 80  1
     if (hadTimeZone()) {
 81  0
       sb.append('Z');
 82   
     }
 83  1
     return sb.toString();
 84   
   }
 85   
 
 86   
 }
 87