Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 69   Methods: 6
NCLOC: 49   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
Key.java 75% 95,7% 83,3% 87,8%
 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.schema.constraint;
 11   
 
 12   
 import java.util.ArrayList;
 13   
 import java.util.Iterator;
 14   
 import java.util.List;
 15   
 
 16   
 import org.jbind.xml.core.base.IKey;
 17   
 
 18   
 public class Key implements IKey {
 19   
 
 20   
   private List myList = new ArrayList();
 21   
 
 22  253
   public Key() {}
 23   
 
 24  0
   public Key(Object aData) {
 25   
     assert null != aData : "data must not be null";
 26  0
     myList.add(aData);
 27   
   }
 28   
 
 29  278
   public void add(Object anObject) {
 30  278
     myList.add(anObject);
 31   
   }
 32   
 
 33  75
   public boolean equals(Object anObject) {
 34  75
     boolean equals = false;
 35  75
     if (anObject instanceof Key) {
 36  75
       Key key = (Key)anObject;
 37  75
       if (myList.size() == key.myList.size()) {
 38  75
         equals = true;
 39  75
         for (int i = myList.size(); equals && (--i >= 0); ) {
 40  88
           Object o1 = myList.get(i);
 41  88
           Object o2 = key.myList.get(i);
 42  88
           equals = (((o1 == null) && (o2 == null)) || ((o1 != null) && o1.equals(o2)));
 43   
         }
 44   
       }
 45   
     }
 46  75
     return equals;
 47   
   }
 48   
 
 49  562
   public int hashCode() {
 50  562
     int hashCode = 0;
 51  562
     for (Iterator i = myList.iterator(); i.hasNext(); ) {
 52  625
       Object o = i.next();
 53  625
       if (null != o) {
 54  625
         hashCode += o.hashCode();
 55   
       }
 56   
     }
 57  562
     return hashCode;
 58   
   }
 59   
 
 60  12
   public String toString() {
 61  12
     StringBuffer sb = new StringBuffer("(");
 62  12
     for (Iterator i = myList.iterator(); i.hasNext(); ) {
 63  15
       sb.append(i.next()).append(i.hasNext() ? ", " : "");
 64   
     }
 65  12
     sb.append(")");
 66  12
     return sb.toString();
 67   
   }
 68   
 }
 69