Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 79   Methods: 6
NCLOC: 54   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
TypeDef.java 70% 81% 100% 81,1%
 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.Set;
 13   
 
 14   
 import org.jbind.xml.base.IAttribute;
 15   
 import org.jbind.xml.base.IBindingAttributes;
 16   
 import org.jbind.xml.base.ISymbolspace;
 17   
 import org.jbind.xml.base.ISymbolspaces;
 18   
 import org.jbind.xml.msg.IConstraintViolations;
 19   
 import org.jbind.xml.msg.XmlException;
 20   
 import org.jbind.xml.msg.XmlMessages;
 21   
 import org.jbind.xml.schema.instantiation.IElemValHelper;
 22   
 
 23   
 public abstract class TypeDef extends Named implements ITypeDef {
 24   
 
 25   
   /**
 26   
    * <i>(optional)</i>.
 27   
    */
 28   
   private Set myFinalTypes = null;
 29   
 
 30   
   private String myRole = null;
 31   
 
 32  797
   public TypeDef(CreationParams aCreationParams, String aRole) {
 33  797
     super(aCreationParams);
 34  797
     if (null != aRole) {
 35  287
       myRole = aRole.substring(aRole.lastIndexOf('.') + 1);
 36   
     }
 37   
   }
 38   
 
 39  623
   protected IAttribute doCreateAttribute(ACParams anACParams) throws XmlException {
 40  623
     IAttribute res = null;
 41  623
     String upan = NameUtil.getBindingAttributeName(anACParams);
 42  623
     String an = NameUtil.getSchemaAttributeName(anACParams);
 43  623
     if (IBindingAttributes.HAS_BEHAVIOUR.equals(upan)) {
 44  0
       res = new BooleanAttribute(anACParams);
 45  623
     } else if ("final".equals(an)) {
 46  0
       res = new Attribute(anACParams);
 47  0
       myFinalTypes = ConstantResolver.getFinalTypes(res.getStringValue(), this);
 48   
     } else {
 49  623
       res = super.doCreateAttribute(anACParams);
 50   
     }
 51  623
     return res;
 52   
   }
 53   
 
 54  735
   public Set getFinalTypes() {
 55  735
     return myFinalTypes;
 56   
   }
 57   
 
 58  534
   public ISymbolspace getSymbolSpace() {
 59  534
     return ISymbolspaces.TYPE;
 60   
   }
 61   
 
 62  770
   protected String getRole() {
 63  770
     return myRole;
 64   
   }
 65   
 
 66  797
   public void validateElement(IElemValHelper aHelper, IConstraintViolations aViolations) {
 67  797
     super.validateElement(aHelper, aViolations);
 68  797
     if ((null == getName()) && isTopLevelComponent()) {
 69  0
       aViolations.add(XmlMessages.missingAttribute("name", this));
 70   
     }
 71  797
     if ((null != getName()) && !isTopLevelComponent()) {
 72  4
       aViolations.add(XmlMessages.inlinedTypeMustNotHaveName(this));
 73   
     }
 74   
     assert ((null != myRole) && !isTopLevelComponent()) || ((null == myRole) && isTopLevelComponent()) :
 75   
            "a type must have a role exactly if it is anonymous: " + this;
 76   
   }
 77   
 
 78   
 }
 79