Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 70   Methods: 6
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
ElementKeyRefConstraint.java 87,5% 78,6% 50% 75%
 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.constraint;
 11   
 
 12   
 import java.util.Iterator;
 13   
 
 14   
 import org.jbind.xml.core.base.IKey;
 15   
 import org.jbind.xml.core.base.IKeyStore;
 16   
 import org.jbind.xml.core.bridge.IDataImpl;
 17   
 import org.jbind.xml.core.cmp.ISourceInfo;
 18   
 import org.jbind.xml.core.constraint.ConstraintType;
 19   
 import org.jbind.xml.core.constraint.IElementInstanceConstraint;
 20   
 import org.jbind.xml.core.constraint.IElementKeyRefConstraint;
 21   
 import org.jbind.xml.core.data.IAnyTypeData;
 22   
 import org.jbind.xml.core.data.IDataContext;
 23   
 import org.jbind.xml.msg.IConstraintViolations;
 24   
 import org.jbind.xml.msg.XmlException;
 25   
 import org.jbind.xml.msg.XmlMessages;
 26   
 
 27   
 public class ElementKeyRefConstraint extends ElementIdentityConstraint implements IElementKeyRefConstraint {
 28   
 
 29   
   private IElementInstanceConstraint myRefer = null;
 30   
 
 31  15
   public ElementKeyRefConstraint(ISourceInfo aSourceInfo, String aNamespace, String aName) {
 32  15
     super(aSourceInfo, aNamespace, aName);
 33   
   }
 34   
 
 35  0
   public void globalCheck(IDataContext aContext, IAnyTypeData aData, IAnyTypeData anEnclosingData, IConstraintViolations aViolations) {}
 36   
 
 37  25
   public void checkElementKeys(IKeyStore anElementKeys, IAnyTypeData aData, IConstraintViolations aViolations) {
 38  25
     try {
 39  25
       for (Iterator i = select(aData); i.hasNext(); ) {
 40  43
         IDataImpl d = (IDataImpl)i.next();
 41  43
         IKey key = createKey(d, true, aViolations);
 42  43
         if (null != key) {
 43  43
           if (!anElementKeys.contains(myRefer.getGlobalRef(), key)) {
 44  6
             if (anElementKeys.isAmbiguous(myRefer.getGlobalRef(), key)) {
 45  1
               aViolations.add(XmlMessages.ambiguousReference(myRefer.getGlobalRef(), key, aData.getImpl_()));
 46   
             } else {
 47  5
               aViolations.add(XmlMessages.unresolvedReference(myRefer.getGlobalRef(), key, aData.getImpl_()));
 48   
             }
 49   
           }
 50   
         }
 51   
       }
 52   
     } catch (XmlException e) {
 53  0
       aViolations.add(e.getXmlMessage());
 54   
     }
 55   
   }
 56   
 
 57  0
   public ConstraintType getConstraintType() {
 58  0
     return ConstraintType.ELEMENT_KEY_REF;
 59   
   }
 60   
 
 61  12
   public void setRefer(IElementInstanceConstraint aConstraint) {
 62  12
     myRefer = aConstraint;
 63   
   }
 64   
 
 65  0
   public boolean isSingleNotMultipleReference() {
 66  0
     return getSelector().selectsZeroOrOneNode();
 67   
   }
 68   
 
 69   
 }
 70