Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 87   Methods: 9
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
AbstractListType.java 66,7% 90% 88,9% 85,7%
 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.cmp;
 11   
 
 12   
 import java.util.HashSet;
 13   
 import java.util.Iterator;
 14   
 import java.util.List;
 15   
 import java.util.Set;
 16   
 
 17   
 import org.jbind.xml.base.FinalType;
 18   
 import org.jbind.xml.base.WhiteSpaceProcessing;
 19   
 import org.jbind.xml.core.bridge.IDataImpl;
 20   
 import org.jbind.xml.core.cmp.ISourceInfo;
 21   
 import org.jbind.xml.core.constraint.ConstraintType;
 22   
 import org.jbind.xml.core.constraint.ICheckContext;
 23   
 import org.jbind.xml.core.data.IAnyListTypeData;
 24   
 import org.jbind.xml.core.data.IAnyTypeData;
 25   
 import org.jbind.xml.core.type.IAnyType;
 26   
 import org.jbind.xml.core.type.IListType;
 27   
 import org.jbind.xml.core.type.ISimpleType;
 28   
 import org.jbind.xml.msg.IConstraintViolations;
 29   
 import org.jbind.xml.msg.XmlException;
 30   
 import org.jbind.xml.msg.XmlMessages;
 31   
 import org.jbind.xml.schema.constraint.Constraints;
 32   
 
 33   
 public abstract class AbstractListType extends SimpleType implements IListType {
 34   
 
 35  35
   private static Set addFinalList(Set aSet) {
 36  35
     Set res = new HashSet(17);
 37  35
     if (null != aSet) {
 38  35
       res.addAll(aSet);
 39   
     }
 40  35
     res.add(FinalType.LIST);
 41  35
     return res;
 42   
   }
 43   
 
 44  13
   public final boolean isApplicable(ConstraintType aConstraintType) {
 45  13
     return ConstraintType.CHECKER_LWEP.isApplicable(aConstraintType);
 46   
   }
 47   
 
 48  35
   public AbstractListType(ISourceInfo aSourceInfo, String aNamespace, String aName, String aRole, Set aFinalTypes) {
 49  35
     super(aSourceInfo, aNamespace, aName, aRole, addFinalList(aFinalTypes));
 50  35
     setConstraints(new Constraints());
 51  35
     getConstraints().setWhiteSpaceProcessing(WhiteSpaceProcessing.COLLAPSE);
 52   
   }
 53   
 
 54  42
   public final IAnyType getInstanceType() {
 55  42
     return this;
 56   
   }
 57   
 
 58  0
   public final IAnyTypeData createItem(IDataImpl anImpl) throws XmlException {
 59  0
     return getItemType().createUncheckedData(anImpl);
 60   
   }
 61   
 
 62  11
   public final ISimpleType createRestriction(ISourceInfo aSourceInfo, String aNamespace, String aName, String aRole, Set aFinalTypes, IConstraintViolations aViolations) {
 63  11
     return new RestrictedListType(aSourceInfo, aNamespace, aName, aRole, aFinalTypes, aViolations);
 64   
   }
 65   
 
 66  131
   public final Class getSimpleStorageType() {
 67  131
     return List.class;
 68   
   }
 69   
 
 70  66
   public final void checkEnclosedConstraints(ICheckContext aContext) {
 71  66
     IAnyListTypeData ld = (IAnyListTypeData)aContext.getData();
 72  66
     for (Iterator i = ld.iterItems(); i.hasNext(); ) {
 73  157
       IAnyTypeData item = (IAnyTypeData)i.next();
 74  157
       if (!getItemType().canBeOverloadedBy(item.getType_())) {
 75  0
         aContext.add(XmlMessages.invalidDataTypeofListItem(item, item.getType_(), getItemType(), null));
 76   
       } else {
 77  157
         getItemType().checkConstraints(aContext.newNestedContext(item));
 78   
       }
 79   
     }
 80   
   }
 81   
 
 82  25
   public final boolean isUnion() {
 83  25
     return false;
 84   
   }
 85   
 
 86   
 }
 87