Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 59   Methods: 4
NCLOC: 41   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
ElementUniqueConstraint.java 100% 83,3% 50% 81,8%
 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.HashSet;
 13   
 import java.util.Iterator;
 14   
 import java.util.Set;
 15   
 
 16   
 import org.jbind.xml.core.base.IKey;
 17   
 import org.jbind.xml.core.base.IKeyStore;
 18   
 import org.jbind.xml.core.bridge.IDataImpl;
 19   
 import org.jbind.xml.core.cmp.ISourceInfo;
 20   
 import org.jbind.xml.core.constraint.ConstraintType;
 21   
 import org.jbind.xml.core.constraint.IElementUniqueConstraint;
 22   
 import org.jbind.xml.core.data.IAnyTypeData;
 23   
 import org.jbind.xml.core.data.IDataContext;
 24   
 import org.jbind.xml.msg.IConstraintViolations;
 25   
 import org.jbind.xml.msg.XmlException;
 26   
 import org.jbind.xml.msg.XmlMessages;
 27   
 
 28   
 public class ElementUniqueConstraint extends ElementInstanceConstraint implements IElementUniqueConstraint {
 29   
 
 30  5
   public ElementUniqueConstraint(ISourceInfo aSourceInfo, String aNamespace, String aName) {
 31  5
     super(aSourceInfo, aNamespace, aName);
 32   
   }
 33   
 
 34  0
   public void globalCheck(IDataContext aContext, IAnyTypeData aData, IAnyTypeData anEnclosingData, IConstraintViolations aViolations) {}
 35   
 
 36  14
   public void checkElementKeys(IKeyStore anElementKeys, IAnyTypeData aData, IConstraintViolations aViolations) {
 37  14
     try {
 38  14
       Set keys = new HashSet(17);
 39  14
       for (Iterator i = select(aData); i.hasNext(); ) {
 40  24
         IDataImpl d = (IDataImpl)i.next();
 41  24
         IKey key = createKey(d, true, aViolations);
 42  24
         if (null != key) {
 43  20
           if (!keys.add(key)) {
 44  2
             aViolations.add(XmlMessages.keyNotUniqueInIndex(getGlobalRef(), key, d));
 45   
           }
 46   
         }
 47   
       }
 48  14
       anElementKeys.addKeys(getGlobalRef(), keys);
 49   
     } catch (XmlException e) {
 50  0
       aViolations.add(e.getXmlMessage());
 51   
     }
 52   
   }
 53   
 
 54  0
   public ConstraintType getConstraintType() {
 55  0
     return ConstraintType.ELEMENT_UNIQUE;
 56   
   }
 57   
 
 58   
 }
 59