Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 75   Methods: 7
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
ElemDesc.java 100% 94,4% 85,7% 92,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.schema.cmp;
 11   
 
 12   
 import org.jbind.xml.base.Compositor;
 13   
 import org.jbind.xml.base.IRange;
 14   
 import org.jbind.xml.base.Range;
 15   
 import org.jbind.xml.core.bridge.IDataImpl;
 16   
 import org.jbind.xml.core.cmp.ISourceInfo;
 17   
 import org.jbind.xml.core.content.IElemDesc;
 18   
 import org.jbind.xml.core.content.IElemGroupDesc;
 19   
 import org.jbind.xml.core.content.IUseState;
 20   
 import org.jbind.xml.core.data.IAnyTypeData;
 21   
 import org.jbind.xml.core.type.IAnyType;
 22   
 import org.jbind.xml.msg.XmlException;
 23   
 
 24   
 public abstract class ElemDesc extends Content implements IElemDesc {
 25   
 
 26  1453
   public ElemDesc(ISourceInfo aSourceInfo, String aNamespace, String aName, IRange aRange) {
 27  1453
     super(aSourceInfo, aNamespace, aName, aRange);
 28   
   }
 29   
 
 30  2394
   public final IAnyTypeData createData(IDataImpl anImpl, IAnyType anOverloadingType) throws XmlException {
 31  2394
     return DataDescHelper.createData(this, anImpl, anOverloadingType, anImpl);
 32   
   }
 33   
 
 34  10
   public final IAnyTypeData createUncheckedData(IDataImpl anImpl, IAnyType anOverloadingType) throws XmlException {
 35  10
     return DataDescHelper.createUncheckedData(this, anImpl, anOverloadingType, anImpl);
 36   
   }
 37   
 
 38  0
   public final IAnyTypeData createEmptyData(IDataImpl anImpl, IAnyType anOverloadingType) throws XmlException {
 39  0
     return DataDescHelper.createEmptyData(this, anImpl, anOverloadingType, anImpl);
 40   
   }
 41   
 
 42  2338
   public final void checkValueConstraints(IAnyTypeData aData) throws XmlException {
 43  2338
     DataDescHelper.checkValueConstraints(this, aData);
 44   
   }
 45   
 
 46  4656
   public final IUseState createUseStateProxy(IUseState aParent) {
 47  4656
     return createUseState(aParent);
 48   
   }
 49   
 
 50  2081
   public boolean addToParent(IElemGroupDesc aParent) {
 51  2081
     boolean changed;
 52   
     // EXTENSION
 53   
     // b2: If a choice has minOccurs=0 and then all contained particles that have
 54   
     //     a minOccurs=1 get also a minOccurs=0.
 55   
     // b3: If a choice has maxOccurs=unbounded and the maxOccurs of the particle
 56   
     //     is >0 but not already unbounded then the maxOccurs is set to unbounded.
 57  2081
     boolean b1 = aParent.getCompositor() == Compositor.CHOICE;
 58  2081
     boolean b2 = b1 && (getMinOccurs() == 1) && (aParent.getMinOccurs() == 0);
 59  2081
     boolean b3 = b1 && !isUnbounded() && (getMaxOccurs() != 0) && aParent.isUnbounded();
 60   
 
 61  2081
     if (b2 || b3) {
 62  494
       int newMin = b2 ? 0 : getMinOccurs();
 63  494
       IRange newRange = (isUnbounded() || b3) ? new Range(newMin) : new Range(newMin, getMaxOccurs());
 64  494
       doAddToParentWithNewRange(newRange, aParent);
 65  494
       changed = true;
 66   
     } else {
 67  1587
       aParent.add(this);
 68  1587
       changed = false;
 69   
     }
 70  2081
     return changed;
 71   
   }
 72   
 
 73   
   protected abstract void doAddToParentWithNewRange(IRange aRange, IElemGroupDesc aParent);
 74   
 }
 75