Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 111   Methods: 10
NCLOC: 86   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
AnyListTypeData.java 57,1% 65,9% 70% 64,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.util.ArrayList;
 13   
 import java.util.Enumeration;
 14   
 import java.util.Iterator;
 15   
 import java.util.List;
 16   
 import java.util.ListIterator;
 17   
 import java.util.StringTokenizer;
 18   
 
 19   
 import org.jbind.util.other.StrBuffer;
 20   
 import org.jbind.xml.core.data.IAnyListTypeData;
 21   
 import org.jbind.xml.core.data.IAnySimpleTypeData;
 22   
 import org.jbind.xml.core.data.IAnyTypeData;
 23   
 import org.jbind.xml.core.type.IListType;
 24   
 import org.jbind.xml.core.type.ISimpleType;
 25   
 import org.jbind.xml.msg.IConstraintViolations;
 26   
 import org.jbind.xml.msg.XmlException;
 27   
 
 28   
 public class AnyListTypeData extends AbstractSimpleData implements IAnyListTypeData {
 29   
 
 30   
   private List myValue = null;
 31   
 
 32  47
   public void doAccept(String aString) throws XmlException {
 33  47
     super.doAccept(aString);
 34  47
     IListType listType = (IListType)getType_().getSimpleContentType();
 35  47
     ISimpleType itemType = listType.getItemType();
 36  47
     List l = new ArrayList();
 37  47
     for (Enumeration e = new StringTokenizer(aString); e.hasMoreElements(); ) {
 38  98
       String s = (String)e.nextElement();
 39  98
       l.add(itemType.createData(new StringDataImpl(s, getImpl_().getPrefixToNamespaceMapping(), getImpl_())));
 40   
     }
 41  46
     myValue = l;
 42   
   }
 43   
 
 44  5
   public List getList() {
 45  5
     return myValue;
 46   
   }
 47   
 
 48  5
   public int getLength() {
 49  5
     return myValue.size();
 50   
   }
 51   
 
 52  0
   public void setList(List aNewValue) throws XmlException {
 53  0
     IListType listType = (IListType)getType_().getSimpleContentType();
 54  0
     List oldValue = myValue;
 55  0
     myValue = aNewValue;
 56  0
     IConstraintViolations violations = completeSimpleStorageAssignment_();
 57  0
     if (!violations.isEmpty()) {
 58  0
       myValue = oldValue;
 59  0
       throw new XmlException(violations);
 60   
     }
 61   
   }
 62   
 
 63  78
   public ListIterator iterItems() {
 64  78
     return myValue.listIterator();
 65   
   }
 66   
 
 67  0
   public String getCanonicalForm_() {
 68  0
     StrBuffer sb = new StrBuffer();
 69  0
     for (Iterator i = iterItems(); i.hasNext(); ) {
 70  0
       sb.append(((IAnySimpleTypeData)i.next()).getCanonicalForm_());
 71  0
       sb.append(i.hasNext() ? " " : "");
 72   
     }
 73  0
     return sb.toString();
 74   
   }
 75   
 
 76  1
   public boolean simpleStorageValueEquals(IAnyTypeData aData) {
 77  1
     if (!(aData instanceof IAnyListTypeData)) {
 78  0
       return false;
 79   
     }
 80  1
     boolean equals = true;
 81  1
     Iterator i1 = iterItems();
 82  1
     Iterator i2 = ((IAnyListTypeData)aData).iterItems();
 83  1
     while (equals && i1.hasNext() && i2.hasNext()) {
 84  3
       Object d1 = i1.next();
 85  3
       Object d2 = i2.next();
 86  3
       equals = d1.equals(d2);
 87   
     }
 88  1
     if (equals) {
 89  1
       equals = !i1.hasNext() && !i2.hasNext();
 90   
     }
 91  1
     return equals;
 92   
   }
 93   
 
 94  5
   public int simpleStorageValueHashCode() {
 95  5
     int hc = 0;
 96  5
     for (Iterator i = iterItems(); i.hasNext(); ) {
 97  15
       hc += i.next().hashCode();
 98   
     }
 99  5
     return hc;
 100   
   }
 101   
 
 102  1
   public Object getSimpleStorageObject() {
 103  1
     return myValue;
 104   
   }
 105   
 
 106  0
   public void setSimpleStorageObject(Object aValue) {
 107  0
     myValue = (List)aValue;
 108   
   }
 109   
 
 110   
 }
 111