Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 110   Methods: 11
NCLOC: 83   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
AttributeInfos.java 92,9% 93,8% 90,9% 93%
 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.element;
 11   
 
 12   
 import java.util.Iterator;
 13   
 
 14   
 import org.jbind.xml.base.IAttribute;
 15   
 import org.jbind.xml.base.IBindingAttributes;
 16   
 import org.jbind.xml.core.cmp.IComponent;
 17   
 import org.jbind.xml.core.cmp.ISourceInfo;
 18   
 import org.jbind.xml.core.content.IAttrGroupDecl;
 19   
 import org.jbind.xml.core.content.IAttrGroupRef;
 20   
 import org.jbind.xml.core.content.IAttrRefOrDecl;
 21   
 import org.jbind.xml.core.content.IAttrWildcard;
 22   
 import org.jbind.xml.msg.IConstraintViolations;
 23   
 import org.jbind.xml.schema.instantiation.IComponentSetter;
 24   
 import org.jbind.xml.schema.instantiation.IElementHelper;
 25   
 import org.jbind.xml.schema.instantiation.IJobRefs;
 26   
 
 27   
 public class AttributeInfos implements IAttributeInfos {
 28   
 
 29   
   private IElement myElement = null;
 30   
   private IAnyAttribute myAnyAttribute = null;
 31   
 
 32  573
   public AttributeInfos(IElement anElement) {
 33   
     assert null != anElement : "element must not be null";
 34  573
     myElement = anElement;
 35   
   }
 36   
 
 37  0
   public IAnyAttribute getAnyAttribute() {
 38  0
     return myAnyAttribute;
 39   
   }
 40   
 
 41  1799
   public Iterator iterAttributeDeclarations() {
 42  1799
     return myElement.iterChildrenByClass(IAttributeDeclaration.class);
 43   
   }
 44   
 
 45  1804
   public Iterator iterAttributeGroupRefs() {
 46  1804
     return myElement.iterChildrenByClass(IAttributeGroupRef.class);
 47   
   }
 48   
 
 49  573
   public void validate(IConstraintViolations aViolations) {
 50  573
     myAnyAttribute = (IAnyAttribute)myElement.getSubElement(IAnyAttribute.class, "duplicate anyAttribute", aViolations);
 51   
   }
 52   
 
 53  1262
   public void collectRefsForCreation(IJobRefs aJobRefs) {
 54  1262
     for (Iterator i = iterAttributeDeclarations(); i.hasNext(); ) {
 55  1259
       IAttributeDeclaration ad = (IAttributeDeclaration)i.next();
 56  1259
       if (null != ad.getRef()) {
 57  53
         aJobRefs.add(ad.getRef(), true, ad);
 58   
       }
 59  1259
       IAttribute a = ad.getLocalBindingAttribute(IBindingAttributes.REFERENCED_TYPE);
 60  1259
       if (null != a) {
 61  0
         aJobRefs.add(a.getRef(), false, ad);
 62   
       }
 63   
     }
 64  1262
     for (Iterator i = iterAttributeGroupRefs(); i.hasNext(); ) {
 65  97
       IAttributeGroupRef gr = (IAttributeGroupRef)i.next();
 66  97
       aJobRefs.add(gr.getRef(), true, gr);
 67   
     }
 68   
   }
 69   
 
 70  537
   public void applyAttributes(IElementHelper anElementHelper, final IAttrGroupDecl anAttrGroupDecl, final IConstraintViolations aViolations) {
 71  537
     for (Iterator i = iterAttributeDeclarations(); i.hasNext(); ) {
 72  608
       IAttributeDeclaration ad = (IAttributeDeclaration)i.next();
 73   
 
 74  608
       anElementHelper.addSubJob(ad, new IComponentSetter() {
 75  608
         public void set(IComponent aComponent, IConstraintViolations aVls) {
 76  608
           IAttrRefOrDecl decl = (IAttrRefOrDecl)aComponent;
 77  608
           anAttrGroupDecl.add(decl, aVls);
 78   
         }
 79   
       });
 80   
 
 81   
     }
 82   
 
 83  537
     int counter = 0;
 84   
 
 85  537
     for (Iterator i = iterAttributeGroupRefs(); i.hasNext(); ) {
 86  49
       IAttributeGroupRef gr = (IAttributeGroupRef)i.next();
 87  49
       final int index = counter++;
 88  49
       anElementHelper.addSubJob(gr, new IComponentSetter() {
 89  49
         public void set(IComponent aComponent, IConstraintViolations aVls) {
 90  49
           IAttrGroupRef attrGroupRef = (IAttrGroupRef)aComponent;
 91  49
           anAttrGroupDecl.add(attrGroupRef, index, aVls);
 92   
         }
 93   
       });
 94   
     }
 95   
 
 96  537
     if (null != myAnyAttribute) {
 97  66
       anElementHelper.addSubJob(myAnyAttribute, new IComponentSetter() {
 98  66
         public void set(IComponent aComponent, IConstraintViolations aVls) {
 99  66
           IAttrWildcard wildcard = (IAttrWildcard)aComponent;
 100  66
           anAttrGroupDecl.add(wildcard, aVls);
 101   
         }
 102   
       });
 103   
     }
 104   
   }
 105   
 
 106  485
   public ISourceInfo getSourceInfo() {
 107  485
     return myElement;
 108   
   }
 109   
 }
 110