Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 108   Methods: 10
NCLOC: 85   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
AttrGroupDecl.java 90% 90,6% 90% 90,3%
 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.ArrayList;
 13   
 import java.util.Iterator;
 14   
 import java.util.List;
 15   
 
 16   
 import org.jbind.xml.base.ISymbolspace;
 17   
 import org.jbind.xml.base.ISymbolspaces;
 18   
 import org.jbind.xml.core.cmp.IAttributesModel;
 19   
 import org.jbind.xml.core.cmp.IComponentVisitor;
 20   
 import org.jbind.xml.core.cmp.ISourceInfo;
 21   
 import org.jbind.xml.core.cmp.IWildcard;
 22   
 import org.jbind.xml.core.content.IAttrGroupDecl;
 23   
 import org.jbind.xml.core.content.IAttrGroupRef;
 24   
 import org.jbind.xml.core.content.IAttrRefOrDecl;
 25   
 import org.jbind.xml.core.content.IAttrWildcard;
 26   
 import org.jbind.xml.msg.IConstraintViolations;
 27   
 import org.jbind.xml.msg.XmlException;
 28   
 import org.jbind.xml.msg.XmlMessages;
 29   
 
 30   
 public class AttrGroupDecl extends Component implements IAttrGroupDecl {
 31   
 
 32   
   private IAttrWildcard myAttrWildcard = null;
 33   
   private List myAttrGroupRefs = null;
 34   
   private List myAttrRefOrDecls = null;
 35   
 
 36  537
   public AttrGroupDecl(ISourceInfo aSourceInfo, String aNamespace, String aName) {
 37  537
     super(aSourceInfo, aNamespace, aName);
 38   
   }
 39   
 
 40  815
   public ISymbolspace getSymbolspace() {
 41  815
     return ISymbolspaces.ATTRIBUTE_GROUP;
 42   
   }
 43  0
   public boolean isReference() {
 44  0
     return false;
 45   
   }
 46   
 
 47  1165
   public void accept(IComponentVisitor aVisitor) throws XmlException {
 48  1165
     aVisitor.visitAttrGroupDeclStart(this);
 49  1165
     visitSubComponents(aVisitor);
 50  1165
     aVisitor.visitAttrGroupDeclEnd(this);
 51   
   }
 52   
 
 53  66
   public void add(IAttrWildcard aWildcard, IConstraintViolations aViolations) {
 54  66
     if (null != myAttrWildcard) {
 55  0
       aViolations.add(XmlMessages.moreThanOneAttrWildcardInAttrGroup(aWildcard));
 56   
     } else {
 57  66
       myAttrWildcard = aWildcard;
 58   
     }
 59   
   }
 60   
 
 61  608
   public void add(IAttrRefOrDecl anAttribute, IConstraintViolations aViolations) {
 62  608
     if (null == myAttrRefOrDecls) {
 63  244
       myAttrRefOrDecls = new ArrayList();
 64   
     }
 65  608
     myAttrRefOrDecls.add(anAttribute);
 66   
   }
 67   
 
 68  49
   public void add(IAttrGroupRef anAttrGroupRef, int anIndex, IConstraintViolations aViolations) {
 69  49
     if (null == myAttrGroupRefs) {
 70  44
       myAttrGroupRefs = new ArrayList();
 71   
     }
 72  49
     while (myAttrGroupRefs.size() <= anIndex) {
 73  49
       myAttrGroupRefs.add(null);
 74   
     }
 75  49
     myAttrGroupRefs.set(anIndex, anAttrGroupRef);
 76   
   }
 77   
 
 78  520
   public void collectAttributeInfo(IAttributesModel aModel, IConstraintViolations aViolations) {
 79  520
     if (null != myAttrWildcard) {
 80  66
       IWildcard wildcard = aModel.getWildcard();
 81  66
       if (null == wildcard) {
 82  66
         wildcard = myAttrWildcard.getWildcard();
 83   
       } else {
 84  0
         wildcard = wildcard.intersect(myAttrWildcard.getWildcard(), wildcard.getProcessContentsType());
 85   
       }
 86  66
       aModel.setWildcard(wildcard);
 87   
     }
 88  520
     if (null != myAttrRefOrDecls) {
 89  239
       for (Iterator i = myAttrRefOrDecls.iterator(); i.hasNext(); ) {
 90  607
         IAttrRefOrDecl a = (IAttrRefOrDecl)i.next();
 91  607
         aModel.addAttrRefOrDecl(a, aViolations);
 92   
       }
 93   
     }
 94  520
     if (null != myAttrGroupRefs) {
 95  39
       for (Iterator i = myAttrGroupRefs.iterator(); i.hasNext(); ) {
 96  44
         IAttrGroupRef r = (IAttrGroupRef)i.next();
 97  44
         r.collectAttributeInfo(aModel, aViolations);
 98   
       }
 99   
     }
 100   
   }
 101   
 
 102  537
   public void validate(IConstraintViolations aViolations) {}
 103   
 
 104  1835
   public boolean isTopLevelComponent() {
 105  1835
     return null != getName();
 106   
   }
 107   
 }
 108