Clover coverage report - JBind Project
Coverage timestamp: Fr Mai 28 2004 11:17:36 CEST
file stats: LOC: 79   Methods: 7
NCLOC: 57   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
XPathConstraint.java 83,3% 70,6% 57,1% 70%
 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.Collections;
 13   
 import java.util.Iterator;
 14   
 
 15   
 import org.jbind.xml.base.IHasLocation;
 16   
 import org.jbind.xml.base.ILocation;
 17   
 import org.jbind.xml.core.bridge.IDataImpl;
 18   
 import org.jbind.xml.core.bridge.IXPath;
 19   
 import org.jbind.xml.core.constraint.ConstraintType;
 20   
 import org.jbind.xml.core.constraint.ICheckContext;
 21   
 import org.jbind.xml.core.constraint.IConstraint;
 22   
 import org.jbind.xml.core.constraint.IXPathConstraint;
 23   
 import org.jbind.xml.core.data.IAnyTypeData;
 24   
 import org.jbind.xml.core.data.IDataContext;
 25   
 import org.jbind.xml.msg.IConstraintViolations;
 26   
 import org.jbind.xml.msg.XmlException;
 27   
 import org.jbind.xml.msg.XmlMessages;
 28   
 
 29   
 public class XPathConstraint implements IXPathConstraint {
 30   
 
 31   
   private IXPath myTest = null;
 32   
   private IXPath mySelect = null;
 33   
   private IHasLocation myHasLocation = null;
 34   
 
 35  2
   public XPathConstraint(IXPath aTest, IXPath aSelect, IHasLocation aHasLocation) {
 36  2
     myTest = aTest;
 37  2
     mySelect = aSelect;
 38  2
     myHasLocation = aHasLocation;
 39   
   }
 40   
 
 41  4
   public ConstraintType getConstraintType() {
 42  4
     return ConstraintType.XPATH_CONSTRAINT;
 43   
   }
 44   
 
 45  0
   public ILocation getLocation() {
 46  0
     return (null != myHasLocation) ? myHasLocation.getLocation() : null;
 47   
   }
 48   
 
 49  22
   public void globalCheck(IDataContext aContext, IAnyTypeData aData, IAnyTypeData anEnclosingData, IConstraintViolations aViolations) {
 50  22
     try {
 51  22
       Iterator i = null;
 52  22
       if (null != mySelect) {
 53  0
         i = mySelect.select((IDataImpl)aData.getImpl_());
 54   
       } else {
 55  22
         i = Collections.singletonList(aData.getImpl_()).iterator();
 56   
       }
 57  22
       while (i.hasNext()) {
 58  22
         IDataImpl data = (IDataImpl)i.next();
 59  22
         if (!myTest.test(data)) {
 60  2
           aViolations.add(XmlMessages.xPathConstraint(myTest, mySelect, data.getLocation(), aData.getImpl_()));
 61   
         }
 62   
       }
 63   
     } catch (XmlException e) {
 64  0
       aViolations.add(e.getXmlMessage());
 65   
     }
 66   
   }
 67   
 
 68  0
   public boolean isFinal() {
 69  0
     return false;
 70   
   }
 71   
 
 72  0
   public boolean isRestriction(IConstraint aConstraint) {
 73  0
     return false;
 74   
   }
 75   
 
 76  22
   public void localCheck(ICheckContext aCheckContext, IAnyTypeData aData, IConstraintViolations aViolations) {}
 77   
 
 78   
 }
 79