Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 89   Methods: 9
NCLOC: 69   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
AttrRef.java 80% 78,6% 77,8% 78,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 org.jbind.xml.base.AttributeOccurence;
 13   
 import org.jbind.xml.base.IAttribute;
 14   
 import org.jbind.xml.core.cmp.IComponentVisitor;
 15   
 import org.jbind.xml.core.cmp.ISourceInfo;
 16   
 import org.jbind.xml.core.content.IAttrRef;
 17   
 import org.jbind.xml.core.content.IAttrRefOrDecl;
 18   
 import org.jbind.xml.core.data.ISimpleData;
 19   
 import org.jbind.xml.core.type.IAnyType;
 20   
 import org.jbind.xml.instance.data.StringDataImpl;
 21   
 import org.jbind.xml.msg.IConstraintViolations;
 22   
 import org.jbind.xml.msg.XmlException;
 23   
 import org.jbind.xml.msg.XmlMessages;
 24   
 
 25   
 public class AttrRef extends AttrRefOrDecl implements IAttrRef {
 26   
 
 27   
   private IAttrRefOrDecl myAttrRefOrDecl;
 28   
 
 29  33
   public AttrRef(ISourceInfo aSourceInfo, AttributeOccurence anOccurence, IAttrRefOrDecl anAttr) {
 30  33
     super(aSourceInfo, anAttr.getNamespace(), anAttr.getName(), anOccurence);
 31  33
     myAttrRefOrDecl = anAttr;
 32   
   }
 33   
 
 34  52
   public void accept(IComponentVisitor aVisitor) throws XmlException {
 35  52
     aVisitor.visitAttrRefStart(this);
 36  52
     visitSubComponents(aVisitor);
 37  52
     aVisitor.visitAttrRefEnd(this);
 38   
   }
 39   
 
 40  30
   public void addValueConstraints(String aDefault, String aFixed, IConstraintViolations aViolations) {
 41  30
     try {
 42  30
       myDefault = (null != aDefault) ? (ISimpleData)getType().createData(new StringDataImpl(aDefault, getPrefixToNamespaceMapping(), this)) : null;
 43  30
       myFixed = (null != aFixed) ? (ISimpleData)getType().createData(new StringDataImpl(aFixed, getPrefixToNamespaceMapping(), this)) : null;
 44  30
       if (null == myDefault) {
 45  28
         myDefault = myAttrRefOrDecl.getDefault();
 46   
       }
 47  30
       if (null == myFixed) {
 48  28
         myFixed = myAttrRefOrDecl.getFixed();
 49   
       }
 50  30
       if ((null != myFixed) && (null != myAttrRefOrDecl.getFixed()) && !myFixed.equals(myAttrRefOrDecl.getFixed())) {
 51  0
         aViolations.add(XmlMessages.fixedValueMustNotBeChanged(this));
 52   
       }
 53  30
       if ((null != myDefault) && (null != myAttrRefOrDecl.getFixed()) && !myDefault.equals(myAttrRefOrDecl.getFixed())) {
 54  0
         aViolations.add(XmlMessages.defaultValueMustMatchFixed(this));
 55   
       }
 56  30
       if (null != myFixed) {
 57  4
         myDefault = myFixed;
 58   
       }
 59   
     } catch (XmlException e) {
 60  0
       aViolations.add(e.getXmlMessage());
 61   
     }
 62   
   }
 63   
 
 64  463
   public IAnyType getType() {
 65  463
     return myAttrRefOrDecl.getType();
 66   
   }
 67  0
   public boolean hasDefaultType() {
 68  0
     return myAttrRefOrDecl.hasDefaultType();
 69   
   }
 70   
 
 71  33
   public boolean isReference() {
 72  33
     return true;
 73   
   }
 74   
 
 75  224
   public IAttribute getBindingAttribute(String aName) {
 76  224
     IAttribute a = super.getBindingAttribute(aName);
 77  224
     return (null != a) ? a : myAttrRefOrDecl.getBindingAttribute(aName);
 78   
   }
 79  103
   public IAttribute getLocalBindingAttribute(String aName) {
 80  103
     IAttribute a = super.getLocalBindingAttribute(aName);
 81  103
     return (null != a) ? a : myAttrRefOrDecl.getLocalBindingAttribute(aName);
 82   
   }
 83  0
   public IAttribute getDefaultedLocalBindingAttribute(String aName) {
 84  0
     IAttribute a = super.getLocalBindingAttribute(aName);
 85  0
     return (null != a) ? a : myAttrRefOrDecl.getLocalBindingAttribute(aName);
 86   
   }
 87   
 
 88   
 }
 89